Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / taskloop_simd_misc_messages.c
blobc1e667e2477644a4fc00db76b16a16fec639a214
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
9 void xxx(int argc) {
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) {
23 int i;
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
30 ++i;
33 void test_branch_protected_scope(void) {
34 int i = 0;
35 L1:
36 ++i;
38 int x[24];
40 #pragma omp parallel
41 #pragma omp taskloop simd
42 for (i = 0; i < 16; ++i) {
43 if (i == 5)
44 goto L1; // expected-error {{use of undeclared label 'L1'}}
45 else if (i == 6)
46 return; // expected-error {{cannot return from OpenMP region}}
47 else if (i == 7)
48 goto L2;
49 else if (i == 8) {
50 L2:
51 x[i]++;
55 if (x[0] == 0)
56 goto L2; // expected-error {{use of undeclared label 'L2'}}
57 else if (x[1] == 1)
58 goto L1;
61 void test_invalid_clause(void) {
62 int i;
63 #pragma omp parallel
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) {
75 int i, x;
77 #pragma omp parallel
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}}
83 #pragma omp parallel
84 #pragma omp taskloop simd linear(x);
85 for (i = 0; i < 16; ++i)
88 #pragma omp parallel
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)
94 #pragma omp parallel
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) {
104 int i;
105 #pragma omp parallel
106 // expected-error@+1 {{expected '('}}
107 #pragma omp taskloop simd collapse
108 for (i = 0; i < 16; ++i)
110 #pragma omp parallel
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)
115 #pragma omp parallel
116 // expected-error@+1 {{expected expression}}
117 #pragma omp taskloop simd collapse()
118 for (i = 0; i < 16; ++i)
120 #pragma omp parallel
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)
125 #pragma omp parallel
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)
130 #pragma omp parallel
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)
136 #pragma omp parallel
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}}
142 #pragma omp parallel
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}}
148 #pragma omp parallel
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}}
154 #pragma omp parallel
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}}
159 #pragma omp parallel
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}}
165 #pragma omp parallel
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}}
171 #pragma omp parallel
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)
177 foo();
178 #pragma omp parallel
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}}
184 #pragma omp parallel
185 // expected-error@+1 {{integer constant expression}}
186 #pragma omp taskloop simd collapse(2.5)
187 for (i = 0; i < 16; ++i)
189 #pragma omp parallel
190 // expected-error@+1 {{integer constant expression}}
191 #pragma omp taskloop simd collapse(foo())
192 for (i = 0; i < 16; ++i)
194 #pragma omp parallel
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)
199 #pragma omp parallel
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)
204 #pragma omp parallel
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) {
212 int i;
213 #pragma omp parallel
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)
219 #pragma omp parallel
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)
225 #pragma omp parallel
226 // expected-error@+1 2 {{expected expression}}
227 #pragma omp taskloop simd private(, )
228 for (i = 0; i < 16; ++i)
230 #pragma omp parallel
231 // expected-error@+1 {{expected expression}}
232 #pragma omp taskloop simd private()
233 for (i = 0; i < 16; ++i)
235 #pragma omp parallel
236 // expected-error@+1 {{expected expression}}
237 #pragma omp taskloop simd private(int)
238 for (i = 0; i < 16; ++i)
240 #pragma omp parallel
241 // expected-error@+1 {{expected variable name}}
242 #pragma omp taskloop simd private(0)
243 for (i = 0; i < 16; ++i)
246 int x, y, z;
247 #pragma omp parallel
248 #pragma omp taskloop simd private(x)
249 for (i = 0; i < 16; ++i)
251 #pragma omp parallel
252 #pragma omp taskloop simd private(x, y)
253 for (i = 0; i < 16; ++i)
255 #pragma omp parallel
256 #pragma omp taskloop simd private(x, y, z)
257 for (i = 0; i < 16; ++i) {
258 x = y * i + z;
262 void test_lastprivate(void) {
263 int i;
264 #pragma omp parallel
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)
271 #pragma omp parallel
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)
277 #pragma omp parallel
278 // expected-error@+1 2 {{expected expression}}
279 #pragma omp taskloop simd lastprivate(, )
280 for (i = 0; i < 16; ++i)
282 #pragma omp parallel
283 // expected-error@+1 {{expected expression}}
284 #pragma omp taskloop simd lastprivate()
285 for (i = 0; i < 16; ++i)
287 #pragma omp parallel
288 // expected-error@+1 {{expected expression}}
289 #pragma omp taskloop simd lastprivate(int)
290 for (i = 0; i < 16; ++i)
292 #pragma omp parallel
293 // expected-error@+1 {{expected variable name}}
294 #pragma omp taskloop simd lastprivate(0)
295 for (i = 0; i < 16; ++i)
298 int x, y, z;
299 #pragma omp parallel
300 #pragma omp taskloop simd lastprivate(x)
301 for (i = 0; i < 16; ++i)
303 #pragma omp parallel
304 #pragma omp taskloop simd lastprivate(x, y)
305 for (i = 0; i < 16; ++i)
307 #pragma omp parallel
308 #pragma omp taskloop simd lastprivate(x, y, z)
309 for (i = 0; i < 16; ++i)
313 void test_firstprivate(void) {
314 int i;
315 #pragma omp parallel
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)
322 #pragma omp parallel
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)
328 #pragma omp parallel
329 // expected-error@+1 2 {{expected expression}}
330 #pragma omp taskloop simd firstprivate(, )
331 for (i = 0; i < 16; ++i)
333 #pragma omp parallel
334 // expected-error@+1 {{expected expression}}
335 #pragma omp taskloop simd firstprivate()
336 for (i = 0; i < 16; ++i)
338 #pragma omp parallel
339 // expected-error@+1 {{expected expression}}
340 #pragma omp taskloop simd firstprivate(int)
341 for (i = 0; i < 16; ++i)
343 #pragma omp parallel
344 // expected-error@+1 {{expected variable name}}
345 #pragma omp taskloop simd firstprivate(0)
346 for (i = 0; i < 16; ++i)
349 int x, y, z;
350 #pragma omp parallel
351 #pragma omp taskloop simd lastprivate(x) firstprivate(x)
352 for (i = 0; i < 16; ++i)
354 #pragma omp parallel
355 #pragma omp taskloop simd lastprivate(x, y) firstprivate(x, y)
356 for (i = 0; i < 16; ++i)
358 #pragma omp parallel
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];
370 #pragma omp parallel
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];
376 #pragma omp parallel
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) {
391 int i;
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)
432 int x, y;
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)