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
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) {
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
31 void test_branch_protected_scope(void) {
39 #pragma omp 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) {
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) {
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}}
82 #pragma omp master taskloop simd linear(x);
83 for (i
= 0; i
< 16; ++i
)
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
)
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
)
101 void test_collapse(void) {
104 // expected-error@+1 {{expected '('}}
105 #pragma omp master taskloop simd collapse
106 for (i
= 0; i
< 16; ++i
)
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
)
114 // expected-error@+1 {{expected expression}}
115 #pragma omp master taskloop simd collapse()
116 for (i
= 0; i
< 16; ++i
)
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
)
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
)
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
)
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}}
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}}
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}}
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}}
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}}
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}}
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
)
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}}
183 // expected-error@+1 {{integer constant expression}}
184 #pragma omp master taskloop simd collapse(2.5)
185 for (i
= 0; i
< 16; ++i
)
188 // expected-error@+1 {{integer constant expression}}
189 #pragma omp master taskloop simd collapse(foo())
190 for (i
= 0; i
< 16; ++i
)
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
)
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
)
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) {
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
)
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
)
224 // expected-error@+1 2 {{expected expression}}
225 #pragma omp master taskloop simd private(, )
226 for (i
= 0; i
< 16; ++i
)
229 // expected-error@+1 {{expected expression}}
230 #pragma omp master taskloop simd private()
231 for (i
= 0; i
< 16; ++i
)
234 // expected-error@+1 {{expected expression}}
235 #pragma omp master taskloop simd private(int)
236 for (i
= 0; i
< 16; ++i
)
239 // expected-error@+1 {{expected variable name}}
240 #pragma omp master taskloop simd private(0)
241 for (i
= 0; i
< 16; ++i
)
246 #pragma omp master taskloop simd private(x)
247 for (i
= 0; i
< 16; ++i
)
250 #pragma omp master taskloop simd private(x, y)
251 for (i
= 0; i
< 16; ++i
)
254 #pragma omp master taskloop simd private(x, y, z)
255 for (i
= 0; i
< 16; ++i
) {
260 void test_lastprivate(void) {
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
)
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
)
276 // expected-error@+1 2 {{expected expression}}
277 #pragma omp master taskloop simd lastprivate(, )
278 for (i
= 0; i
< 16; ++i
)
281 // expected-error@+1 {{expected expression}}
282 #pragma omp master taskloop simd lastprivate()
283 for (i
= 0; i
< 16; ++i
)
286 // expected-error@+1 {{expected expression}}
287 #pragma omp master taskloop simd lastprivate(int)
288 for (i
= 0; i
< 16; ++i
)
291 // expected-error@+1 {{expected variable name}}
292 #pragma omp master taskloop simd lastprivate(0)
293 for (i
= 0; i
< 16; ++i
)
298 #pragma omp master taskloop simd lastprivate(x)
299 for (i
= 0; i
< 16; ++i
)
302 #pragma omp master taskloop simd lastprivate(x, y)
303 for (i
= 0; i
< 16; ++i
)
306 #pragma omp master taskloop simd lastprivate(x, y, z)
307 for (i
= 0; i
< 16; ++i
)
311 void test_firstprivate(void) {
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
)
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
)
327 // expected-error@+1 2 {{expected expression}}
328 #pragma omp master taskloop simd firstprivate(, )
329 for (i
= 0; i
< 16; ++i
)
332 // expected-error@+1 {{expected expression}}
333 #pragma omp master taskloop simd firstprivate()
334 for (i
= 0; i
< 16; ++i
)
337 // expected-error@+1 {{expected expression}}
338 #pragma omp master taskloop simd firstprivate(int)
339 for (i
= 0; i
< 16; ++i
)
342 // expected-error@+1 {{expected variable name}}
343 #pragma omp master taskloop simd firstprivate(0)
344 for (i
= 0; i
< 16; ++i
)
349 #pragma omp master taskloop simd lastprivate(x) firstprivate(x)
350 for (i
= 0; i
< 16; ++i
)
353 #pragma omp master taskloop simd lastprivate(x, y) firstprivate(x, y)
354 for (i
= 0; i
< 16; ++i
)
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];
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
];
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) {
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
)
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
)