1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp45 %s -Wno-openmp-mapping -Wuninitialized
2 // RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp50 %s -Wno-openmp-mapping -Wuninitialized
3 // RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp51 %s -Wno-openmp-mapping -Wuninitialized
5 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp45 %s -Wno-openmp-mapping -Wuninitialized
6 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp50 %s -Wno-openmp-mapping -Wuninitialized
7 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp51 %s -Wno-openmp-mapping -Wuninitialized
15 S(const S
&s
) : a(s
.a
) {}
19 // expected-note@+1 {{defined as threadprivate or thread local}}
20 #pragma omp threadprivate(sii)
23 int test_iteration_spaces() {
25 float a
[N
], b
[N
], c
[N
];
29 #pragma omp target parallel for simd
30 for (int i
= 0; i
< 10; i
+= 1) {
33 #pragma omp target parallel for simd
34 for (char i
= 0; i
< 10; i
++) {
37 #pragma omp target parallel for simd
38 for (char i
= 0; i
< 10; i
+= '\1') {
41 #pragma omp target parallel for simd
42 for (long long i
= 0; i
< 10; i
++) {
45 // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'double'}}
46 #pragma omp target parallel for simd
47 for (long long i
= 0; i
< 10; i
+= 1.5) {
50 #pragma omp target parallel for simd
51 for (long long i
= 0; i
< 'z'; i
+= 1u) {
54 // expected-error@+2 {{variable must be of integer or random access iterator type}}
55 #pragma omp target parallel for simd
56 for (float fi
= 0; fi
< 10.0; fi
++) {
57 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
59 // expected-error@+2 {{variable must be of integer or random access iterator type}}
60 #pragma omp target parallel for simd
61 for (double fi
= 0; fi
< 10.0; fi
++) {
62 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
64 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
65 #pragma omp target parallel for simd
66 for (int &ref
= ii
; ref
< 10; ref
++) {
68 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
69 #pragma omp target parallel for simd
70 for (int i
; i
< 10; i
++)
73 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
74 #pragma omp target parallel for simd
75 for (int i
= 0, j
= 0; i
< 10; ++i
)
78 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
79 #pragma omp target parallel for simd
83 // expected-warning@+3 {{expression result unused}}
84 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
85 #pragma omp target parallel for simd
86 for (ii
+ 1; ii
< 10; ++ii
)
89 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
90 #pragma omp target parallel for simd
91 for (c
[ii
] = 0; ii
< 10; ++ii
)
94 // Ok to skip parenthesises.
95 #pragma omp target parallel for simd
96 for (((ii
)) = 0; ii
< 10; ++ii
)
99 // omp45-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp50-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}} omp51-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
100 #pragma omp target parallel for simd
101 for (int i
= 0; i
; i
++)
104 // omp45-error@+3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp50-error@+3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}} omp51-error@+3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
105 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}}
106 #pragma omp target parallel for simd
107 for (int i
= 0; jj
< kk
; ii
++)
110 // omp45-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp50-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}} omp51-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
111 #pragma omp target parallel for simd
112 for (int i
= 0; !!i
; i
++)
115 // omp45-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
116 #pragma omp target parallel for simd
117 for (int i
= 0; i
!= 1; i
++)
120 // omp45-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp50-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}} omp51-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
121 #pragma omp target parallel for simd
122 for (int i
= 0;; i
++)
126 #pragma omp target parallel for simd
127 for (int i
= 11; i
> 10; i
--)
131 #pragma omp target parallel for simd
132 for (int i
= 0; i
< 10; ++i
)
136 #pragma omp target parallel for simd
137 for (ii
= 0; ii
< 10; ++ii
)
140 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
141 #pragma omp target parallel for simd
142 for (ii
= 0; ii
< 10; ++jj
)
145 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
146 #pragma omp target parallel for simd
147 for (ii
= 0; ii
< 10; ++++ii
)
150 // Ok but undefined behavior (in general, cannot check that incr
151 // is really loop-invariant).
152 #pragma omp target parallel for simd
153 for (ii
= 0; ii
< 10; ii
= ii
+ ii
)
156 // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'float'}}
157 #pragma omp target parallel for simd
158 for (ii
= 0; ii
< 10; ii
= ii
+ 1.0f
)
161 // Ok - step was converted to integer type.
162 #pragma omp target parallel for simd
163 for (ii
= 0; ii
< 10; ii
= ii
+ (int)1.1f
)
166 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
167 #pragma omp target parallel for simd
168 for (ii
= 0; ii
< 10; jj
= ii
+ 2)
171 // expected-warning@+3 {{relational comparison result unused}}
172 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
173 #pragma omp target parallel for simd
174 for (ii
= 0; ii
<10; jj
> kk
+ 2)
177 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
178 #pragma omp target parallel for simd
179 for (ii
= 0; ii
< 10;)
182 // expected-warning@+3 {{expression result unused}}
183 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
184 #pragma omp target parallel for simd
185 for (ii
= 0; ii
< 10; !ii
)
188 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
189 #pragma omp target parallel for simd
190 for (ii
= 0; ii
< 10; ii
? ++ii
: ++jj
)
193 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
194 #pragma omp target parallel for simd
195 for (ii
= 0; ii
< 10; ii
= ii
< 10)
198 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
199 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
200 #pragma omp target parallel for simd
201 for (ii
= 0; ii
< 10; ii
= ii
+ 0)
204 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
205 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
206 #pragma omp target parallel for simd
207 for (ii
= 0; ii
< 10; ii
= ii
+ (int)(0.8 - 0.45))
210 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
211 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
212 #pragma omp target parallel for simd
213 for (ii
= 0; (ii
) < 10; ii
-= 25)
216 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
217 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
218 #pragma omp target parallel for simd
219 for (ii
= 0; (ii
< 10); ii
-= 0)
222 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
223 // expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
224 #pragma omp target parallel for simd
225 for (ii
= 0; ii
> 10; (ii
+= 0))
228 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
229 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
230 #pragma omp target parallel for simd
231 for (ii
= 0; ii
< 10; (ii
) = (1 - 1) + (ii
))
234 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
235 // expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
236 #pragma omp target parallel for simd
237 for ((ii
= 0); ii
> 10; (ii
-= 0))
240 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
241 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
242 #pragma omp target parallel for simd
243 for (ii
= 0; (ii
< 10); (ii
-= 0))
246 // expected-note@+2 {{defined as firstprivate}}
247 // expected-error@+2 {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be firstprivate, predetermined as linear}}
248 #pragma omp target parallel for simd firstprivate(ii)
249 for (ii
= 0; ii
< 10; ii
++)
252 #pragma omp target parallel for simd linear(ii)
253 for (ii
= 0; ii
< 10; ii
++)
256 // omp45-note@+2 {{defined as private}}
257 // omp45-error@+2 {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be private, predetermined as linear}}
258 #pragma omp target parallel for simd private(ii)
259 for (ii
= 0; ii
< 10; ii
++)
262 // omp45-note@+2 {{defined as lastprivate}}
263 // omp45-error@+2 {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be lastprivate, predetermined as linear}}
264 #pragma omp target parallel for simd lastprivate(ii)
265 for (ii
= 0; ii
< 10; ii
++)
269 // expected-error@+2 {{loop iteration variable in the associated loop of 'omp target parallel for simd' directive may not be threadprivate or thread local, predetermined as linear}}
270 #pragma omp target parallel for simd
271 for (sii
= 0; sii
< 10; sii
+= 1)
276 #pragma omp target parallel for simd
277 for (globalii
= 0; globalii
< 10; globalii
+= 1)
278 c
[globalii
] = a
[globalii
];
282 #pragma omp target parallel for simd collapse(2)
283 for (ii
= 0; ii
< 10; ii
+= 1)
284 for (globalii
= 0; globalii
< 10; globalii
+= 1)
285 c
[globalii
] += a
[globalii
] + ii
;
288 // omp45-error@+2 {{statement after '#pragma omp target parallel for simd' must be a for loop}}
289 #pragma omp target parallel for simd
290 for (auto &item
: a
) {
294 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
295 // expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
296 #pragma omp target parallel for simd
297 for (unsigned i
= 9; i
< 10; i
--) {
301 int(*lb
)[4] = nullptr;
302 #pragma omp target parallel for simd
303 for (int(*p
)[4] = lb
; p
< lb
+ 8; ++p
) {
306 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
307 #pragma omp target parallel for simd
308 for (int a
{0}; a
< 10; ++a
) {
314 // Iterators allowed in openmp for-loops.
316 struct random_access_iterator_tag
{};
317 template <class Iter
>
318 struct iterator_traits
{
319 typedef typename
Iter::difference_type difference_type
;
320 typedef typename
Iter::iterator_category iterator_category
;
322 template <class Iter
>
323 typename iterator_traits
<Iter
>::difference_type
324 distance(Iter first
, Iter last
) { return first
- last
; }
329 Iter0(const Iter0
&) {}
330 Iter0
operator++() { return *this; }
331 Iter0
operator--() { return *this; }
332 bool operator<(Iter0 a
) { return true; }
334 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
335 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
336 int operator-(Iter0 a
, Iter0 b
) { return 0; }
339 Iter1(float f
= 0.0f
, double d
= 0.0) {}
340 Iter1(const Iter1
&) {}
341 Iter1
operator++() { return *this; }
342 Iter1
operator--() { return *this; }
343 bool operator<(Iter1 a
) { return true; }
344 bool operator>=(Iter1 a
) { return false; }
349 GoodIter(const GoodIter
&) {}
350 GoodIter(int fst
, int snd
) {}
351 GoodIter
&operator=(const GoodIter
&that
) { return *this; }
352 GoodIter
&operator=(const Iter0
&that
) { return *this; }
353 GoodIter
&operator+=(int x
) { return *this; }
354 GoodIter
&operator-=(int x
) { return *this; }
355 explicit GoodIter(void *) {}
356 GoodIter
operator++() { return *this; }
357 GoodIter
operator--() { return *this; }
358 bool operator!() { return true; }
359 bool operator<(GoodIter a
) { return true; }
360 bool operator<=(GoodIter a
) { return true; }
361 bool operator>=(GoodIter a
) { return false; }
362 typedef int difference_type
;
363 typedef std::random_access_iterator_tag iterator_category
;
365 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
366 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
367 int operator-(GoodIter a
, GoodIter b
) { return 0; }
368 // expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
369 GoodIter
operator-(GoodIter a
) { return a
; }
370 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
371 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
372 GoodIter
operator-(GoodIter a
, int v
) { return GoodIter(); }
373 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
374 GoodIter
operator+(GoodIter a
, int v
) { return GoodIter(); }
375 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
376 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
377 GoodIter
operator-(int v
, GoodIter a
) { return GoodIter(); }
378 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
379 GoodIter
operator+(int v
, GoodIter a
) { return GoodIter(); }
381 int test_with_random_access_iterator() {
384 #pragma omp target parallel for simd
385 for (GoodIter I
= begin
; I
< end
; ++I
)
387 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
388 #pragma omp target parallel for simd
389 for (GoodIter
&I
= begin
; I
< end
; ++I
)
391 #pragma omp target parallel for simd
392 for (GoodIter I
= begin
; I
>= end
; --I
)
394 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
395 #pragma omp target parallel for simd
396 for (GoodIter
I(begin
); I
< end
; ++I
)
398 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
399 #pragma omp target parallel for simd
400 for (GoodIter
I(nullptr); I
< end
; ++I
)
402 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
403 #pragma omp target parallel for simd
404 for (GoodIter
I(0); I
< end
; ++I
)
406 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
407 #pragma omp target parallel for simd
408 for (GoodIter
I(1, 2); I
< end
; ++I
)
410 #pragma omp target parallel for simd
411 for (begin
= GoodIter(0); begin
< end
; ++begin
)
413 // expected-error@+3 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
414 // expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
415 #pragma omp target parallel for simd
416 for (begin
= begin0
; begin
< end
; ++begin
)
418 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
419 #pragma omp target parallel for simd
420 for (++begin
; begin
< end
; ++begin
)
422 #pragma omp target parallel for simd
423 for (begin
= end
; begin
< end
; ++begin
)
425 // omp45-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp50-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}} omp51-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}
426 #pragma omp target parallel for simd
427 for (GoodIter I
= begin
; I
- I
; ++I
)
429 // omp45-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp50-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}} omp51-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}
430 #pragma omp target parallel for simd
431 for (GoodIter I
= begin
; begin
< end
; ++I
)
433 // omp45-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp50-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}} omp51-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}
434 #pragma omp target parallel for simd
435 for (GoodIter I
= begin
; !I
; ++I
)
437 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
438 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
439 #pragma omp target parallel for simd
440 for (GoodIter I
= begin
; I
>= end
; I
= I
+ 1)
442 #pragma omp target parallel for simd
443 for (GoodIter I
= begin
; I
>= end
; I
= I
- 1)
445 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
446 #pragma omp target parallel for simd
447 for (GoodIter I
= begin
; I
>= end
; I
= -I
)
449 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
450 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
451 #pragma omp target parallel for simd
452 for (GoodIter I
= begin
; I
>= end
; I
= 2 + I
)
454 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
455 #pragma omp target parallel for simd
456 for (GoodIter I
= begin
; I
>= end
; I
= 2 - I
)
458 // expected-error@+2 {{invalid operands to binary expression ('Iter0' and 'int')}}
459 #pragma omp target parallel for simd
460 for (Iter0 I
= begin0
; I
< end0
; ++I
)
462 // Initializer is constructor without params.
463 // expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
464 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
465 #pragma omp target parallel for simd
466 for (Iter0 I
; I
< end0
; ++I
)
469 // expected-error@+3 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
470 // expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
471 #pragma omp target parallel for simd
472 for (Iter1 I
= begin1
; I
< end1
; ++I
)
474 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
475 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
476 #pragma omp target parallel for simd
477 for (Iter1 I
= begin1
; I
>= end1
; ++I
)
479 // expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'float')}}
480 // expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
481 // Initializer is constructor with all default params.
482 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
483 #pragma omp target parallel for simd
484 for (Iter1 I
; I
< end1
; ++I
) {
489 template <typename IT
, int ST
>
492 int dotest_lt(IT begin
, IT end
) {
493 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
494 // expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
495 #pragma omp target parallel for simd
496 for (IT I
= begin
; I
< end
; I
= I
+ ST
) {
499 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
500 // expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
501 #pragma omp target parallel for simd
502 for (IT I
= begin
; I
<= end
; I
+= ST
) {
505 #pragma omp target parallel for simd
506 for (IT I
= begin
; I
< end
; ++I
) {
515 template <typename IT
, int ST
= 0>
516 int dotest_gt(IT begin
, IT end
) {
517 // expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
518 // expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
519 #pragma omp target parallel for simd
520 for (IT I
= begin
; I
>= end
; I
= I
+ ST
) {
523 // expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
524 // expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
525 #pragma omp target parallel for simd
526 for (IT I
= begin
; I
>= end
; I
+= ST
) {
530 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
531 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
532 #pragma omp target parallel for simd
533 for (IT I
= begin
; I
>= end
; ++I
) {
537 #pragma omp target parallel for simd
538 for (IT I
= begin
; I
< end
; I
+= TC
<int, ST
>::step()) {
543 void test_with_template() {
545 TC
<GoodIter
, 100> t1
;
546 TC
<GoodIter
, -100> t2
;
547 t1
.dotest_lt(begin
, end
);
548 t2
.dotest_lt(begin
, end
); // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
549 dotest_gt(begin
, end
); // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
550 dotest_gt
<unsigned, 10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, 10>' requested here}}
553 void test_loop_break() {
555 float a
[N
], b
[N
], c
[N
];
556 #pragma omp target parallel for simd
557 for (int i
= 0; i
< 10; i
++) {
559 for (int j
= 0; j
< 10; ++j
) {
561 break; // OK in nested loop
571 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
574 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
577 #pragma omp target parallel for simd
578 for (int i
= 0; i
< 10; i
++) {
579 for (int j
= 0; j
< 10; j
++) {
590 void test_loop_eh() {
592 float a
[N
], b
[N
], c
[N
];
593 #pragma omp target parallel for simd
594 for (int i
= 0; i
< 10; i
++) {
596 try { // expected-error {{'try' statement cannot be used in OpenMP simd region}}
597 for (int j
= 0; j
< 10; ++j
) {
599 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
601 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
604 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
605 return; // expected-error {{cannot return from OpenMP region}}
614 for (int j
= 0; j
< 10; j
++) {
616 throw c
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
622 #pragma omp target parallel for simd
623 for (int i
= 0; i
< 10; ++i
) {
625 void g() { throw 0; }
630 void test_loop_firstprivate_lastprivate() {
632 #pragma omp target parallel for simd lastprivate(s) firstprivate(s)
633 for (int i
= 0; i
< 16; ++i
)
635 #pragma omp target parallel for simd order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for simd'}} expected-error {{expected '(' after 'order'}}
636 for (int i
= 0; i
< 10; ++i
)
638 #pragma omp target parallel for simd order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} omp51-error {{expected 'concurrent' in OpenMP clause 'order'}}
639 for (int i
= 0; i
< 10; ++i
)
641 #pragma omp target parallel for simd order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} omp51-error {{expected 'concurrent' in OpenMP clause 'order'}}
642 for (int i
= 0; i
< 10; ++i
)
644 #pragma omp target parallel for simd order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
645 for (int i
= 0; i
< 10; ++i
)
647 #pragma omp target parallel for simd order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for simd'}}
648 for (int i
= 0; i
< 10; ++i
)
650 #pragma omp target parallel for simd order(unconstrained:) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for simd'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} omp51-error {{expected 'concurrent' in OpenMP clause 'order'}}
651 for (int i
= 0; i
< 10; ++i
)
653 #pragma omp target parallel for simd order(reproducible:concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
654 for (int i
= 0; i
< 10; ++i
)
656 #pragma omp target parallel for simd order(reproducible:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for simd'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
657 for (int i
= 0; i
< 10; ++i
)
659 #pragma omp target parallel for simd order(unconstrained:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for simd'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
660 for (int i
= 0; i
< 10; ++i
)
662 #pragma omp target parallel for simd order(concurrent) order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for simd'}} omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target parallel for simd'}} omp51-error {{directive '#pragma omp target parallel for simd' cannot contain more than one 'order' clause}}
663 for (int i
= 0; i
< 10; ++i
)