1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
2 
3 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ferror-limit 100 %s -Wuninitialized
4 
foo()5 void foo() {
6 }
7 
foobool(int argc)8 bool foobool(int argc) {
9   return argc;
10 }
11 
xxx(int argc)12 void xxx(int argc) {
13   int cond; // expected-note {{initialize the variable 'cond' to silence this warning}}
14 #pragma omp distribute parallel for if(cond) // expected-warning {{variable 'cond' is uninitialized when used here}}
15   for (int i = 0; i < 10; ++i)
16     ;
17 }
18 
19 struct S1; // expected-note {{declared here}}
20 
21 template <class T, class S> // expected-note {{declared here}}
tmain(T argc,S ** argv)22 int tmain(T argc, S **argv) {
23   T i, z;
24 #pragma omp target
25 #pragma omp teams
26 #pragma omp distribute parallel for if // expected-error {{expected '(' after 'if'}}
27   for (i = 0; i < argc; ++i) foo();
28 #pragma omp target
29 #pragma omp teams
30 #pragma omp distribute parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
31   for (i = 0; i < argc; ++i) foo();
32 #pragma omp target
33 #pragma omp teams
34 #pragma omp distribute parallel for if () // expected-error {{expected expression}}
35   for (i = 0; i < argc; ++i) foo();
36 #pragma omp target
37 #pragma omp teams
38 #pragma omp distribute parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
39   for (i = 0; i < argc; ++i) foo();
40 #pragma omp target
41 #pragma omp teams
42 #pragma omp distribute parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
43   for (i = 0; i < argc; ++i) foo();
44 #pragma omp target
45 #pragma omp teams
46 #pragma omp distribute parallel for if (argc > 0 ? argv[1] : argv[2])
47   for (i = 0; i < argc; ++i) foo();
48 #pragma omp target
49 #pragma omp teams
50 #pragma omp distribute parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'if' clause}}
51   for (i = 0; i < argc; ++i) foo();
52 #pragma omp target
53 #pragma omp teams
54 #pragma omp distribute parallel for if (S) // expected-error {{'S' does not refer to a value}}
55   for (i = 0; i < argc; ++i) foo();
56 #pragma omp target
57 #pragma omp teams
58 #pragma omp distribute parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
59   for (i = 0; i < argc; ++i) foo();
60 #pragma omp target
61 #pragma omp teams
62 #pragma omp distribute parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
63   for (i = 0; i < argc; ++i) foo();
64 #pragma omp target
65 #pragma omp teams
66 #pragma omp distribute parallel for if(argc+z)
67   for (i = 0; i < argc; ++i) foo();
68 #pragma omp target
69 #pragma omp teams
70 #pragma omp distribute parallel for if(parallel // expected-error {{use of undeclared identifier 'parallel'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
71   for (i = 0; i < argc; ++i) foo();
72 #pragma omp target
73 #pragma omp teams
74 #pragma omp distribute parallel for if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
75   for (i = 0; i < argc; ++i) foo();
76 #pragma omp target
77 #pragma omp teams
78 #pragma omp distribute parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
79   for (i = 0; i < argc; ++i) foo();
80 #pragma omp target
81 #pragma omp teams
82 #pragma omp distribute parallel for if(parallel : argc)
83   for (i = 0; i < argc; ++i) foo();
84 #pragma omp target
85 #pragma omp teams
86 #pragma omp distribute parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp distribute parallel for'}}
87   for (i = 0; i < argc; ++i) foo();
88 #pragma omp target
89 #pragma omp teams
90 #pragma omp distribute parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
91   for (i = 0; i < argc; ++i) foo();
92 #pragma omp target
93 #pragma omp teams
94 #pragma omp distribute parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
95   for (i = 0; i < argc; ++i) foo();
96 #pragma omp target
97 #pragma omp teams
98 #pragma omp distribute parallel for if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp distribute parallel for'}}
99   for (i = 0; i < argc; ++i) foo();
100 
101   return 0;
102 }
103 
main(int argc,char ** argv)104 int main(int argc, char **argv) {
105   int i, z;
106 #pragma omp target
107 #pragma omp teams
108 #pragma omp distribute parallel for if // expected-error {{expected '(' after 'if'}}
109   for (i = 0; i < argc; ++i) foo();
110 #pragma omp target
111 #pragma omp teams
112 #pragma omp distribute parallel for if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
113   for (i = 0; i < argc; ++i) foo();
114 #pragma omp target
115 #pragma omp teams
116 #pragma omp distribute parallel for if () // expected-error {{expected expression}}
117   for (i = 0; i < argc; ++i) foo();
118 #pragma omp target
119 #pragma omp teams
120 #pragma omp distribute parallel for if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
121   for (i = 0; i < argc; ++i) foo();
122 #pragma omp target
123 #pragma omp teams
124 #pragma omp distribute parallel for if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
125   for (i = 0; i < argc; ++i) foo();
126 #pragma omp target
127 #pragma omp teams
128 #pragma omp distribute parallel for if (argc > 0 ? argv[1] : argv[2])
129   for (i = 0; i < argc; ++i) foo();
130 #pragma omp target
131 #pragma omp teams
132 #pragma omp distribute parallel for if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'if' clause}}
133   for (i = 0; i < argc; ++i) foo();
134 #pragma omp target
135 #pragma omp teams
136 #pragma omp distribute parallel for if (S1) // expected-error {{'S1' does not refer to a value}}
137   for (i = 0; i < argc; ++i) foo();
138 #pragma omp target
139 #pragma omp teams
140 #pragma omp distribute parallel for if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
141   for (i = 0; i < argc; ++i) foo();
142 #pragma omp target
143 #pragma omp teams
144 #pragma omp distribute parallel for if (argc argc) // expected-error {{expected ')'}} expected-note {{to match this '('}}
145   for (i = 0; i < argc; ++i) foo();
146 #pragma omp target
147 #pragma omp teams
148 #pragma omp distribute parallel for if (1 0) // expected-error {{expected ')'}} expected-note {{to match this '('}}
149   for (i = 0; i < argc; ++i) foo();
150 #pragma omp target
151 #pragma omp teams
152 #pragma omp distribute parallel for if(if(tmain(argc, argv) // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
153   for (i = 0; i < argc; ++i) foo();
154 #pragma omp target
155 #pragma omp teams
156 #pragma omp distribute parallel for if(parallel // expected-error {{use of undeclared identifier 'parallel'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
157   for (i = 0; i < argc; ++i) foo();
158 #pragma omp target
159 #pragma omp teams
160 #pragma omp distribute parallel for if(parallel : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
161   for (i = 0; i < argc; ++i) foo();
162 #pragma omp target
163 #pragma omp teams
164 #pragma omp distribute parallel for if(parallel : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
165   for (i = 0; i < argc; ++i) foo();
166 #pragma omp target
167 #pragma omp teams
168 #pragma omp distribute parallel for if(parallel : argc-z)
169   for (i = 0; i < argc; ++i) foo();
170 #pragma omp target
171 #pragma omp teams
172 #pragma omp distribute parallel for if(parallel : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp distribute parallel for'}}
173   for (i = 0; i < argc; ++i) foo();
174 #pragma omp target
175 #pragma omp teams
176 #pragma omp distribute parallel for if(parallel : argc) if (parallel:argc) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'if' clause with 'parallel' name modifier}}
177   for (i = 0; i < argc; ++i) foo();
178 #pragma omp target
179 #pragma omp teams
180 #pragma omp distribute parallel for if(parallel : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
181   for (i = 0; i < argc; ++i) foo();
182 #pragma omp target
183 #pragma omp teams
184 #pragma omp distribute parallel for if(distribute : argc) // expected-error {{directive name modifier 'distribute' is not allowed for '#pragma omp distribute parallel for'}}
185   for (i = 0; i < argc; ++i) foo();
186 
187   return tmain(argc, argv);
188 }
189