1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -verify=expected,omp45 %s -Wuninitialized
2 // RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=50 -verify=expected,omp5,omp50 %s -Wuninitialized
3 // RUN: %clang_cc1 -fsyntax-only -fopenmp -verify=expected,omp5,omp51 %s -Wuninitialized
5 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 -verify=expected,omp45 %s -Wuninitialized
6 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=50 -verify=expected,omp5,omp50 %s -Wuninitialized
7 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify=expected,omp5,omp51 %s -Wuninitialized
9 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp target teams distribute simd'}}
10 #pragma omp target teams distribute simd
12 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp target teams distribute simd'}}
13 #pragma omp target teams distribute simd foo
15 void test_no_clause(void) {
17 #pragma omp target teams distribute simd
18 for (i
= 0; i
< 16; ++i
)
21 // expected-error@+2 {{statement after '#pragma omp target teams distribute simd' must be a for loop}}
22 #pragma omp target teams distribute simd
26 void test_branch_protected_scope(void) {
33 #pragma omp target teams distribute simd
34 for (i
= 0; i
< 16; ++i
) {
36 goto L1
; // expected-error {{use of undeclared label 'L1'}}
38 return; // expected-error {{cannot return from OpenMP region}}
48 goto L2
; // expected-error {{use of undeclared label 'L2'}}
53 void test_invalid_clause(void) {
55 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
56 #pragma omp target teams distribute simd foo bar
57 for (i
= 0; i
< 16; ++i
)
61 void test_non_identifiers(void) {
64 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
65 #pragma omp target teams distribute simd;
66 for (i
= 0; i
< 16; ++i
)
69 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
70 #pragma omp target teams distribute simd private(x);
71 for (i
= 0; i
< 16; ++i
)
74 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
75 #pragma omp target teams distribute simd, private(x);
76 for (i
= 0; i
< 16; ++i
)
82 void test_collapse(void) {
84 // expected-error@+1 {{expected '('}}
85 #pragma omp target teams distribute simd collapse
86 for (i
= 0; i
< 16; ++i
)
88 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
89 #pragma omp target teams distribute simd collapse(
90 for (i
= 0; i
< 16; ++i
)
92 // expected-error@+1 {{expected expression}}
93 #pragma omp target teams distribute simd collapse()
94 for (i
= 0; i
< 16; ++i
)
96 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
97 #pragma omp target teams distribute simd collapse(,
98 for (i
= 0; i
< 16; ++i
)
100 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
101 #pragma omp target teams distribute simd collapse(, )
102 for (i
= 0; i
< 16; ++i
)
104 // expected-warning@+2 {{extra tokens at the end of '#pragma omp target teams distribute simd' are ignored}}
105 // expected-error@+1 {{expected '('}}
106 #pragma omp target teams distribute simd collapse 4)
107 for (i
= 0; i
< 16; ++i
)
109 // expected-error@+2 {{expected ')'}}
110 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
111 #pragma omp target teams distribute simd collapse(4
112 for (i
= 0; i
< 16; ++i
)
113 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute simd', but found only 1}}
114 // expected-error@+2 {{expected ')'}}
115 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
116 #pragma omp target teams distribute simd collapse(4,
117 for (i
= 0; i
< 16; ++i
)
118 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute simd', but found only 1}}
119 // expected-error@+2 {{expected ')'}}
120 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
121 #pragma omp target teams distribute simd collapse(4, )
122 for (i
= 0; i
< 16; ++i
)
123 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute simd', but found only 1}}
124 // expected-note@+1 {{as specified in 'collapse' clause}}
125 #pragma omp target teams distribute simd collapse(4)
126 for (i
= 0; i
< 16; ++i
)
127 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute simd', but found only 1}}
128 // expected-error@+2 {{expected ')'}}
129 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
130 #pragma omp target teams distribute simd collapse(4 4)
131 for (i
= 0; i
< 16; ++i
)
132 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute simd', but found only 1}}
133 // expected-error@+2 {{expected ')'}}
134 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
135 #pragma omp target teams distribute simd collapse(4, , 4)
136 for (i
= 0; i
< 16; ++i
)
137 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute simd', but found only 1}}
138 #pragma omp target teams distribute simd collapse(4)
139 for (int i1
= 0; i1
< 16; ++i1
)
140 for (int i2
= 0; i2
< 16; ++i2
)
141 for (int i3
= 0; i3
< 16; ++i3
)
142 for (int i4
= 0; i4
< 16; ++i4
)
144 // expected-error@+2 {{expected ')'}}
145 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
146 #pragma omp target teams distribute simd collapse(4, 8)
147 for (i
= 0; i
< 16; ++i
)
148 ; // expected-error {{expected 4 for loops after '#pragma omp target teams distribute simd', but found only 1}}
149 // expected-error@+1 {{integer constant expression}}
150 #pragma omp target teams distribute simd collapse(2.5)
151 for (i
= 0; i
< 16; ++i
)
153 // expected-error@+1 {{integer constant expression}}
154 #pragma omp target teams distribute simd collapse(foo())
155 for (i
= 0; i
< 16; ++i
)
157 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
158 #pragma omp target teams distribute simd collapse(-5)
159 for (i
= 0; i
< 16; ++i
)
161 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
162 #pragma omp target teams distribute simd collapse(0)
163 for (i
= 0; i
< 16; ++i
)
165 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
166 #pragma omp target teams distribute simd collapse(5 - 5)
167 for (i
= 0; i
< 16; ++i
)
170 // expected-error@+4 {{OpenMP constructs may not be nested inside a simd region}}
171 #pragma omp target teams distribute simd collapse(2) firstprivate(i) // expected-note {{defined as firstprivate}}
172 for (i
= 0; i
< 16; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp target teams distribute simd' directive may not be firstprivate, predetermined as lastprivate}}
173 for (int j
= 0; j
< 16; ++j
)
174 #pragma omp parallel for reduction(+ : i, j)
175 for (int k
= 0; k
< 16; ++k
)
179 void test_private(void) {
181 // expected-error@+2 {{expected expression}}
182 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
183 #pragma omp target teams distribute simd private(
184 for (i
= 0; i
< 16; ++i
)
186 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
187 // expected-error@+1 2 {{expected expression}}
188 #pragma omp target teams distribute simd private(,
189 for (i
= 0; i
< 16; ++i
)
191 // expected-error@+1 2 {{expected expression}}
192 #pragma omp target teams distribute simd private(, )
193 for (i
= 0; i
< 16; ++i
)
195 // expected-error@+1 {{expected expression}}
196 #pragma omp target teams distribute simd private()
197 for (i
= 0; i
< 16; ++i
)
199 // expected-error@+1 {{expected expression}}
200 #pragma omp target teams distribute simd private(int)
201 for (i
= 0; i
< 16; ++i
)
203 // expected-error@+1 {{expected variable name}}
204 #pragma omp target teams distribute simd private(0)
205 for (i
= 0; i
< 16; ++i
)
209 #pragma omp target teams distribute simd private(x)
210 for (i
= 0; i
< 16; ++i
)
212 #pragma omp target teams distribute simd private(x, y)
213 for (i
= 0; i
< 16; ++i
)
215 #pragma omp target teams distribute simd private(x, y, z)
216 for (i
= 0; i
< 16; ++i
) {
221 void test_lastprivate(void) {
223 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
224 // expected-error@+1 {{expected expression}}
225 #pragma omp target teams distribute simd lastprivate(
226 for (i
= 0; i
< 16; ++i
)
229 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
230 // expected-error@+1 2 {{expected expression}}
231 #pragma omp target teams distribute simd lastprivate(,
232 for (i
= 0; i
< 16; ++i
)
234 // expected-error@+1 2 {{expected expression}}
235 #pragma omp target teams distribute simd lastprivate(, )
236 for (i
= 0; i
< 16; ++i
)
238 // expected-error@+1 {{expected expression}}
239 #pragma omp target teams distribute simd lastprivate()
240 for (i
= 0; i
< 16; ++i
)
242 // expected-error@+1 {{expected expression}}
243 #pragma omp target teams distribute simd lastprivate(int)
244 for (i
= 0; i
< 16; ++i
)
246 // expected-error@+1 {{expected variable name}}
247 #pragma omp target teams distribute simd lastprivate(0)
248 for (i
= 0; i
< 16; ++i
)
252 #pragma omp target teams distribute simd lastprivate(x)
253 for (i
= 0; i
< 16; ++i
)
255 #pragma omp target teams distribute simd lastprivate(x, y)
256 for (i
= 0; i
< 16; ++i
)
258 #pragma omp target teams distribute simd lastprivate(x, y, z)
259 for (i
= 0; i
< 16; ++i
)
263 void test_firstprivate(void) {
265 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
266 // expected-error@+1 {{expected expression}}
267 #pragma omp target teams distribute simd firstprivate(
268 for (i
= 0; i
< 16; ++i
)
271 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
272 // expected-error@+1 2 {{expected expression}}
273 #pragma omp target teams distribute simd firstprivate(,
274 for (i
= 0; i
< 16; ++i
)
276 // expected-error@+1 2 {{expected expression}}
277 #pragma omp target teams distribute simd firstprivate(, )
278 for (i
= 0; i
< 16; ++i
)
280 // expected-error@+1 {{expected expression}}
281 #pragma omp target teams distribute simd firstprivate()
282 for (i
= 0; i
< 16; ++i
)
284 // expected-error@+1 {{expected expression}}
285 #pragma omp target teams distribute simd firstprivate(int)
286 for (i
= 0; i
< 16; ++i
)
288 // expected-error@+1 {{expected variable name}}
289 #pragma omp target teams distribute simd firstprivate(0)
290 for (i
= 0; i
< 16; ++i
)
294 // expected-error@+1 {{lastprivate variable cannot be firstprivate}} expected-note@+1 {{defined as lastprivate}}
295 #pragma omp target teams distribute simd lastprivate(x) firstprivate(x)
296 for (i
= 0; i
< 16; ++i
)
298 // expected-error@+1 2 {{lastprivate variable cannot be firstprivate}} expected-note@+1 2 {{defined as lastprivate}}
299 #pragma omp target teams distribute simd lastprivate(x, y) firstprivate(x, y)
300 for (i
= 0; i
< 16; ++i
)
302 // expected-error@+1 3 {{lastprivate variable cannot be firstprivate}} expected-note@+1 3 {{defined as lastprivate}}
303 #pragma omp target teams distribute simd lastprivate(x, y, z) firstprivate(x, y, z)
304 for (i
= 0; i
< 16; ++i
)
306 // expected-error@+1 {{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}}
307 #pragma omp target teams distribute simd simdlen(64) safelen(8)
308 for (i
= 0; i
< 16; ++i
)
312 void test_loop_messages(void) {
313 float a
[100], b
[100], c
[100];
314 // expected-error@+2 {{variable must be of integer or pointer type}}
315 #pragma omp target teams distribute simd
316 for (float fi
= 0; fi
< 10.0; fi
++) {
317 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
319 // expected-error@+2 {{variable must be of integer or pointer type}}
320 #pragma omp target teams distribute simd
321 for (double fi
= 0; fi
< 10.0; fi
++) {
322 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
326 void test_nontemporal(void) {
328 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}} expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
329 #pragma omp target teams distribute simd nontemporal(
330 for (i
= 0; i
< 16; ++i
)
332 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}} expected-error@+1 2 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
333 #pragma omp target teams distribute simd nontemporal(,
334 for (i
= 0; i
< 16; ++i
)
336 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}} expected-error@+1 2 {{expected expression}}
337 #pragma omp target teams distribute simd nontemporal(, )
338 for (i
= 0; i
< 16; ++i
)
340 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}} expected-error@+1 {{expected expression}}
341 #pragma omp target teams distribute simd nontemporal()
342 for (i
= 0; i
< 16; ++i
)
344 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}} expected-error@+1 {{expected expression}}
345 #pragma omp target teams distribute simd nontemporal(int)
346 for (i
= 0; i
< 16; ++i
)
348 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}} omp5-error@+1 {{expected variable name}}
349 #pragma omp target teams distribute simd nontemporal(0)
350 for (i
= 0; i
< 16; ++i
)
352 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}} expected-error@+1 {{use of undeclared identifier 'x'}}
353 #pragma omp target teams distribute simd nontemporal(x)
354 for (i
= 0; i
< 16; ++i
)
356 // expected-error@+2 {{use of undeclared identifier 'x'}}
357 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}} expected-error@+1 {{use of undeclared identifier 'y'}}
358 #pragma omp target teams distribute simd nontemporal(x, y)
359 for (i
= 0; i
< 16; ++i
)
361 // expected-error@+3 {{use of undeclared identifier 'x'}}
362 // expected-error@+2 {{use of undeclared identifier 'y'}}
363 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}} expected-error@+1 {{use of undeclared identifier 'z'}}
364 #pragma omp target teams distribute simd nontemporal(x, y, z)
365 for (i
= 0; i
< 16; ++i
)
369 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
370 #pragma omp target teams distribute simd nontemporal(x :)
371 for (i
= 0; i
< 16; ++i
)
373 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}}
374 #pragma omp target teams distribute simd nontemporal(x :, )
375 for (i
= 0; i
< 16; ++i
)
378 // omp5-note@+2 {{defined as nontemporal}}
379 // omp45-error@+1 2 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}} omp5-error@+1 {{a variable cannot appear in more than one nontemporal clause}}
380 #pragma omp target teams distribute simd nontemporal(x) nontemporal(x)
381 for (i
= 0; i
< 16; ++i
)
384 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}}
385 #pragma omp target teams distribute simd private(x) nontemporal(x)
386 for (i
= 0; i
< 16; ++i
)
389 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}}
390 #pragma omp target teams distribute simd nontemporal(x) private(x)
391 for (i
= 0; i
< 16; ++i
)
394 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}}
395 #pragma omp target teams distribute simd nontemporal(x, y : 0)
396 for (i
= 0; i
< 16; ++i
)
399 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}}
400 #pragma omp target teams distribute simd nontemporal(x) lastprivate(x)
401 for (i
= 0; i
< 16; ++i
)
404 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp target teams distribute simd'}}
405 #pragma omp target teams distribute simd lastprivate(x) nontemporal(x)
406 for (i
= 0; i
< 16; ++i
)
408 #pragma omp target teams distribute simd order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute simd'}} expected-error {{expected '(' after 'order'}}
409 for (int i
= 0; i
< 10; ++i
)
411 #pragma omp target teams distribute simd order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
412 for (int i
= 0; i
< 10; ++i
)
414 #pragma omp target teams distribute simd order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
415 for (int i
= 0; i
< 10; ++i
)
417 #pragma omp target teams distribute simd order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
418 for (int i
= 0; i
< 10; ++i
)
420 #pragma omp target teams distribute simd order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute simd'}}
421 for (int i
= 0; i
< 10; ++i
)
423 #pragma omp target teams distribute simd order(unconstrained:) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute simd'}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
424 for (int i
= 0; i
< 10; ++i
)
426 #pragma omp target teams distribute simd order(reproducible:concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
427 for (int i
= 0; i
< 10; ++i
)
429 #pragma omp target teams distribute simd order(reproducible:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute simd'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
430 for (int i
= 0; i
< 10; ++i
)
432 #pragma omp target teams distribute simd order(unconstrained:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute simd'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
433 for (int i
= 0; i
< 10; ++i
)
435 #pragma omp target teams distribute simd order(concurrent) order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute simd'}} omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute simd'}} omp51-error {{directive '#pragma omp target teams distribute simd' cannot contain more than one 'order' clause}}
436 for (int i
= 0; i
< 10; ++i
)