• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++98 -o - %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
4 
5 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -o - %s -Wuninitialized
6 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++98 -o - %s -Wuninitialized
7 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
8 
xxx(int argc)9 void xxx(int argc) {
10   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
11 #pragma omp for ordered
12   for (int i = 0; i < 10; ++i) {
13 #pragma omp ordered
14     argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
15   }
16 }
17 
18 int foo();
19 #if __cplusplus >= 201103L
20 // expected-note@-2 {{declared here}}
21 #endif
22 
23 template <class T>
foo()24 T foo() {
25  T k;
26   #pragma omp for ordered
27   for (int i = 0; i < 10; ++i) {
28     L1:
29       foo();
30     #pragma omp ordered
31     {
32       foo();
33       goto L1; // expected-error {{use of undeclared label 'L1'}}
34     }
35   }
36   #pragma omp for ordered
37   for (int i = 0; i < 10; ++i) {
38     foo();
39     goto L2; // expected-error {{use of undeclared label 'L2'}}
40     #pragma omp ordered
41     {
42       L2:
43       foo();
44     }
45   }
46   #pragma omp for ordered
47   for (int i = 0; i < 10; ++i) {
48     #pragma omp ordered threads threads // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'threads' clause}}
49     {
50       foo();
51     }
52   }
53   #pragma omp for ordered(1) // expected-note {{'ordered' clause with specified parameter}}
54   for (int i = 0; i < 10; ++i) {
55     #pragma omp ordered // expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
56     {
57       foo();
58     }
59   }
60   #pragma omp for ordered(1) // expected-note {{'ordered' clause with specified parameter}}
61   for (int i = 0; i < 10; ++i) {
62     #pragma omp ordered threads // expected-error {{'ordered' directive with 'threads' clause cannot be closely nested inside ordered region with specified parameter}}
63     {
64       foo();
65     }
66   }
67   #pragma omp for ordered
68   for (int i = 0; i < 10; ++i) {
69     #pragma omp ordered // expected-note {{previous 'ordered' directive used here}}
70     {
71       foo();
72     }
73     #pragma omp ordered // expected-error {{exactly one 'ordered' directive must appear in the loop body of an enclosing directive}}
74     {
75       foo();
76     }
77   }
78   #pragma omp ordered simd simd // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'simd' clause}}
79   {
80     foo();
81   }
82   #pragma omp simd
83   for (int i = 0; i < 10; ++i) {
84     #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
85     {
86       foo();
87     }
88   }
89   #pragma omp simd
90   for (int i = 0; i < 10; ++i) {
91     #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
92     {
93       foo();
94     }
95   }
96   #pragma omp simd
97   for (int i = 0; i < 10; ++i) {
98 #pragma omp ordered simd // expected-note {{previous 'ordered' directive used here}}
99     {
100       foo();
101     }
102 #pragma omp ordered simd // expected-error {{exactly one 'ordered' directive must appear in the loop body of an enclosing directive}}
103     {
104       foo();
105     }
106   }
107 #pragma omp for simd
108   for (int i = 0; i < 10; ++i) {
109     #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
110     {
111       foo();
112     }
113   }
114   #pragma omp for simd
115   for (int i = 0; i < 10; ++i) {
116     #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
117     {
118       foo();
119     }
120   }
121   #pragma omp parallel for simd
122   for (int i = 0; i < 10; ++i) {
123     #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
124     {
125       foo();
126     }
127   }
128   #pragma omp parallel for simd
129   for (int i = 0; i < 10; ++i) {
130     #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
131     {
132       foo();
133     }
134     #pragma omp ordered depend(source) // expected-error {{OpenMP constructs may not be nested inside a simd region}}
135   }
136 #pragma omp parallel for ordered
137   for (int i = 0; i < 10; ++i) {
138     #pragma omp ordered depend(source) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
139     #pragma omp ordered depend(sink : i) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
140   }
141 #pragma omp parallel for ordered(2) // expected-note 3 {{'ordered' clause with specified parameter}}
142   for (int i = 0; i < 10; ++i) {
143     for (int j = 0; j < 10; ++j) {
144 #pragma omp ordered depend // expected-error {{expected '(' after 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
145 #pragma omp ordered depend( // expected-error {{expected ')'}} expected-error {{expected 'source' or 'sink' in OpenMP clause 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}} expected-warning {{missing ':' or ')' after dependency type - ignoring}} expected-note {{to match this '('}}
146 #pragma omp ordered depend(source // expected-error {{expected ')'}} expected-note {{to match this '('}}
147 #pragma omp ordered depend(sink // expected-error {{expected expression}} expected-warning {{missing ':' or ')' after dependency type - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'i' loop iteration variable}}
148 #pragma omp ordered depend(sink : // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-error {{expected 'i' loop iteration variable}}
149 #pragma omp ordered depend(sink : i // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'j' loop iteration variable}}
150 #pragma omp ordered depend(sink : i) // expected-error {{expected 'j' loop iteration variable}}
151 #pragma omp ordered depend(source)
152                            if (i == j)
153 #pragma omp ordered depend(source) // expected-error {{'#pragma omp ordered' with 'depend' clause cannot be an immediate substatement}}
154                              ;
155                            if (i == j)
156 #pragma omp ordered depend(sink : i, j) // expected-error {{'#pragma omp ordered' with 'depend' clause cannot be an immediate substatement}}
157                              ;
158 #pragma omp ordered depend(source) threads // expected-error {{'depend' clauses cannot be mixed with 'threads' clause}}
159 #pragma omp ordered simd depend(source) // expected-error {{'depend' clauses cannot be mixed with 'simd' clause}}
160 #pragma omp ordered depend(source) depend(source) // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'depend' clause with 'source' dependence}}
161 #pragma omp ordered depend(in : i) // expected-error {{expected 'source' or 'sink' in OpenMP clause 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
162 #pragma omp ordered depend(sink : i, j)
163 #pragma omp ordered depend(sink : j, i) // expected-error {{expected 'i' loop iteration variable}} expected-error {{expected 'j' loop iteration variable}}
164 #pragma omp ordered depend(sink : i, j, k) // expected-error {{unexpected expression: number of expressions is larger than the number of associated loops}}
165 #pragma omp ordered depend(sink : i+foo(), j/4) // expected-error {{integral constant expression}} expected-error {{expected '+' or '-' operation}}
166 #if __cplusplus >= 201103L
167 // expected-note@-2 {{non-constexpr function 'foo' cannot be used in a constant expression}}
168 #endif
169 #pragma omp ordered depend(sink : i*0, j-4)// expected-error {{expected '+' or '-' operation}}
170 #pragma omp ordered depend(sink : i-0, j+sizeof(T)) depend(sink : i-0, j+sizeof(T))
171 #pragma omp ordered depend(sink : i-0, j+sizeof(T)) depend(source) // expected-error {{'depend(source)' clause cannot be mixed with 'depend(sink:vec)' clauses}}
172 #pragma omp ordered depend(source) depend(sink : i-0, j+sizeof(T)) // expected-error {{'depend(sink:vec)' clauses cannot be mixed with 'depend(source)' clause}}
173     }
174   }
175 #pragma omp ordered depend(source) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
176 #pragma omp ordered depend(sink:k) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
177   return T();
178 }
179 
foo()180 int foo() {
181 #if __cplusplus >= 201103L
182 // expected-note@-2 {{declared here}}
183 #endif
184 int k;
185   #pragma omp for ordered
186   for (int i = 0; i < 10; ++i) {
187     L1:
188       foo();
189     #pragma omp ordered
190     {
191       foo();
192       goto L1; // expected-error {{use of undeclared label 'L1'}}
193     }
194   }
195   #pragma omp for ordered
196   for (int i = 0; i < 10; ++i) {
197     foo();
198     goto L2; // expected-error {{use of undeclared label 'L2'}}
199     #pragma omp ordered
200     {
201       L2:
202       foo();
203     }
204   }
205   #pragma omp for ordered
206   for (int i = 0; i < 10; ++i) {
207     #pragma omp ordered threads threads // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'threads' clause}}
208     {
209       foo();
210     }
211   }
212   #pragma omp for ordered(1) // expected-note {{'ordered' clause with specified parameter}}
213   for (int i = 0; i < 10; ++i) {
214     #pragma omp ordered // expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
215     {
216       foo();
217     }
218   }
219   #pragma omp for ordered(1) // expected-note {{'ordered' clause with specified parameter}}
220   for (int i = 0; i < 10; ++i) {
221     #pragma omp ordered threads // expected-error {{'ordered' directive with 'threads' clause cannot be closely nested inside ordered region with specified parameter}}
222     {
223       foo();
224     }
225   }
226   #pragma omp ordered simd simd // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'simd' clause}}
227   {
228     foo();
229   }
230   #pragma omp simd
231   for (int i = 0; i < 10; ++i) {
232     #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
233     {
234       foo();
235     }
236   }
237   #pragma omp simd
238   for (int i = 0; i < 10; ++i) {
239     #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
240     {
241       foo();
242     }
243   }
244   #pragma omp for simd
245   for (int i = 0; i < 10; ++i) {
246     #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
247     {
248       foo();
249     }
250   }
251   #pragma omp for simd
252   for (int i = 0; i < 10; ++i) {
253     #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
254     {
255       foo();
256     }
257   }
258   #pragma omp parallel for simd
259   for (int i = 0; i < 10; ++i) {
260     #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
261     {
262       foo();
263     }
264   }
265   #pragma omp parallel for simd
266   for (int i = 0; i < 10; ++i) {
267     #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
268     {
269       foo();
270     }
271     #pragma omp ordered depend(source) // expected-error {{OpenMP constructs may not be nested inside a simd region}}
272   }
273 #pragma omp parallel for ordered
274   for (int i = 0; i < 10; ++i) {
275     #pragma omp ordered depend(source) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
276     #pragma omp ordered depend(sink : i) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
277   }
278 #pragma omp parallel for ordered(2) // expected-note 3 {{'ordered' clause with specified parameter}}
279   for (int i = 0; i < 10; ++i) {
280     for (int j = 0; j < 10; ++j) {
281 #pragma omp ordered depend // expected-error {{expected '(' after 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
282 #pragma omp ordered depend( // expected-error {{expected ')'}} expected-error {{expected 'source' or 'sink' in OpenMP clause 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}} expected-warning {{missing ':' or ')' after dependency type - ignoring}} expected-note {{to match this '('}}
283 #pragma omp ordered depend(source // expected-error {{expected ')'}} expected-note {{to match this '('}}
284 #pragma omp ordered depend(sink // expected-error {{expected expression}} expected-warning {{missing ':' or ')' after dependency type - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'i' loop iteration variable}}
285 #pragma omp ordered depend(sink : // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-error {{expected 'i' loop iteration variable}}
286 #pragma omp ordered depend(sink : i // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'j' loop iteration variable}}
287 #pragma omp ordered depend(sink : i) // expected-error {{expected 'j' loop iteration variable}}
288 #pragma omp ordered depend(source)
289                            if (i == j)
290 #pragma omp ordered depend(source) // expected-error {{'#pragma omp ordered' with 'depend' clause cannot be an immediate substatement}}
291                              ;
292                            if (i == j)
293 #pragma omp ordered depend(sink : i, j) // expected-error {{'#pragma omp ordered' with 'depend' clause cannot be an immediate substatement}}
294                              ;
295 #pragma omp ordered depend(source) threads // expected-error {{'depend' clauses cannot be mixed with 'threads' clause}}
296 #pragma omp ordered simd depend(source) // expected-error {{'depend' clauses cannot be mixed with 'simd' clause}}
297 #pragma omp ordered depend(source) depend(source) // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'depend' clause with 'source' dependence}}
298 #pragma omp ordered depend(in : i) // expected-error {{expected 'source' or 'sink' in OpenMP clause 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
299 #pragma omp ordered depend(sink : i, j) allocate(i) // expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp ordered'}}
300 #pragma omp ordered depend(sink : j, i) // expected-error {{expected 'i' loop iteration variable}} expected-error {{expected 'j' loop iteration variable}}
301 #pragma omp ordered depend(sink : i, j, k) // expected-error {{unexpected expression: number of expressions is larger than the number of associated loops}}
302 #pragma omp ordered depend(sink : i+foo(), j/4) // expected-error {{integral constant expression}} expected-error {{expected '+' or '-' operation}}
303 #if __cplusplus >= 201103L
304 // expected-note@-2 {{non-constexpr function 'foo' cannot be used in a constant expression}}
305 #endif
306 #pragma omp ordered depend(sink : i*0, j-4)// expected-error {{expected '+' or '-' operation}}
307 #pragma omp ordered depend(sink : i-0, j+sizeof(int)) depend(sink : i-0, j+sizeof(int))
308 #pragma omp ordered depend(sink : i-0, j+sizeof(int)) depend(source) // expected-error {{'depend(source)' clause cannot be mixed with 'depend(sink:vec)' clauses}}
309 #pragma omp ordered depend(source) depend(sink : i-0, j+sizeof(int)) // expected-error {{'depend(sink:vec)' clauses cannot be mixed with 'depend(source)' clause}}
310     }
311   }
312 
313 #pragma omp for ordered(2) // expected-note {{as specified in 'ordered' clause}}
314   for (int i = 0; i < 10; ++i) { // expected-error {{expected 2 for loops after '#pragma omp for', but found only 1}}
315 #pragma omp ordered depend(sink : i)
316     int j;
317 #pragma omp ordered depend(sink : i, j) // expected-error {{expected loop iteration variable}}
318     foo();
319   }
320 
321   return foo<int>(); // expected-note {{in instantiation of function template specialization 'foo<int>' requested here}}
322 }
323