Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / parallel_master_taskloop_simd_misc_messages.c
blobeb9131d17a740c77b5c039d81c5e27024efad2c7
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,omp51 -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,omp51 -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 parallel 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 parallel master taskloop simd'}}
15 #pragma omp parallel master taskloop simd
17 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel master taskloop simd'}}
18 #pragma omp parallel master taskloop simd foo
20 void test_no_clause(void) {
21 int i;
22 #pragma omp parallel master taskloop simd
23 for (i = 0; i < 16; ++i)
26 // expected-error@+2 {{statement after '#pragma omp parallel master taskloop simd' must be a for loop}}
27 #pragma omp parallel 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 parallel 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, a;
61 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}
62 #pragma omp parallel master taskloop simd foo bar
63 for (i = 0; i < 16; ++i)
65 // expected-error@+1 {{directive '#pragma omp parallel master taskloop simd' cannot contain more than one 'nogroup' clause}}
66 #pragma omp parallel master taskloop simd nogroup nogroup
67 for (i = 0; i < 16; ++i)
69 // expected-error@+1 {{unexpected OpenMP clause 'in_reduction' in directive '#pragma omp parallel master taskloop simd'}}
70 #pragma omp parallel master taskloop simd in_reduction(+:a)
71 for (i = 0; i < 16; ++i)
75 void test_non_identifiers(void) {
76 int i, x;
78 #pragma omp parallel
79 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}
80 #pragma omp parallel master taskloop simd;
81 for (i = 0; i < 16; ++i)
83 // expected-warning@+2 {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}
84 #pragma omp parallel
85 #pragma omp parallel master taskloop simd linear(x);
86 for (i = 0; i < 16; ++i)
89 #pragma omp parallel
90 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}
91 #pragma omp parallel master taskloop simd private(x);
92 for (i = 0; i < 16; ++i)
95 #pragma omp parallel
96 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}
97 #pragma omp parallel master taskloop simd, private(x);
98 for (i = 0; i < 16; ++i)
102 extern int foo(void);
104 void test_collapse(void) {
105 int i;
106 #pragma omp parallel
107 // expected-error@+1 {{expected '('}}
108 #pragma omp parallel master taskloop simd collapse
109 for (i = 0; i < 16; ++i)
111 #pragma omp parallel
112 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
113 #pragma omp parallel master taskloop simd collapse(
114 for (i = 0; i < 16; ++i)
116 #pragma omp parallel
117 // expected-error@+1 {{expected expression}}
118 #pragma omp parallel master taskloop simd collapse()
119 for (i = 0; i < 16; ++i)
121 #pragma omp parallel
122 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
123 #pragma omp parallel master taskloop simd collapse(,
124 for (i = 0; i < 16; ++i)
126 #pragma omp parallel
127 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
128 #pragma omp parallel master taskloop simd collapse(, )
129 for (i = 0; i < 16; ++i)
131 #pragma omp parallel
132 // expected-warning@+2 {{extra tokens at the end of '#pragma omp parallel master taskloop simd' are ignored}}
133 // expected-error@+1 {{expected '('}}
134 #pragma omp parallel master taskloop simd collapse 4)
135 for (i = 0; i < 16; ++i)
137 #pragma omp parallel
138 // expected-error@+2 {{expected ')'}}
139 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
140 #pragma omp parallel master taskloop simd collapse(4
141 for (i = 0; i < 16; ++i)
142 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}
143 #pragma omp parallel
144 // expected-error@+2 {{expected ')'}}
145 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
146 #pragma omp parallel master taskloop simd collapse(4,
147 for (i = 0; i < 16; ++i)
148 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}
149 #pragma omp parallel
150 // expected-error@+2 {{expected ')'}}
151 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
152 #pragma omp parallel master taskloop simd collapse(4, )
153 for (i = 0; i < 16; ++i)
154 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}
155 #pragma omp parallel
156 // expected-note@+1 {{as specified in 'collapse' clause}}
157 #pragma omp parallel master taskloop simd collapse(4)
158 for (i = 0; i < 16; ++i)
159 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}
160 #pragma omp parallel
161 // expected-error@+2 {{expected ')'}}
162 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
163 #pragma omp parallel master taskloop simd collapse(4 4)
164 for (i = 0; i < 16; ++i)
165 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}
166 #pragma omp parallel
167 // expected-error@+2 {{expected ')'}}
168 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
169 #pragma omp parallel master taskloop simd collapse(4, , 4)
170 for (i = 0; i < 16; ++i)
171 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}
172 #pragma omp parallel
173 #pragma omp parallel master taskloop simd collapse(4)
174 for (int i1 = 0; i1 < 16; ++i1)
175 for (int i2 = 0; i2 < 16; ++i2)
176 for (int i3 = 0; i3 < 16; ++i3)
177 for (int i4 = 0; i4 < 16; ++i4)
178 foo();
179 #pragma omp parallel
180 // expected-error@+2 {{expected ')'}}
181 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
182 #pragma omp parallel master taskloop simd collapse(4, 8)
183 for (i = 0; i < 16; ++i)
184 ; // expected-error {{expected 4 for loops after '#pragma omp parallel master taskloop simd', but found only 1}}
185 #pragma omp parallel
186 // expected-error@+1 {{integer constant expression}}
187 #pragma omp parallel master taskloop simd collapse(2.5)
188 for (i = 0; i < 16; ++i)
190 #pragma omp parallel
191 // expected-error@+1 {{integer constant expression}}
192 #pragma omp parallel master taskloop simd collapse(foo())
193 for (i = 0; i < 16; ++i)
195 #pragma omp parallel
196 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
197 #pragma omp parallel master taskloop simd collapse(-5)
198 for (i = 0; i < 16; ++i)
200 #pragma omp parallel
201 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
202 #pragma omp parallel master taskloop simd collapse(0)
203 for (i = 0; i < 16; ++i)
205 #pragma omp parallel
206 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
207 #pragma omp parallel master taskloop simd collapse(5 - 5)
208 for (i = 0; i < 16; ++i)
212 void test_private(void) {
213 int i;
214 #pragma omp parallel
215 // expected-error@+2 {{expected expression}}
216 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
217 #pragma omp parallel master taskloop simd private(
218 for (i = 0; i < 16; ++i)
220 #pragma omp parallel
221 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
222 // expected-error@+1 2 {{expected expression}}
223 #pragma omp parallel master taskloop simd private(,
224 for (i = 0; i < 16; ++i)
226 #pragma omp parallel
227 // expected-error@+1 2 {{expected expression}}
228 #pragma omp parallel master taskloop simd private(, )
229 for (i = 0; i < 16; ++i)
231 #pragma omp parallel
232 // expected-error@+1 {{expected expression}}
233 #pragma omp parallel master taskloop simd private()
234 for (i = 0; i < 16; ++i)
236 #pragma omp parallel
237 // expected-error@+1 {{expected expression}}
238 #pragma omp parallel master taskloop simd private(int)
239 for (i = 0; i < 16; ++i)
241 #pragma omp parallel
242 // expected-error@+1 {{expected variable name}}
243 #pragma omp parallel master taskloop simd private(0)
244 for (i = 0; i < 16; ++i)
247 int x, y, z;
248 #pragma omp parallel
249 #pragma omp parallel master taskloop simd private(x)
250 for (i = 0; i < 16; ++i)
252 #pragma omp parallel
253 #pragma omp parallel master taskloop simd private(x, y)
254 for (i = 0; i < 16; ++i)
256 #pragma omp parallel
257 #pragma omp parallel master taskloop simd private(x, y, z)
258 for (i = 0; i < 16; ++i) {
259 x = y * i + z;
263 void test_lastprivate(void) {
264 int i;
265 #pragma omp parallel
266 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
267 // expected-error@+1 {{expected expression}}
268 #pragma omp parallel master taskloop simd lastprivate(
269 for (i = 0; i < 16; ++i)
272 #pragma omp parallel
273 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
274 // expected-error@+1 2 {{expected expression}}
275 #pragma omp parallel master taskloop simd lastprivate(,
276 for (i = 0; i < 16; ++i)
278 #pragma omp parallel
279 // expected-error@+1 2 {{expected expression}}
280 #pragma omp parallel master taskloop simd lastprivate(, )
281 for (i = 0; i < 16; ++i)
283 #pragma omp parallel
284 // expected-error@+1 {{expected expression}}
285 #pragma omp parallel master taskloop simd lastprivate()
286 for (i = 0; i < 16; ++i)
288 #pragma omp parallel
289 // expected-error@+1 {{expected expression}}
290 #pragma omp parallel master taskloop simd lastprivate(int)
291 for (i = 0; i < 16; ++i)
293 #pragma omp parallel
294 // expected-error@+1 {{expected variable name}}
295 #pragma omp parallel master taskloop simd lastprivate(0)
296 for (i = 0; i < 16; ++i)
299 int x, y, z;
300 #pragma omp parallel
301 #pragma omp parallel master taskloop simd lastprivate(x)
302 for (i = 0; i < 16; ++i)
304 #pragma omp parallel
305 #pragma omp parallel master taskloop simd lastprivate(x, y)
306 for (i = 0; i < 16; ++i)
308 #pragma omp parallel
309 #pragma omp parallel master taskloop simd lastprivate(x, y, z)
310 for (i = 0; i < 16; ++i)
314 void test_firstprivate(void) {
315 int i;
316 #pragma omp parallel
317 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
318 // expected-error@+1 {{expected expression}}
319 #pragma omp parallel master taskloop simd firstprivate(
320 for (i = 0; i < 16; ++i)
323 #pragma omp parallel
324 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
325 // expected-error@+1 2 {{expected expression}}
326 #pragma omp parallel master taskloop simd firstprivate(,
327 for (i = 0; i < 16; ++i)
329 #pragma omp parallel
330 // expected-error@+1 2 {{expected expression}}
331 #pragma omp parallel master taskloop simd firstprivate(, )
332 for (i = 0; i < 16; ++i)
334 #pragma omp parallel
335 // expected-error@+1 {{expected expression}}
336 #pragma omp parallel master taskloop simd firstprivate()
337 for (i = 0; i < 16; ++i)
339 #pragma omp parallel
340 // expected-error@+1 {{expected expression}}
341 #pragma omp parallel master taskloop simd firstprivate(int)
342 for (i = 0; i < 16; ++i)
344 #pragma omp parallel
345 // expected-error@+1 {{expected variable name}}
346 #pragma omp parallel master taskloop simd firstprivate(0)
347 for (i = 0; i < 16; ++i)
350 int x, y, z;
351 #pragma omp parallel
352 #pragma omp parallel master taskloop simd lastprivate(x) firstprivate(x)
353 for (i = 0; i < 16; ++i)
355 #pragma omp parallel
356 #pragma omp parallel master taskloop simd lastprivate(x, y) firstprivate(x, y)
357 for (i = 0; i < 16; ++i)
359 #pragma omp parallel
360 #pragma omp parallel master taskloop simd lastprivate(x, y, z) firstprivate(x, y, z)
361 for (i = 0; i < 16; ++i)
365 void test_loop_messages(void) {
366 float a[100], b[100], c[100];
367 #pragma omp parallel
368 // expected-error@+2 {{variable must be of integer or pointer type}}
369 #pragma omp parallel master taskloop simd
370 for (float fi = 0; fi < 10.0; fi++) {
371 c[(int)fi] = a[(int)fi] + b[(int)fi];
373 #pragma omp parallel
374 // expected-error@+2 {{variable must be of integer or pointer type}}
375 #pragma omp parallel master taskloop simd
376 for (double fi = 0; fi < 10.0; fi++) {
377 c[(int)fi] = a[(int)fi] + b[(int)fi];
380 // expected-warning@+2 {{OpenMP loop iteration variable cannot have more than 64 bits size and will be narrowed}}
381 #pragma omp parallel master taskloop simd
382 for (__int128 ii = 0; ii < 10; ii++) {
383 c[ii] = a[ii] + b[ii];
387 void test_nontemporal(void) {
388 int i;
389 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
390 #pragma omp parallel master taskloop simd nontemporal(
391 for (i = 0; i < 16; ++i)
393 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 2 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
394 #pragma omp parallel master taskloop simd nontemporal(,
395 for (i = 0; i < 16; ++i)
397 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 2 {{expected expression}}
398 #pragma omp parallel master taskloop simd nontemporal(, )
399 for (i = 0; i < 16; ++i)
401 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{expected expression}}
402 #pragma omp parallel master taskloop simd nontemporal()
403 for (i = 0; i < 16; ++i)
405 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{expected expression}}
406 #pragma omp parallel master taskloop simd nontemporal(int)
407 for (i = 0; i < 16; ++i)
409 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} omp51-error@+1 {{expected variable name}}
410 #pragma omp parallel master taskloop simd nontemporal(0)
411 for (i = 0; i < 16; ++i)
413 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{use of undeclared identifier 'x'}}
414 #pragma omp parallel master taskloop simd nontemporal(x)
415 for (i = 0; i < 16; ++i)
417 // expected-error@+2 {{use of undeclared identifier 'x'}}
418 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{use of undeclared identifier 'y'}}
419 #pragma omp parallel master taskloop simd nontemporal(x, y)
420 for (i = 0; i < 16; ++i)
422 // expected-error@+3 {{use of undeclared identifier 'x'}}
423 // expected-error@+2 {{use of undeclared identifier 'y'}}
424 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{use of undeclared identifier 'z'}}
425 #pragma omp parallel master taskloop simd nontemporal(x, y, z)
426 for (i = 0; i < 16; ++i)
429 int x, y;
430 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
431 #pragma omp parallel master taskloop simd nontemporal(x :)
432 for (i = 0; i < 16; ++i)
434 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}}
435 #pragma omp parallel master taskloop simd nontemporal(x :, )
436 for (i = 0; i < 16; ++i)
439 // omp51-note@+2 {{defined as nontemporal}}
440 // omp45-error@+1 2 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} omp51-error@+1 {{a variable cannot appear in more than one nontemporal clause}}
441 #pragma omp parallel master taskloop simd nontemporal(x) nontemporal(x)
442 for (i = 0; i < 16; ++i)
445 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}}
446 #pragma omp parallel master taskloop simd private(x) nontemporal(x)
447 for (i = 0; i < 16; ++i)
450 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}}
451 #pragma omp parallel master taskloop simd nontemporal(x) private(x)
452 for (i = 0; i < 16; ++i)
455 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}}
456 #pragma omp parallel master taskloop simd nontemporal(x, y : 0)
457 for (i = 0; i < 16; ++i)
460 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}}
461 #pragma omp parallel master taskloop simd nontemporal(x) lastprivate(x)
462 for (i = 0; i < 16; ++i)
465 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel master taskloop simd'}}
466 #pragma omp parallel master taskloop simd lastprivate(x) nontemporal(x)
467 for (i = 0; i < 16; ++i)