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
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) {
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
31 void test_branch_protected_scope(void) {
39 #pragma omp parallel master taskloop simd
40 for (i
= 0; i
< 16; ++i
) {
42 goto L1
; // expected-error {{use of undeclared label 'L1'}}
44 return; // expected-error {{cannot return from OpenMP region}}
54 goto L2
; // expected-error {{use of undeclared label 'L2'}}
59 void test_invalid_clause(void) {
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) {
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}}
85 #pragma omp parallel master taskloop simd linear(x);
86 for (i
= 0; i
< 16; ++i
)
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
)
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) {
107 // expected-error@+1 {{expected '('}}
108 #pragma omp parallel master taskloop simd collapse
109 for (i
= 0; i
< 16; ++i
)
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
)
117 // expected-error@+1 {{expected expression}}
118 #pragma omp parallel master taskloop simd collapse()
119 for (i
= 0; i
< 16; ++i
)
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
)
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
)
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
)
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}}
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}}
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}}
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}}
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}}
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}}
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
)
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}}
186 // expected-error@+1 {{integer constant expression}}
187 #pragma omp parallel master taskloop simd collapse(2.5)
188 for (i
= 0; i
< 16; ++i
)
191 // expected-error@+1 {{integer constant expression}}
192 #pragma omp parallel master taskloop simd collapse(foo())
193 for (i
= 0; i
< 16; ++i
)
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
)
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
)
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) {
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
)
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
)
227 // expected-error@+1 2 {{expected expression}}
228 #pragma omp parallel master taskloop simd private(, )
229 for (i
= 0; i
< 16; ++i
)
232 // expected-error@+1 {{expected expression}}
233 #pragma omp parallel master taskloop simd private()
234 for (i
= 0; i
< 16; ++i
)
237 // expected-error@+1 {{expected expression}}
238 #pragma omp parallel master taskloop simd private(int)
239 for (i
= 0; i
< 16; ++i
)
242 // expected-error@+1 {{expected variable name}}
243 #pragma omp parallel master taskloop simd private(0)
244 for (i
= 0; i
< 16; ++i
)
249 #pragma omp parallel master taskloop simd private(x)
250 for (i
= 0; i
< 16; ++i
)
253 #pragma omp parallel master taskloop simd private(x, y)
254 for (i
= 0; i
< 16; ++i
)
257 #pragma omp parallel master taskloop simd private(x, y, z)
258 for (i
= 0; i
< 16; ++i
) {
263 void test_lastprivate(void) {
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
)
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
)
279 // expected-error@+1 2 {{expected expression}}
280 #pragma omp parallel master taskloop simd lastprivate(, )
281 for (i
= 0; i
< 16; ++i
)
284 // expected-error@+1 {{expected expression}}
285 #pragma omp parallel master taskloop simd lastprivate()
286 for (i
= 0; i
< 16; ++i
)
289 // expected-error@+1 {{expected expression}}
290 #pragma omp parallel master taskloop simd lastprivate(int)
291 for (i
= 0; i
< 16; ++i
)
294 // expected-error@+1 {{expected variable name}}
295 #pragma omp parallel master taskloop simd lastprivate(0)
296 for (i
= 0; i
< 16; ++i
)
301 #pragma omp parallel master taskloop simd lastprivate(x)
302 for (i
= 0; i
< 16; ++i
)
305 #pragma omp parallel master taskloop simd lastprivate(x, y)
306 for (i
= 0; i
< 16; ++i
)
309 #pragma omp parallel master taskloop simd lastprivate(x, y, z)
310 for (i
= 0; i
< 16; ++i
)
314 void test_firstprivate(void) {
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
)
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
)
330 // expected-error@+1 2 {{expected expression}}
331 #pragma omp parallel master taskloop simd firstprivate(, )
332 for (i
= 0; i
< 16; ++i
)
335 // expected-error@+1 {{expected expression}}
336 #pragma omp parallel master taskloop simd firstprivate()
337 for (i
= 0; i
< 16; ++i
)
340 // expected-error@+1 {{expected expression}}
341 #pragma omp parallel master taskloop simd firstprivate(int)
342 for (i
= 0; i
< 16; ++i
)
345 // expected-error@+1 {{expected variable name}}
346 #pragma omp parallel master taskloop simd firstprivate(0)
347 for (i
= 0; i
< 16; ++i
)
352 #pragma omp parallel master taskloop simd lastprivate(x) firstprivate(x)
353 for (i
= 0; i
< 16; ++i
)
356 #pragma omp parallel master taskloop simd lastprivate(x, y) firstprivate(x, y)
357 for (i
= 0; i
< 16; ++i
)
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];
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
];
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) {
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
)
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
)