1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s
2
3 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp simd'}}
4 #pragma omp simd
5
6 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp simd'}}
7 #pragma omp simd foo
8
9 // expected-error@+1 {{unexpected OpenMP directive '#pragma omp simd'}}
10 #pragma omp simd safelen(4)
11
test_no_clause()12 void test_no_clause() {
13 int i;
14 #pragma omp simd
15 for (i = 0; i < 16; ++i)
16 ;
17
18 // expected-error@+2 {{statement after '#pragma omp simd' must be a for loop}}
19 #pragma omp simd
20 ++i;
21 }
22
test_branch_protected_scope()23 void test_branch_protected_scope() {
24 int i = 0;
25 L1:
26 ++i;
27
28 int x[24];
29
30 #pragma omp simd
31 for (i = 0; i < 16; ++i) {
32 if (i == 5)
33 goto L1; // expected-error {{use of undeclared label 'L1'}}
34 else if (i == 6)
35 return; // expected-error {{cannot return from OpenMP region}}
36 else if (i == 7)
37 goto L2;
38 else if (i == 8) {
39 L2:
40 x[i]++;
41 }
42 }
43
44 if (x[0] == 0)
45 goto L2; // expected-error {{use of undeclared label 'L2'}}
46 else if (x[1] == 1)
47 goto L1;
48 }
49
test_invalid_clause()50 void test_invalid_clause() {
51 int i;
52 // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
53 #pragma omp simd foo bar
54 for (i = 0; i < 16; ++i)
55 ;
56 }
57
test_non_identifiers()58 void test_non_identifiers() {
59 int i, x;
60
61 // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
62 #pragma omp simd;
63 for (i = 0; i < 16; ++i)
64 ;
65 // expected-error@+2 {{unexpected OpenMP clause 'firstprivate' in directive '#pragma omp simd'}}
66 // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
67 #pragma omp simd firstprivate(x);
68 for (i = 0; i < 16; ++i)
69 ;
70
71 // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
72 #pragma omp simd private(x);
73 for (i = 0; i < 16; ++i)
74 ;
75
76 // expected-warning@+1 {{extra tokens at the end of '#pragma omp simd' are ignored}}
77 #pragma omp simd, private(x);
78 for (i = 0; i < 16; ++i)
79 ;
80 }
81
82 extern int foo();
test_safelen()83 void test_safelen() {
84 int i;
85 // expected-error@+1 {{expected '('}}
86 #pragma omp simd safelen
87 for (i = 0; i < 16; ++i)
88 ;
89 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
90 #pragma omp simd safelen(
91 for (i = 0; i < 16; ++i)
92 ;
93 // expected-error@+1 {{expected expression}}
94 #pragma omp simd safelen()
95 for (i = 0; i < 16; ++i)
96 ;
97 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
98 #pragma omp simd safelen(,
99 for (i = 0; i < 16; ++i)
100 ;
101 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
102 #pragma omp simd safelen(, )
103 for (i = 0; i < 16; ++i)
104 ;
105 // expected-warning@+2 {{extra tokens at the end of '#pragma omp simd' are ignored}}
106 // expected-error@+1 {{expected '('}}
107 #pragma omp simd safelen 4)
108 for (i = 0; i < 16; ++i)
109 ;
110 // expected-error@+2 {{expected ')'}}
111 // expected-note@+1 {{to match this '('}}
112 #pragma omp simd safelen(4
113 for (i = 0; i < 16; ++i)
114 ;
115 // expected-error@+2 {{expected ')'}}
116 // expected-note@+1 {{to match this '('}}
117 #pragma omp simd safelen(4,
118 for (i = 0; i < 16; ++i)
119 ;
120 // expected-error@+2 {{expected ')'}}
121 // expected-note@+1 {{to match this '('}}
122 #pragma omp simd safelen(4, )
123 for (i = 0; i < 16; ++i)
124 ;
125 // xxpected-error@+1 {{expected expression}}
126 #pragma omp simd safelen(4)
127 for (i = 0; i < 16; ++i)
128 ;
129 // expected-error@+2 {{expected ')'}}
130 // expected-note@+1 {{to match this '('}}
131 #pragma omp simd safelen(4 4)
132 for (i = 0; i < 16; ++i)
133 ;
134 // expected-error@+2 {{expected ')'}}
135 // expected-note@+1 {{to match this '('}}
136 #pragma omp simd safelen(4, , 4)
137 for (i = 0; i < 16; ++i)
138 ;
139 #pragma omp simd safelen(4)
140 for (i = 0; i < 16; ++i)
141 ;
142 // expected-error@+2 {{expected ')'}}
143 // expected-note@+1 {{to match this '('}}
144 #pragma omp simd safelen(4, 8)
145 for (i = 0; i < 16; ++i)
146 ;
147 // expected-error@+1 {{expression is not an integer constant expression}}
148 #pragma omp simd safelen(2.5)
149 for (i = 0; i < 16; ++i)
150 ;
151 // expected-error@+1 {{expression is not an integer constant expression}}
152 #pragma omp simd safelen(foo())
153 for (i = 0; i < 16; ++i)
154 ;
155 // expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}}
156 #pragma omp simd safelen(-5)
157 for (i = 0; i < 16; ++i)
158 ;
159 // expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}}
160 #pragma omp simd safelen(0)
161 for (i = 0; i < 16; ++i)
162 ;
163 // expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}}
164 #pragma omp simd safelen(5 - 5)
165 for (i = 0; i < 16; ++i)
166 ;
167 }
168
test_simdlen()169 void test_simdlen() {
170 int i;
171 // expected-error@+1 {{expected '('}}
172 #pragma omp simd simdlen
173 for (i = 0; i < 16; ++i)
174 ;
175 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
176 #pragma omp simd simdlen(
177 for (i = 0; i < 16; ++i)
178 ;
179 // expected-error@+1 {{expected expression}}
180 #pragma omp simd simdlen()
181 for (i = 0; i < 16; ++i)
182 ;
183 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
184 #pragma omp simd simdlen(,
185 for (i = 0; i < 16; ++i)
186 ;
187 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
188 #pragma omp simd simdlen(, )
189 for (i = 0; i < 16; ++i)
190 ;
191 // expected-warning@+2 {{extra tokens at the end of '#pragma omp simd' are ignored}}
192 // expected-error@+1 {{expected '('}}
193 #pragma omp simd simdlen 4)
194 for (i = 0; i < 16; ++i)
195 ;
196 // expected-error@+2 {{expected ')'}}
197 // expected-note@+1 {{to match this '('}}
198 #pragma omp simd simdlen(4
199 for (i = 0; i < 16; ++i)
200 ;
201 // expected-error@+2 {{expected ')'}}
202 // expected-note@+1 {{to match this '('}}
203 #pragma omp simd simdlen(4,
204 for (i = 0; i < 16; ++i)
205 ;
206 // expected-error@+2 {{expected ')'}}
207 // expected-note@+1 {{to match this '('}}
208 #pragma omp simd simdlen(4, )
209 for (i = 0; i < 16; ++i)
210 ;
211 #pragma omp simd simdlen(4)
212 for (i = 0; i < 16; ++i)
213 ;
214 // expected-error@+2 {{expected ')'}}
215 // expected-note@+1 {{to match this '('}}
216 #pragma omp simd simdlen(4 4)
217 for (i = 0; i < 16; ++i)
218 ;
219 // expected-error@+2 {{expected ')'}}
220 // expected-note@+1 {{to match this '('}}
221 #pragma omp simd simdlen(4, , 4)
222 for (i = 0; i < 16; ++i)
223 ;
224 #pragma omp simd simdlen(4)
225 for (i = 0; i < 16; ++i)
226 ;
227 // expected-error@+2 {{expected ')'}}
228 // expected-note@+1 {{to match this '('}}
229 #pragma omp simd simdlen(4, 8)
230 for (i = 0; i < 16; ++i)
231 ;
232 // expected-error@+1 {{expression is not an integer constant expression}}
233 #pragma omp simd simdlen(2.5)
234 for (i = 0; i < 16; ++i)
235 ;
236 // expected-error@+1 {{expression is not an integer constant expression}}
237 #pragma omp simd simdlen(foo())
238 for (i = 0; i < 16; ++i)
239 ;
240 // expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
241 #pragma omp simd simdlen(-5)
242 for (i = 0; i < 16; ++i)
243 ;
244 // expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
245 #pragma omp simd simdlen(0)
246 for (i = 0; i < 16; ++i)
247 ;
248 // expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}}
249 #pragma omp simd simdlen(5 - 5)
250 for (i = 0; i < 16; ++i)
251 ;
252 }
253
test_safelen_simdlen()254 void test_safelen_simdlen() {
255 int i;
256 // expected-error@+1 {{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}}
257 #pragma omp simd simdlen(6) safelen(5)
258 for (i = 0; i < 16; ++i)
259 ;
260 // expected-error@+1 {{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}}
261 #pragma omp simd safelen(5) simdlen(6)
262 for (i = 0; i < 16; ++i)
263 ;
264 }
265
test_collapse()266 void test_collapse() {
267 int i;
268 // expected-error@+1 {{expected '('}}
269 #pragma omp simd collapse
270 for (i = 0; i < 16; ++i)
271 ;
272 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
273 #pragma omp simd collapse(
274 for (i = 0; i < 16; ++i)
275 ;
276 // expected-error@+1 {{expected expression}}
277 #pragma omp simd collapse()
278 for (i = 0; i < 16; ++i)
279 ;
280 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
281 #pragma omp simd collapse(,
282 for (i = 0; i < 16; ++i)
283 ;
284 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
285 #pragma omp simd collapse(, )
286 for (i = 0; i < 16; ++i)
287 ;
288 // expected-warning@+2 {{extra tokens at the end of '#pragma omp simd' are ignored}}
289 // expected-error@+1 {{expected '('}}
290 #pragma omp simd collapse 4)
291 for (i = 0; i < 16; ++i)
292 ;
293 // expected-error@+2 {{expected ')'}}
294 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
295 #pragma omp simd collapse(4
296 for (i = 0; i < 16; ++i)
297 ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
298 // expected-error@+2 {{expected ')'}}
299 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
300 #pragma omp simd collapse(4,
301 for (i = 0; i < 16; ++i)
302 ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
303 // expected-error@+2 {{expected ')'}}
304 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
305 #pragma omp simd collapse(4, )
306 for (i = 0; i < 16; ++i)
307 ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
308 // xxpected-error@+1 {{expected expression}} expected-note@+1 {{as specified in 'collapse' clause}}
309 #pragma omp simd collapse(4)
310 for (i = 0; i < 16; ++i)
311 ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
312 // expected-error@+2 {{expected ')'}}
313 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
314 #pragma omp simd collapse(4 4)
315 for (i = 0; i < 16; ++i)
316 ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
317 // expected-error@+2 {{expected ')'}}
318 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
319 #pragma omp simd collapse(4, , 4)
320 for (i = 0; i < 16; ++i)
321 ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
322 #pragma omp simd collapse(4)
323 for (int i1 = 0; i1 < 16; ++i1)
324 for (int i2 = 0; i2 < 16; ++i2)
325 for (int i3 = 0; i3 < 16; ++i3)
326 for (int i4 = 0; i4 < 16; ++i4)
327 foo();
328 // expected-error@+2 {{expected ')'}}
329 // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}}
330 #pragma omp simd collapse(4, 8)
331 for (i = 0; i < 16; ++i)
332 ; // expected-error {{expected 4 for loops after '#pragma omp simd', but found only 1}}
333 // expected-error@+1 {{expression is not an integer constant expression}}
334 #pragma omp simd collapse(2.5)
335 for (i = 0; i < 16; ++i)
336 ;
337 // expected-error@+1 {{expression is not an integer constant expression}}
338 #pragma omp simd collapse(foo())
339 for (i = 0; i < 16; ++i)
340 ;
341 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
342 #pragma omp simd collapse(-5)
343 for (i = 0; i < 16; ++i)
344 ;
345 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
346 #pragma omp simd collapse(0)
347 for (i = 0; i < 16; ++i)
348 ;
349 // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}}
350 #pragma omp simd collapse(5 - 5)
351 for (i = 0; i < 16; ++i)
352 ;
353 // expected-note@+2 {{defined as reduction}}
354 #pragma omp parallel
355 #pragma omp simd collapse(2) reduction(+ : i)
356 for (i = 0; i < 16; ++i)
357 // expected-note@+1 {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for' directive into a parallel or another task region?}}
358 for (int j = 0; j < 16; ++j)
359 // expected-error@+2 2 {{reduction variable must be shared}}
360 // expected-error@+1 {{OpenMP constructs may not be nested inside a simd region}}
361 #pragma omp for reduction(+ : i, j)
362 for (int k = 0; k < 16; ++k)
363 i += j;
364 #pragma omp parallel
365 #pragma omp for
366 for (i = 0; i < 16; ++i)
367 for (int j = 0; j < 16; ++j)
368 #pragma omp simd reduction(+ : i, j)
369 for (int k = 0; k < 16; ++k)
370 i += j;
371 }
372
test_linear()373 void test_linear() {
374 int i;
375 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
376 #pragma omp simd linear(
377 for (i = 0; i < 16; ++i)
378 ;
379 // expected-error@+2 {{expected expression}}
380 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
381 #pragma omp simd linear(,
382 for (i = 0; i < 16; ++i)
383 ;
384 // expected-error@+2 {{expected expression}}
385 // expected-error@+1 {{expected expression}}
386 #pragma omp simd linear(, )
387 for (i = 0; i < 16; ++i)
388 ;
389 // expected-error@+1 {{expected expression}}
390 #pragma omp simd linear()
391 for (i = 0; i < 16; ++i)
392 ;
393 // expected-error@+1 {{expected expression}}
394 #pragma omp simd linear(int)
395 for (i = 0; i < 16; ++i)
396 ;
397 // expected-error@+1 {{expected variable name}}
398 #pragma omp simd linear(0)
399 for (i = 0; i < 16; ++i)
400 ;
401 // expected-error@+1 {{use of undeclared identifier 'x'}}
402 #pragma omp simd linear(x)
403 for (i = 0; i < 16; ++i)
404 ;
405 // expected-error@+2 {{use of undeclared identifier 'x'}}
406 // expected-error@+1 {{use of undeclared identifier 'y'}}
407 #pragma omp simd linear(x, y)
408 for (i = 0; i < 16; ++i)
409 ;
410 // expected-error@+3 {{use of undeclared identifier 'x'}}
411 // expected-error@+2 {{use of undeclared identifier 'y'}}
412 // expected-error@+1 {{use of undeclared identifier 'z'}}
413 #pragma omp simd linear(x, y, z)
414 for (i = 0; i < 16; ++i)
415 ;
416
417 int x, y;
418 // expected-error@+1 {{expected expression}}
419 #pragma omp simd linear(x :)
420 for (i = 0; i < 16; ++i)
421 ;
422 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
423 #pragma omp simd linear(x :, )
424 for (i = 0; i < 16; ++i)
425 ;
426 #pragma omp simd linear(x : 1)
427 for (i = 0; i < 16; ++i)
428 ;
429 #pragma omp simd linear(x : 2 * 2)
430 for (i = 0; i < 16; ++i)
431 ;
432 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
433 #pragma omp simd linear(x : 1, y)
434 for (i = 0; i < 16; ++i)
435 ;
436 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
437 #pragma omp simd linear(x : 1, y, z : 1)
438 for (i = 0; i < 16; ++i)
439 ;
440
441 // expected-note@+2 {{defined as linear}}
442 // expected-error@+1 {{linear variable cannot be linear}}
443 #pragma omp simd linear(x) linear(x)
444 for (i = 0; i < 16; ++i)
445 ;
446
447 // expected-note@+2 {{defined as private}}
448 // expected-error@+1 {{private variable cannot be linear}}
449 #pragma omp simd private(x) linear(x)
450 for (i = 0; i < 16; ++i)
451 ;
452
453 // expected-note@+2 {{defined as linear}}
454 // expected-error@+1 {{linear variable cannot be private}}
455 #pragma omp simd linear(x) private(x)
456 for (i = 0; i < 16; ++i)
457 ;
458
459 // expected-warning@+1 {{zero linear step (x and other variables in clause should probably be const)}}
460 #pragma omp simd linear(x, y : 0)
461 for (i = 0; i < 16; ++i)
462 ;
463
464 // expected-note@+2 {{defined as linear}}
465 // expected-error@+1 {{linear variable cannot be lastprivate}}
466 #pragma omp simd linear(x) lastprivate(x)
467 for (i = 0; i < 16; ++i)
468 ;
469
470 // expected-note@+2 {{defined as lastprivate}}
471 // expected-error@+1 {{lastprivate variable cannot be linear}}
472 #pragma omp simd lastprivate(x) linear(x)
473 for (i = 0; i < 16; ++i)
474 ;
475 }
476
test_aligned()477 void test_aligned() {
478 int i;
479 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
480 #pragma omp simd aligned(
481 for (i = 0; i < 16; ++i)
482 ;
483 // expected-error@+2 {{expected expression}}
484 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
485 #pragma omp simd aligned(,
486 for (i = 0; i < 16; ++i)
487 ;
488 // expected-error@+2 {{expected expression}}
489 // expected-error@+1 {{expected expression}}
490 #pragma omp simd aligned(, )
491 for (i = 0; i < 16; ++i)
492 ;
493 // expected-error@+1 {{expected expression}}
494 #pragma omp simd aligned()
495 for (i = 0; i < 16; ++i)
496 ;
497 // expected-error@+1 {{expected expression}}
498 #pragma omp simd aligned(int)
499 for (i = 0; i < 16; ++i)
500 ;
501 // expected-error@+1 {{expected variable name}}
502 #pragma omp simd aligned(0)
503 for (i = 0; i < 16; ++i)
504 ;
505 // expected-error@+1 {{use of undeclared identifier 'x'}}
506 #pragma omp simd aligned(x)
507 for (i = 0; i < 16; ++i)
508 ;
509 // expected-error@+2 {{use of undeclared identifier 'x'}}
510 // expected-error@+1 {{use of undeclared identifier 'y'}}
511 #pragma omp simd aligned(x, y)
512 for (i = 0; i < 16; ++i)
513 ;
514 // expected-error@+3 {{use of undeclared identifier 'x'}}
515 // expected-error@+2 {{use of undeclared identifier 'y'}}
516 // expected-error@+1 {{use of undeclared identifier 'z'}}
517 #pragma omp simd aligned(x, y, z)
518 for (i = 0; i < 16; ++i)
519 ;
520
521 int *x, y, z[25]; // expected-note 4 {{'y' defined here}}
522 #pragma omp simd aligned(x)
523 for (i = 0; i < 16; ++i)
524 ;
525 #pragma omp simd aligned(z)
526 for (i = 0; i < 16; ++i)
527 ;
528 // expected-error@+1 {{expected expression}}
529 #pragma omp simd aligned(x :)
530 for (i = 0; i < 16; ++i)
531 ;
532 // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
533 #pragma omp simd aligned(x :, )
534 for (i = 0; i < 16; ++i)
535 ;
536 #pragma omp simd aligned(x : 1)
537 for (i = 0; i < 16; ++i)
538 ;
539 #pragma omp simd aligned(x : 2 * 2)
540 for (i = 0; i < 16; ++i)
541 ;
542 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
543 #pragma omp simd aligned(x : 1, y)
544 for (i = 0; i < 16; ++i)
545 ;
546 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
547 #pragma omp simd aligned(x : 1, y, z : 1)
548 for (i = 0; i < 16; ++i)
549 ;
550
551 // expected-error@+1 {{argument of aligned clause should be array or pointer, not 'int'}}
552 #pragma omp simd aligned(x, y)
553 for (i = 0; i < 16; ++i)
554 ;
555 // expected-error@+1 {{argument of aligned clause should be array or pointer, not 'int'}}
556 #pragma omp simd aligned(x, y, z)
557 for (i = 0; i < 16; ++i)
558 ;
559
560 // expected-note@+2 {{defined as aligned}}
561 // expected-error@+1 {{a variable cannot appear in more than one aligned clause}}
562 #pragma omp simd aligned(x) aligned(z, x)
563 for (i = 0; i < 16; ++i)
564 ;
565
566 // expected-note@+3 {{defined as aligned}}
567 // expected-error@+2 {{a variable cannot appear in more than one aligned clause}}
568 // expected-error@+1 2 {{argument of aligned clause should be array or pointer, not 'int'}}
569 #pragma omp simd aligned(x, y, z) aligned(y, z)
570 for (i = 0; i < 16; ++i)
571 ;
572 }
573
test_private()574 void test_private() {
575 int i;
576 // expected-error@+2 {{expected expression}}
577 // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
578 #pragma omp simd private(
579 for (i = 0; i < 16; ++i)
580 ;
581 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
582 // expected-error@+1 2 {{expected expression}}
583 #pragma omp simd private(,
584 for (i = 0; i < 16; ++i)
585 ;
586 // expected-error@+1 2 {{expected expression}}
587 #pragma omp simd private(, )
588 for (i = 0; i < 16; ++i)
589 ;
590 // expected-error@+1 {{expected expression}}
591 #pragma omp simd private()
592 for (i = 0; i < 16; ++i)
593 ;
594 // expected-error@+1 {{expected expression}}
595 #pragma omp simd private(int)
596 for (i = 0; i < 16; ++i)
597 ;
598 // expected-error@+1 {{expected variable name}}
599 #pragma omp simd private(0)
600 for (i = 0; i < 16; ++i)
601 ;
602
603 int x, y, z;
604 #pragma omp simd private(x)
605 for (i = 0; i < 16; ++i)
606 ;
607 #pragma omp simd private(x, y)
608 for (i = 0; i < 16; ++i)
609 ;
610 #pragma omp simd private(x, y, z)
611 for (i = 0; i < 16; ++i) {
612 x = y * i + z;
613 }
614 }
615
test_firstprivate()616 void test_firstprivate() {
617 int i;
618 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
619 // expected-error@+2 {{unexpected OpenMP clause 'firstprivate' in directive '#pragma omp simd'}}
620 // expected-error@+1 {{expected expression}}
621 #pragma omp simd firstprivate(
622 for (i = 0; i < 16; ++i)
623 ;
624 }
625
test_lastprivate()626 void test_lastprivate() {
627 int i;
628 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
629 // expected-error@+1 {{expected expression}}
630 #pragma omp simd lastprivate(
631 for (i = 0; i < 16; ++i)
632 ;
633
634 // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}}
635 // expected-error@+1 2 {{expected expression}}
636 #pragma omp simd lastprivate(,
637 for (i = 0; i < 16; ++i)
638 ;
639 // expected-error@+1 2 {{expected expression}}
640 #pragma omp simd lastprivate(, )
641 for (i = 0; i < 16; ++i)
642 ;
643 // expected-error@+1 {{expected expression}}
644 #pragma omp simd lastprivate()
645 for (i = 0; i < 16; ++i)
646 ;
647 // expected-error@+1 {{expected expression}}
648 #pragma omp simd lastprivate(int)
649 for (i = 0; i < 16; ++i)
650 ;
651 // expected-error@+1 {{expected variable name}}
652 #pragma omp simd lastprivate(0)
653 for (i = 0; i < 16; ++i)
654 ;
655
656 int x, y, z;
657 #pragma omp simd lastprivate(x)
658 for (i = 0; i < 16; ++i)
659 ;
660 #pragma omp simd lastprivate(x, y)
661 for (i = 0; i < 16; ++i)
662 ;
663 #pragma omp simd lastprivate(x, y, z)
664 for (i = 0; i < 16; ++i)
665 ;
666 }
667
test_reduction()668 void test_reduction() {
669 int i, x, y;
670 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
671 // expected-error@+2 {{expected identifier}}
672 // expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
673 #pragma omp simd reduction(
674 for (i = 0; i < 16; ++i)
675 ;
676 // expected-error@+2 {{expected identifier}}
677 // expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
678 #pragma omp simd reduction()
679 for (i = 0; i < 16; ++i)
680 ;
681 // expected-error@+2 {{expected expression}}
682 // expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
683 #pragma omp simd reduction(x)
684 for (i = 0; i < 16; ++i)
685 ;
686 // expected-error@+1 {{expected identifier}}
687 #pragma omp simd reduction( : x)
688 for (i = 0; i < 16; ++i)
689 ;
690 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
691 // expected-error@+2 {{expected identifier}}
692 // expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
693 #pragma omp simd reduction(,
694 for (i = 0; i < 16; ++i)
695 ;
696 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
697 // expected-error@+2 {{expected expression}}
698 // expected-warning@+1 {{missing ':' after reduction identifier - ignoring}}
699 #pragma omp simd reduction(+
700 for (i = 0; i < 16; ++i)
701 ;
702
703 // expected-error@+3 {{expected ')'}} expected-note@+3 {{to match this '('}}
704 //
705 // expected-error@+1 {{expected expression}}
706 #pragma omp simd reduction(+:
707 for (i = 0; i < 16; ++i)
708 ;
709 // expected-error@+1 {{expected expression}}
710 #pragma omp simd reduction(+ :)
711 for (i = 0; i < 16; ++i)
712 ;
713 // expected-error@+1 {{expected expression}}
714 #pragma omp simd reduction(+ :, y)
715 for (i = 0; i < 16; ++i)
716 ;
717 // expected-error@+1 {{expected expression}}
718 #pragma omp simd reduction(+ : x, + : y)
719 for (i = 0; i < 16; ++i)
720 ;
721 // expected-error@+1 {{expected identifier}}
722 #pragma omp simd reduction(% : x)
723 for (i = 0; i < 16; ++i)
724 ;
725
726 #pragma omp simd reduction(+ : x)
727 for (i = 0; i < 16; ++i)
728 ;
729 #pragma omp simd reduction(* : x)
730 for (i = 0; i < 16; ++i)
731 ;
732 #pragma omp simd reduction(- : x)
733 for (i = 0; i < 16; ++i)
734 ;
735 #pragma omp simd reduction(& : x)
736 for (i = 0; i < 16; ++i)
737 ;
738 #pragma omp simd reduction(| : x)
739 for (i = 0; i < 16; ++i)
740 ;
741 #pragma omp simd reduction(^ : x)
742 for (i = 0; i < 16; ++i)
743 ;
744 #pragma omp simd reduction(&& : x)
745 for (i = 0; i < 16; ++i)
746 ;
747 #pragma omp simd reduction(|| : x)
748 for (i = 0; i < 16; ++i)
749 ;
750 #pragma omp simd reduction(max : x)
751 for (i = 0; i < 16; ++i)
752 ;
753 #pragma omp simd reduction(min : x)
754 for (i = 0; i < 16; ++i)
755 ;
756 struct X {
757 int x;
758 };
759 struct X X;
760 // expected-error@+1 {{expected variable name}}
761 #pragma omp simd reduction(+ : X.x)
762 for (i = 0; i < 16; ++i)
763 ;
764 // expected-error@+1 {{expected variable name}}
765 #pragma omp simd reduction(+ : x + x)
766 for (i = 0; i < 16; ++i)
767 ;
768 }
769
test_loop_messages()770 void test_loop_messages() {
771 float a[100], b[100], c[100];
772 // expected-error@+2 {{variable must be of integer or pointer type}}
773 #pragma omp simd
774 for (float fi = 0; fi < 10.0; fi++) {
775 c[(int)fi] = a[(int)fi] + b[(int)fi];
776 }
777 // expected-error@+2 {{variable must be of integer or pointer type}}
778 #pragma omp simd
779 for (double fi = 0; fi < 10.0; fi++) {
780 c[(int)fi] = a[(int)fi] + b[(int)fi];
781 }
782 }
783
linear_modifiers(int argc)784 void linear_modifiers(int argc) {
785 int f;
786 #pragma omp simd linear(f)
787 for (int k = 0; k < argc; ++k) ++k;
788 #pragma omp simd linear(val(f))
789 for (int k = 0; k < argc; ++k) ++k;
790 #pragma omp simd linear(uval(f)) // expected-error {{expected 'val' modifier}}
791 for (int k = 0; k < argc; ++k) ++k;
792 #pragma omp simd linear(ref(f)) // expected-error {{expected 'val' modifier}}
793 for (int k = 0; k < argc; ++k) ++k;
794 #pragma omp simd linear(foo(f)) // expected-error {{expected 'val' modifier}}
795 for (int k = 0; k < argc; ++k) ++k;
796 }
797
798