Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / master_taskloop_simd_misc_messages.c
blob9cb609f0acfaac3ccaee1db2dddc12dcbd11a68a
1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -verify=expected,omp45 -triple x86_64-unknown-unknown %s -Wuninitialized
2 // RUN: %clang_cc1 -fsyntax-only -fopenmp -verify=expected,omp50 -triple x86_64-unknown-unknown %s -Wuninitialized
4 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 -verify=expected,omp45 -triple x86_64-unknown-unknown %s -Wuninitialized
5 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify=expected,omp50 -triple x86_64-unknown-unknown %s -Wuninitialized
7 void xxx(int argc) {
8 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
9 #pragma omp master taskloop simd
10 for (int i = 0; i < 10; ++i)
11 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
14 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp master taskloop simd'}}
15 #pragma omp master taskloop simd
17 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp master taskloop simd'}}
18 #pragma omp master taskloop simd foo
20 void test_no_clause(void) {
21 int i;
22 #pragma omp master taskloop simd
23 for (i = 0; i < 16; ++i)
26 // expected-error@+2 {{statement after '#pragma omp master taskloop simd' must be a for loop}}
27 #pragma omp master taskloop simd
28 ++i;
31 void test_branch_protected_scope(void) {
32 int i = 0;
33 L1:
34 ++i;
36 int x[24];
38 #pragma omp parallel
39 #pragma omp master taskloop simd
40 for (i = 0; i < 16; ++i) {
41 if (i == 5)
42 goto L1; // expected-error {{use of undeclared label 'L1'}}
43 else if (i == 6)
44 return; // expected-error {{cannot return from OpenMP region}}
45 else if (i == 7)
46 goto L2;
47 else if (i == 8) {
48 L2:
49 x[i]++;
53 if (x[0] == 0)
54 goto L2; // expected-error {{use of undeclared label 'L2'}}
55 else if (x[1] == 1)
56 goto L1;
59 void test_invalid_clause(void) {
60 int i;
61 #pragma omp parallel
62 // expected-warning@+1 {{extra tokens at the end of '#pragma omp master taskloop simd' are ignored}}
63 #pragma omp master taskloop simd foo bar
64 for (i = 0; i < 16; ++i)
66 // expected-error@+1 {{directive '#pragma omp master taskloop simd' cannot contain more than one 'nogroup' clause}}
67 #pragma omp master taskloop simd nogroup nogroup
68 for (i = 0; i < 16; ++i)
72 void test_non_identifiers(void) {
73 int i, x;
75 #pragma omp parallel
76 // expected-warning@+1 {{extra tokens at the end of '#pragma omp master taskloop simd' are ignored}}
77 #pragma omp master taskloop simd;
78 for (i = 0; i < 16; ++i)
80 // expected-warning@+2 {{extra tokens at the end of '#pragma omp master taskloop simd' are ignored}}
81 #pragma omp parallel
82 #pragma omp master taskloop simd linear(x);
83 for (i = 0; i < 16; ++i)
86 #pragma omp parallel
87 // expected-warning@+1 {{extra tokens at the end of '#pragma omp master taskloop simd' are ignored}}
88 #pragma omp master taskloop simd private(x);
89 for (i = 0; i < 16; ++i)
92 #pragma omp parallel
93 // expected-warning@+1 {{extra tokens at the end of '#pragma omp master taskloop simd' are ignored}}
94 #pragma omp master taskloop simd, private(x);
95 for (i = 0; i < 16; ++i)
99 extern int foo(void);
101 void test_collapse(void) {
102 int i;
103 #pragma omp parallel
104 // expected-error@+1 {{expected '('}}
105 #pragma omp master taskloop simd collapse
106 for (i = 0; i < 16; ++i)
108 #pragma omp parallel
109 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
110 #pragma omp master taskloop simd collapse(
111 for (i = 0; i < 16; ++i)
113 #pragma omp parallel
114 // expected-error@+1 {{expected expression}}
115 #pragma omp master taskloop simd collapse()
116 for (i = 0; i < 16; ++i)
118 #pragma omp parallel
119 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
120 #pragma omp master taskloop simd collapse(,
121 for (i = 0; i < 16; ++i)
123 #pragma omp parallel
124 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
125 #pragma omp master taskloop simd collapse(, )
126 for (i = 0; i < 16; ++i)
128 #pragma omp parallel
129 // expected-warning@+2 {{extra tokens at the end of '#pragma omp master taskloop simd' are ignored}}
130 // expected-error@+1 {{expected '('}}
131 #pragma omp master taskloop simd collapse 4)
132 for (i = 0; i < 16; ++i)
134 #pragma omp parallel
135 // expected-error@+2 {{expected ')'}}
136 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
137 #pragma omp master taskloop simd collapse(4
138 for (i = 0; i < 16; ++i)
139 ; // expected-error {{expected 4 for loops after '#pragma omp master taskloop simd', but found only 1}}
140 #pragma omp parallel
141 // expected-error@+2 {{expected ')'}}
142 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
143 #pragma omp master taskloop simd collapse(4,
144 for (i = 0; i < 16; ++i)
145 ; // expected-error {{expected 4 for loops after '#pragma omp master taskloop simd', but found only 1}}
146 #pragma omp parallel
147 // expected-error@+2 {{expected ')'}}
148 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
149 #pragma omp master taskloop simd collapse(4, )
150 for (i = 0; i < 16; ++i)
151 ; // expected-error {{expected 4 for loops after '#pragma omp master taskloop simd', but found only 1}}
152 #pragma omp parallel
153 // expected-note@+1 {{as specified in 'collapse' clause}}
154 #pragma omp master taskloop simd collapse(4)
155 for (i = 0; i < 16; ++i)
156 ; // expected-error {{expected 4 for loops after '#pragma omp master taskloop simd', but found only 1}}
157 #pragma omp parallel
158 // expected-error@+2 {{expected ')'}}
159 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
160 #pragma omp master taskloop simd collapse(4 4)
161 for (i = 0; i < 16; ++i)
162 ; // expected-error {{expected 4 for loops after '#pragma omp master taskloop simd', but found only 1}}
163 #pragma omp parallel
164 // expected-error@+2 {{expected ')'}}
165 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
166 #pragma omp master taskloop simd collapse(4, , 4)
167 for (i = 0; i < 16; ++i)
168 ; // expected-error {{expected 4 for loops after '#pragma omp master taskloop simd', but found only 1}}
169 #pragma omp parallel
170 #pragma omp master taskloop simd collapse(4)
171 for (int i1 = 0; i1 < 16; ++i1)
172 for (int i2 = 0; i2 < 16; ++i2)
173 for (int i3 = 0; i3 < 16; ++i3)
174 for (int i4 = 0; i4 < 16; ++i4)
175 foo();
176 #pragma omp parallel
177 // expected-error@+2 {{expected ')'}}
178 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
179 #pragma omp master taskloop simd collapse(4, 8)
180 for (i = 0; i < 16; ++i)
181 ; // expected-error {{expected 4 for loops after '#pragma omp master taskloop simd', but found only 1}}
182 #pragma omp parallel
183 // expected-error@+1 {{integer constant expression}}
184 #pragma omp master taskloop simd collapse(2.5)
185 for (i = 0; i < 16; ++i)
187 #pragma omp parallel
188 // expected-error@+1 {{integer constant expression}}
189 #pragma omp master taskloop simd collapse(foo())
190 for (i = 0; i < 16; ++i)
192 #pragma omp parallel
193 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
194 #pragma omp master taskloop simd collapse(-5)
195 for (i = 0; i < 16; ++i)
197 #pragma omp parallel
198 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
199 #pragma omp master taskloop simd collapse(0)
200 for (i = 0; i < 16; ++i)
202 #pragma omp parallel
203 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
204 #pragma omp master taskloop simd collapse(5 - 5)
205 for (i = 0; i < 16; ++i)
209 void test_private(void) {
210 int i;
211 #pragma omp parallel
212 // expected-error@+2 {{expected expression}}
213 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
214 #pragma omp master taskloop simd private(
215 for (i = 0; i < 16; ++i)
217 #pragma omp parallel
218 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
219 // expected-error@+1 2 {{expected expression}}
220 #pragma omp master taskloop simd private(,
221 for (i = 0; i < 16; ++i)
223 #pragma omp parallel
224 // expected-error@+1 2 {{expected expression}}
225 #pragma omp master taskloop simd private(, )
226 for (i = 0; i < 16; ++i)
228 #pragma omp parallel
229 // expected-error@+1 {{expected expression}}
230 #pragma omp master taskloop simd private()
231 for (i = 0; i < 16; ++i)
233 #pragma omp parallel
234 // expected-error@+1 {{expected expression}}
235 #pragma omp master taskloop simd private(int)
236 for (i = 0; i < 16; ++i)
238 #pragma omp parallel
239 // expected-error@+1 {{expected variable name}}
240 #pragma omp master taskloop simd private(0)
241 for (i = 0; i < 16; ++i)
244 int x, y, z;
245 #pragma omp parallel
246 #pragma omp master taskloop simd private(x)
247 for (i = 0; i < 16; ++i)
249 #pragma omp parallel
250 #pragma omp master taskloop simd private(x, y)
251 for (i = 0; i < 16; ++i)
253 #pragma omp parallel
254 #pragma omp master taskloop simd private(x, y, z)
255 for (i = 0; i < 16; ++i) {
256 x = y * i + z;
260 void test_lastprivate(void) {
261 int i;
262 #pragma omp parallel
263 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
264 // expected-error@+1 {{expected expression}}
265 #pragma omp master taskloop simd lastprivate(
266 for (i = 0; i < 16; ++i)
269 #pragma omp parallel
270 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
271 // expected-error@+1 2 {{expected expression}}
272 #pragma omp master taskloop simd lastprivate(,
273 for (i = 0; i < 16; ++i)
275 #pragma omp parallel
276 // expected-error@+1 2 {{expected expression}}
277 #pragma omp master taskloop simd lastprivate(, )
278 for (i = 0; i < 16; ++i)
280 #pragma omp parallel
281 // expected-error@+1 {{expected expression}}
282 #pragma omp master taskloop simd lastprivate()
283 for (i = 0; i < 16; ++i)
285 #pragma omp parallel
286 // expected-error@+1 {{expected expression}}
287 #pragma omp master taskloop simd lastprivate(int)
288 for (i = 0; i < 16; ++i)
290 #pragma omp parallel
291 // expected-error@+1 {{expected variable name}}
292 #pragma omp master taskloop simd lastprivate(0)
293 for (i = 0; i < 16; ++i)
296 int x, y, z;
297 #pragma omp parallel
298 #pragma omp master taskloop simd lastprivate(x)
299 for (i = 0; i < 16; ++i)
301 #pragma omp parallel
302 #pragma omp master taskloop simd lastprivate(x, y)
303 for (i = 0; i < 16; ++i)
305 #pragma omp parallel
306 #pragma omp master taskloop simd lastprivate(x, y, z)
307 for (i = 0; i < 16; ++i)
311 void test_firstprivate(void) {
312 int i;
313 #pragma omp parallel
314 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
315 // expected-error@+1 {{expected expression}}
316 #pragma omp master taskloop simd firstprivate(
317 for (i = 0; i < 16; ++i)
320 #pragma omp parallel
321 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
322 // expected-error@+1 2 {{expected expression}}
323 #pragma omp master taskloop simd firstprivate(,
324 for (i = 0; i < 16; ++i)
326 #pragma omp parallel
327 // expected-error@+1 2 {{expected expression}}
328 #pragma omp master taskloop simd firstprivate(, )
329 for (i = 0; i < 16; ++i)
331 #pragma omp parallel
332 // expected-error@+1 {{expected expression}}
333 #pragma omp master taskloop simd firstprivate()
334 for (i = 0; i < 16; ++i)
336 #pragma omp parallel
337 // expected-error@+1 {{expected expression}}
338 #pragma omp master taskloop simd firstprivate(int)
339 for (i = 0; i < 16; ++i)
341 #pragma omp parallel
342 // expected-error@+1 {{expected variable name}}
343 #pragma omp master taskloop simd firstprivate(0)
344 for (i = 0; i < 16; ++i)
347 int x, y, z;
348 #pragma omp parallel
349 #pragma omp master taskloop simd lastprivate(x) firstprivate(x)
350 for (i = 0; i < 16; ++i)
352 #pragma omp parallel
353 #pragma omp master taskloop simd lastprivate(x, y) firstprivate(x, y)
354 for (i = 0; i < 16; ++i)
356 #pragma omp parallel
357 #pragma omp master taskloop simd lastprivate(x, y, z) firstprivate(x, y, z)
358 for (i = 0; i < 16; ++i)
360 // expected-error@+1 {{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}}
361 #pragma omp master taskloop simd simdlen(64) safelen(8)
362 for (i = 0; i < 16; ++i)
366 void test_loop_messages(void) {
367 float a[100], b[100], c[100];
368 #pragma omp parallel
369 // expected-error@+2 {{variable must be of integer or pointer type}}
370 #pragma omp master taskloop simd
371 for (float fi = 0; fi < 10.0; fi++) {
372 c[(int)fi] = a[(int)fi] + b[(int)fi];
374 #pragma omp parallel
375 // expected-error@+2 {{variable must be of integer or pointer type}}
376 #pragma omp master taskloop simd
377 for (double fi = 0; fi < 10.0; fi++) {
378 c[(int)fi] = a[(int)fi] + b[(int)fi];
381 // expected-warning@+2 {{OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed}}
382 #pragma omp master taskloop simd
383 for (__int128 ii = 0; ii < 10; ii++) {
384 c[ii] = a[ii] + b[ii];
388 void test_nontemporal(void) {
389 int i;
390 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}} expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
391 #pragma omp master taskloop simd nontemporal(
392 for (i = 0; i < 16; ++i)
394 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}} expected-error@+1 2 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
395 #pragma omp master taskloop simd nontemporal(,
396 for (i = 0; i < 16; ++i)
398 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}} expected-error@+1 2 {{expected expression}}
399 #pragma omp master taskloop simd nontemporal(, )
400 for (i = 0; i < 16; ++i)
402 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}} expected-error@+1 {{expected expression}}
403 #pragma omp master taskloop simd nontemporal()
404 for (i = 0; i < 16; ++i)
406 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}} expected-error@+1 {{expected expression}}
407 #pragma omp master taskloop simd nontemporal(int)
408 for (i = 0; i < 16; ++i)
410 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}} omp50-error@+1 {{expected variable name}}
411 #pragma omp master taskloop simd nontemporal(0)
412 for (i = 0; i < 16; ++i)
414 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}} expected-error@+1 {{use of undeclared identifier 'x'}}
415 #pragma omp master taskloop simd nontemporal(x)
416 for (i = 0; i < 16; ++i)
418 // expected-error@+2 {{use of undeclared identifier 'x'}}
419 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}} expected-error@+1 {{use of undeclared identifier 'y'}}
420 #pragma omp master taskloop simd nontemporal(x, y)
421 for (i = 0; i < 16; ++i)
423 // expected-error@+3 {{use of undeclared identifier 'x'}}
424 // expected-error@+2 {{use of undeclared identifier 'y'}}
425 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}} expected-error@+1 {{use of undeclared identifier 'z'}}
426 #pragma omp master taskloop simd nontemporal(x, y, z)
427 for (i = 0; i < 16; ++i)
430 int x, y;
431 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
432 #pragma omp master taskloop simd nontemporal(x :)
433 for (i = 0; i < 16; ++i)
435 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}}
436 #pragma omp master taskloop simd nontemporal(x :, )
437 for (i = 0; i < 16; ++i)
440 // omp50-note@+2 {{defined as nontemporal}}
441 // omp45-error@+1 2 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}} omp50-error@+1 {{a variable cannot appear in more than one nontemporal clause}}
442 #pragma omp master taskloop simd nontemporal(x) nontemporal(x)
443 for (i = 0; i < 16; ++i)
446 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}}
447 #pragma omp master taskloop simd private(x) nontemporal(x)
448 for (i = 0; i < 16; ++i)
451 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}}
452 #pragma omp master taskloop simd nontemporal(x) private(x)
453 for (i = 0; i < 16; ++i)
456 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}}
457 #pragma omp master taskloop simd nontemporal(x, y : 0)
458 for (i = 0; i < 16; ++i)
461 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}}
462 #pragma omp master taskloop simd nontemporal(x) lastprivate(x)
463 for (i = 0; i < 16; ++i)
466 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp master taskloop simd'}}
467 #pragma omp master taskloop simd lastprivate(x) nontemporal(x)
468 for (i = 0; i < 16; ++i)