1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -triple x86_64-unknown-unknown -fopenmp-version=45 -verify=expected,omp45 %s -Wuninitialized
2 // RUN: %clang_cc1 -fsyntax-only -fopenmp -triple x86_64-unknown-unknown -fopenmp-version=50 -verify=expected,omp5,omp50 %s -Wuninitialized
3 // RUN: %clang_cc1 -fsyntax-only -fopenmp -triple x86_64-unknown-unknown -fopenmp-version=51 -verify=expected,omp5,omp51 %s -Wuninitialized
5 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -triple x86_64-unknown-unknown -fopenmp-version=45 -verify=expected,omp45 %s -Wuninitialized
6 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -triple x86_64-unknown-unknown -fopenmp-version=50 -verify=expected,omp5,omp50 %s -Wuninitialized
7 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -triple x86_64-unknown-unknown -fopenmp-version=51 -verify=expected,omp5,omp51 %s -Wuninitialized
10 int x
; // expected-note {{initialize the variable 'x' to silence this warning}}
11 #pragma omp taskloop simd
12 for (int i
= 0; i
< 10; ++i
)
13 argc
= x
; // expected-warning {{variable 'x' is uninitialized when used here}}
16 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp taskloop simd'}}
17 #pragma omp taskloop simd
19 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp taskloop simd'}}
20 #pragma omp taskloop simd foo
22 void test_no_clause(void) {
24 #pragma omp taskloop simd
25 for (i
= 0; i
< 16; ++i
)
28 // expected-error@+2 {{statement after '#pragma omp taskloop simd' must be a for loop}}
29 #pragma omp taskloop simd
33 void test_branch_protected_scope(void) {
41 #pragma omp taskloop simd
42 for (i
= 0; i
< 16; ++i
) {
44 goto L1
; // expected-error {{use of undeclared label 'L1'}}
46 return; // expected-error {{cannot return from OpenMP region}}
56 goto L2
; // expected-error {{use of undeclared label 'L2'}}
61 void test_invalid_clause(void) {
64 // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}}
65 #pragma omp taskloop simd foo bar
66 for (i
= 0; i
< 16; ++i
)
68 // expected-error@+1 {{directive '#pragma omp taskloop simd' cannot contain more than one 'nogroup' clause}}
69 #pragma omp taskloop simd nogroup nogroup
70 for (i
= 0; i
< 16; ++i
)
74 void test_non_identifiers(void) {
78 // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}}
79 #pragma omp taskloop simd;
80 for (i
= 0; i
< 16; ++i
)
82 // expected-warning@+2 {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}}
84 #pragma omp taskloop simd linear(x);
85 for (i
= 0; i
< 16; ++i
)
89 // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}}
90 #pragma omp taskloop simd private(x);
91 for (i
= 0; i
< 16; ++i
)
95 // expected-warning@+1 {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}}
96 #pragma omp taskloop simd, private(x);
97 for (i
= 0; i
< 16; ++i
)
101 extern int foo(void);
103 void test_collapse(void) {
106 // expected-error@+1 {{expected '('}}
107 #pragma omp taskloop simd collapse
108 for (i
= 0; i
< 16; ++i
)
111 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
112 #pragma omp taskloop simd collapse(
113 for (i
= 0; i
< 16; ++i
)
116 // expected-error@+1 {{expected expression}}
117 #pragma omp taskloop simd collapse()
118 for (i
= 0; i
< 16; ++i
)
121 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
122 #pragma omp taskloop simd collapse(,
123 for (i
= 0; i
< 16; ++i
)
126 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
127 #pragma omp taskloop simd collapse(, )
128 for (i
= 0; i
< 16; ++i
)
131 // expected-warning@+2 {{extra tokens at the end of '#pragma omp taskloop simd' are ignored}}
132 // expected-error@+1 {{expected '('}}
133 #pragma omp taskloop simd collapse 4)
134 for (i
= 0; i
< 16; ++i
)
137 // expected-error@+2 {{expected ')'}}
138 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
139 #pragma omp taskloop simd collapse(4
140 for (i
= 0; i
< 16; ++i
)
141 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}}
143 // expected-error@+2 {{expected ')'}}
144 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
145 #pragma omp taskloop simd collapse(4,
146 for (i
= 0; i
< 16; ++i
)
147 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}}
149 // expected-error@+2 {{expected ')'}}
150 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
151 #pragma omp taskloop simd collapse(4, )
152 for (i
= 0; i
< 16; ++i
)
153 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}}
155 // expected-note@+1 {{as specified in 'collapse' clause}}
156 #pragma omp taskloop simd collapse(4)
157 for (i
= 0; i
< 16; ++i
)
158 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}}
160 // expected-error@+2 {{expected ')'}}
161 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
162 #pragma omp taskloop simd collapse(4 4)
163 for (i
= 0; i
< 16; ++i
)
164 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}}
166 // expected-error@+2 {{expected ')'}}
167 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
168 #pragma omp taskloop simd collapse(4, , 4)
169 for (i
= 0; i
< 16; ++i
)
170 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}}
172 #pragma omp taskloop simd collapse(4)
173 for (int i1
= 0; i1
< 16; ++i1
)
174 for (int i2
= 0; i2
< 16; ++i2
)
175 for (int i3
= 0; i3
< 16; ++i3
)
176 for (int i4
= 0; i4
< 16; ++i4
)
179 // expected-error@+2 {{expected ')'}}
180 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
181 #pragma omp taskloop simd collapse(4, 8)
182 for (i
= 0; i
< 16; ++i
)
183 ; // expected-error {{expected 4 for loops after '#pragma omp taskloop simd', but found only 1}}
185 // expected-error@+1 {{integer constant expression}}
186 #pragma omp taskloop simd collapse(2.5)
187 for (i
= 0; i
< 16; ++i
)
190 // expected-error@+1 {{integer constant expression}}
191 #pragma omp taskloop simd collapse(foo())
192 for (i
= 0; i
< 16; ++i
)
195 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
196 #pragma omp taskloop simd collapse(-5)
197 for (i
= 0; i
< 16; ++i
)
200 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
201 #pragma omp taskloop simd collapse(0)
202 for (i
= 0; i
< 16; ++i
)
205 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
206 #pragma omp taskloop simd collapse(5 - 5)
207 for (i
= 0; i
< 16; ++i
)
211 void test_private(void) {
214 // expected-error@+2 {{expected expression}}
215 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
216 #pragma omp taskloop simd private(
217 for (i
= 0; i
< 16; ++i
)
220 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
221 // expected-error@+1 2 {{expected expression}}
222 #pragma omp taskloop simd private(,
223 for (i
= 0; i
< 16; ++i
)
226 // expected-error@+1 2 {{expected expression}}
227 #pragma omp taskloop simd private(, )
228 for (i
= 0; i
< 16; ++i
)
231 // expected-error@+1 {{expected expression}}
232 #pragma omp taskloop simd private()
233 for (i
= 0; i
< 16; ++i
)
236 // expected-error@+1 {{expected expression}}
237 #pragma omp taskloop simd private(int)
238 for (i
= 0; i
< 16; ++i
)
241 // expected-error@+1 {{expected variable name}}
242 #pragma omp taskloop simd private(0)
243 for (i
= 0; i
< 16; ++i
)
248 #pragma omp taskloop simd private(x)
249 for (i
= 0; i
< 16; ++i
)
252 #pragma omp taskloop simd private(x, y)
253 for (i
= 0; i
< 16; ++i
)
256 #pragma omp taskloop simd private(x, y, z)
257 for (i
= 0; i
< 16; ++i
) {
262 void test_lastprivate(void) {
265 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
266 // expected-error@+1 {{expected expression}}
267 #pragma omp taskloop simd lastprivate(
268 for (i
= 0; i
< 16; ++i
)
272 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
273 // expected-error@+1 2 {{expected expression}}
274 #pragma omp taskloop simd lastprivate(,
275 for (i
= 0; i
< 16; ++i
)
278 // expected-error@+1 2 {{expected expression}}
279 #pragma omp taskloop simd lastprivate(, )
280 for (i
= 0; i
< 16; ++i
)
283 // expected-error@+1 {{expected expression}}
284 #pragma omp taskloop simd lastprivate()
285 for (i
= 0; i
< 16; ++i
)
288 // expected-error@+1 {{expected expression}}
289 #pragma omp taskloop simd lastprivate(int)
290 for (i
= 0; i
< 16; ++i
)
293 // expected-error@+1 {{expected variable name}}
294 #pragma omp taskloop simd lastprivate(0)
295 for (i
= 0; i
< 16; ++i
)
300 #pragma omp taskloop simd lastprivate(x)
301 for (i
= 0; i
< 16; ++i
)
304 #pragma omp taskloop simd lastprivate(x, y)
305 for (i
= 0; i
< 16; ++i
)
308 #pragma omp taskloop simd lastprivate(x, y, z)
309 for (i
= 0; i
< 16; ++i
)
313 void test_firstprivate(void) {
316 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
317 // expected-error@+1 {{expected expression}}
318 #pragma omp taskloop simd firstprivate(
319 for (i
= 0; i
< 16; ++i
)
323 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
324 // expected-error@+1 2 {{expected expression}}
325 #pragma omp taskloop simd firstprivate(,
326 for (i
= 0; i
< 16; ++i
)
329 // expected-error@+1 2 {{expected expression}}
330 #pragma omp taskloop simd firstprivate(, )
331 for (i
= 0; i
< 16; ++i
)
334 // expected-error@+1 {{expected expression}}
335 #pragma omp taskloop simd firstprivate()
336 for (i
= 0; i
< 16; ++i
)
339 // expected-error@+1 {{expected expression}}
340 #pragma omp taskloop simd firstprivate(int)
341 for (i
= 0; i
< 16; ++i
)
344 // expected-error@+1 {{expected variable name}}
345 #pragma omp taskloop simd firstprivate(0)
346 for (i
= 0; i
< 16; ++i
)
351 #pragma omp taskloop simd lastprivate(x) firstprivate(x)
352 for (i
= 0; i
< 16; ++i
)
355 #pragma omp taskloop simd lastprivate(x, y) firstprivate(x, y)
356 for (i
= 0; i
< 16; ++i
)
359 #pragma omp taskloop simd lastprivate(x, y, z) firstprivate(x, y, z)
360 for (i
= 0; i
< 16; ++i
)
362 // expected-error@+1 {{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}}
363 #pragma omp taskloop simd simdlen(64) safelen(8)
364 for (i
= 0; i
< 16; ++i
)
368 void test_loop_messages(void) {
369 float a
[100], b
[100], c
[100];
371 // expected-error@+2 {{variable must be of integer or pointer type}}
372 #pragma omp taskloop simd
373 for (float fi
= 0; fi
< 10.0; fi
++) {
374 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
377 // expected-error@+2 {{variable must be of integer or pointer type}}
378 #pragma omp taskloop simd
379 for (double fi
= 0; fi
< 10.0; fi
++) {
380 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
383 // expected-warning@+2 {{OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed}}
384 #pragma omp taskloop simd
385 for (__int128 ii
= 0; ii
< 10; ii
++) {
386 c
[ii
] = a
[ii
] + b
[ii
];
390 void test_nontemporal(void) {
392 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}} expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
393 #pragma omp taskloop simd nontemporal(
394 for (i
= 0; i
< 16; ++i
)
396 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}} expected-error@+1 2 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
397 #pragma omp taskloop simd nontemporal(,
398 for (i
= 0; i
< 16; ++i
)
400 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}} expected-error@+1 2 {{expected expression}}
401 #pragma omp taskloop simd nontemporal(, )
402 for (i
= 0; i
< 16; ++i
)
404 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}} expected-error@+1 {{expected expression}}
405 #pragma omp taskloop simd nontemporal()
406 for (i
= 0; i
< 16; ++i
)
408 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}} expected-error@+1 {{expected expression}}
409 #pragma omp taskloop simd nontemporal(int)
410 for (i
= 0; i
< 16; ++i
)
412 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}} omp5-error@+1 {{expected variable name}}
413 #pragma omp taskloop simd nontemporal(0)
414 for (i
= 0; i
< 16; ++i
)
416 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}} expected-error@+1 {{use of undeclared identifier 'x'}}
417 #pragma omp taskloop simd nontemporal(x)
418 for (i
= 0; i
< 16; ++i
)
420 // expected-error@+2 {{use of undeclared identifier 'x'}}
421 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}} expected-error@+1 {{use of undeclared identifier 'y'}}
422 #pragma omp taskloop simd nontemporal(x, y)
423 for (i
= 0; i
< 16; ++i
)
425 // expected-error@+3 {{use of undeclared identifier 'x'}}
426 // expected-error@+2 {{use of undeclared identifier 'y'}}
427 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}} expected-error@+1 {{use of undeclared identifier 'z'}}
428 #pragma omp taskloop simd nontemporal(x, y, z)
429 for (i
= 0; i
< 16; ++i
)
433 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
434 #pragma omp taskloop simd nontemporal(x :)
435 for (i
= 0; i
< 16; ++i
)
437 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}}
438 #pragma omp taskloop simd nontemporal(x :, )
439 for (i
= 0; i
< 16; ++i
)
442 // omp5-note@+2 {{defined as nontemporal}}
443 // omp45-error@+1 2 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}} omp5-error@+1 {{a variable cannot appear in more than one nontemporal clause}}
444 #pragma omp taskloop simd nontemporal(x) nontemporal(x)
445 for (i
= 0; i
< 16; ++i
)
448 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}}
449 #pragma omp taskloop simd private(x) nontemporal(x)
450 for (i
= 0; i
< 16; ++i
)
453 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}}
454 #pragma omp taskloop simd nontemporal(x) private(x)
455 for (i
= 0; i
< 16; ++i
)
458 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}}
459 #pragma omp taskloop simd nontemporal(x, y : 0)
460 for (i
= 0; i
< 16; ++i
)
463 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}}
464 #pragma omp taskloop simd nontemporal(x) lastprivate(x)
465 for (i
= 0; i
< 16; ++i
)
468 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp taskloop simd'}}
469 #pragma omp taskloop simd lastprivate(x) nontemporal(x)
470 for (i
= 0; i
< 16; ++i
)
472 #pragma omp taskloop simd order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp taskloop simd'}} expected-error {{expected '(' after 'order'}}
473 for (int i
= 0; i
< 10; ++i
)
475 #pragma omp taskloop simd order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp taskloop simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
476 for (int i
= 0; i
< 10; ++i
)
478 #pragma omp taskloop simd order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp taskloop simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
479 for (int i
= 0; i
< 10; ++i
)
481 #pragma omp taskloop simd order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp taskloop simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
482 for (int i
= 0; i
< 10; ++i
)
484 #pragma omp taskloop simd order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp taskloop simd'}}
485 for (int i
= 0; i
< 10; ++i
)
487 #pragma omp taskloop simd order(unconstrained:) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp taskloop simd'}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
488 for (int i
= 0; i
< 10; ++i
)
490 #pragma omp taskloop simd order(reproducible:concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp taskloop simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
491 for (int i
= 0; i
< 10; ++i
)
493 #pragma omp taskloop simd order(reproducible:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp taskloop simd'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
494 for (int i
= 0; i
< 10; ++i
)
496 #pragma omp taskloop simd order(unconstrained:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp taskloop simd'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
497 for (int i
= 0; i
< 10; ++i
)
499 #pragma omp taskloop simd order(concurrent) order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp taskloop simd'}} omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp taskloop simd'}} omp51-error {{directive '#pragma omp taskloop simd' cannot contain more than one 'order' clause}}
500 for (int i
= 0; i
< 10; ++i
)