1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp4 %s -Wno-openmp-mapping -Wuninitialized
2 // RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp5 %s -Wno-openmp-mapping -Wuninitialized
4 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp4 %s -Wno-openmp-mapping -Wuninitialized
5 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp5 %s -Wno-openmp-mapping -Wuninitialized
9 S() : a(0) {} // expected-note {{implicitly declared private here}}
13 S(const S
&s
) : a(s
.a
) {}
17 // expected-note@+1 {{defined as threadprivate or thread local}}
18 #pragma omp threadprivate(sii)
21 int test_iteration_spaces() {
23 float a
[N
], b
[N
], c
[N
];
27 #pragma omp target teams distribute parallel for
28 for (int i
= 0; i
< 10; i
+= 1) {
31 #pragma omp target teams distribute parallel for
32 for (char i
= 0; i
< 10; i
++) {
35 #pragma omp target teams distribute parallel for
36 for (char i
= 0; i
< 10; i
+= '\1') {
39 #pragma omp target teams distribute parallel for
40 for (long long i
= 0; i
< 10; i
++) {
43 #pragma omp target teams distribute parallel for
44 // expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'double'}}
45 for (long long i
= 0; i
< 10; i
+= 1.5) {
48 #pragma omp target teams distribute parallel for
49 for (long long i
= 0; i
< 'z'; i
+= 1u) {
52 #pragma omp target teams distribute parallel for
53 // expected-error@+1 {{variable must be of integer or random access iterator type}}
54 for (float fi
= 0; fi
< 10.0; fi
++) {
55 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
57 #pragma omp target teams distribute parallel for
58 // expected-error@+1 {{variable must be of integer or random access iterator type}}
59 for (double fi
= 0; fi
< 10.0; fi
++) {
60 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
62 #pragma omp target teams distribute parallel for
63 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
64 for (int &ref
= ii
; ref
< 10; ref
++) {
66 #pragma omp target teams distribute parallel for
67 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
68 for (int i
; i
< 10; i
++)
71 #pragma omp target teams distribute parallel for
72 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
73 for (int i
= 0, j
= 0; i
< 10; ++i
)
76 #pragma omp target teams distribute parallel for
77 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
81 #pragma omp target teams distribute parallel for
82 // expected-warning@+2 {{expression result unused}}
83 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
84 for (ii
+ 1; ii
< 10; ++ii
)
87 #pragma omp target teams distribute parallel for
88 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
89 for (c
[ii
] = 0; ii
< 10; ++ii
)
92 #pragma omp target teams distribute parallel for
93 // Ok to skip parenthesises.
94 for (((ii
)) = 0; ii
< 10; ++ii
)
97 #pragma omp target teams distribute parallel for
98 // omp4-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
99 for (int i
= 0; i
; i
++)
102 #pragma omp target teams distribute parallel for
103 // omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
104 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}}
105 for (int i
= 0; jj
< kk
; ii
++)
108 #pragma omp target teams distribute parallel for
109 // omp4-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
110 for (int i
= 0; !!i
; i
++)
113 // omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
114 #pragma omp target teams distribute parallel for
115 for (int i
= 0; i
!= 1; i
++)
118 #pragma omp target teams distribute parallel for
119 // omp4-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
120 for (int i
= 0;; i
++)
124 #pragma omp target teams distribute parallel for
125 for (int i
= 11; i
> 10; i
--)
129 #pragma omp target teams distribute parallel for
130 for (int i
= 0; i
< 10; ++i
)
134 #pragma omp target teams distribute parallel for
135 for (ii
= 0; ii
< 10; ++ii
)
138 #pragma omp target teams distribute parallel for
139 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
140 for (ii
= 0; ii
< 10; ++jj
)
143 #pragma omp target teams distribute parallel for
144 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
145 for (ii
= 0; ii
< 10; ++++ii
)
148 // Ok but undefined behavior (in general, cannot check that incr
149 // is really loop-invariant).
150 #pragma omp target teams distribute parallel for
151 for (ii
= 0; ii
< 10; ii
= ii
+ ii
)
154 #pragma omp target teams distribute parallel for
155 // expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'float'}}
156 for (ii
= 0; ii
< 10; ii
= ii
+ 1.0f
)
159 // Ok - step was converted to integer type.
160 #pragma omp target teams distribute parallel for
161 for (ii
= 0; ii
< 10; ii
= ii
+ (int)1.1f
)
164 #pragma omp target teams distribute parallel for
165 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
166 for (ii
= 0; ii
< 10; jj
= ii
+ 2)
169 #pragma omp target teams distribute parallel for
170 // expected-warning@+2 {{relational comparison result unused}}
171 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
172 for (ii
= 0; ii
<10; jj
> kk
+ 2)
175 #pragma omp target teams distribute parallel for
176 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
177 for (ii
= 0; ii
< 10;)
180 #pragma omp target teams distribute parallel for
181 // expected-warning@+2 {{expression result unused}}
182 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
183 for (ii
= 0; ii
< 10; !ii
)
186 #pragma omp target teams distribute parallel for
187 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
188 for (ii
= 0; ii
< 10; ii
? ++ii
: ++jj
)
191 #pragma omp target teams distribute parallel for
192 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
193 for (ii
= 0; ii
< 10; ii
= ii
< 10)
196 #pragma omp target teams distribute parallel for
197 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
198 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
199 for (ii
= 0; ii
< 10; ii
= ii
+ 0)
202 #pragma omp target teams distribute parallel for
203 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
204 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
205 for (ii
= 0; ii
< 10; ii
= ii
+ (int)(0.8 - 0.45))
208 #pragma omp target teams distribute parallel for
209 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
210 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
211 for (ii
= 0; (ii
) < 10; ii
-= 25)
214 #pragma omp target teams distribute parallel for
215 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
216 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
217 for (ii
= 0; (ii
< 10); ii
-= 0)
220 #pragma omp target teams distribute parallel for
221 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
222 // expected-error@+1 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
223 for (ii
= 0; ii
> 10; (ii
+= 0))
226 #pragma omp target teams distribute parallel for
227 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
228 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
229 for (ii
= 0; ii
< 10; (ii
) = (1 - 1) + (ii
))
232 #pragma omp target teams distribute parallel for
233 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
234 // expected-error@+1 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
235 for ((ii
= 0); ii
> 10; (ii
-= 0))
238 #pragma omp target teams distribute parallel for
239 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
240 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
241 for (ii
= 0; (ii
< 10); (ii
-= 0))
244 #pragma omp target teams distribute parallel for firstprivate(ii) // expected-note {{defined as firstprivate}}
245 // expected-error@+1 {{loop iteration variable in the associated loop of 'omp target teams distribute parallel for' directive may not be firstprivate, predetermined as private}}
246 for (ii
= 0; ii
< 10; ii
++)
249 #pragma omp target teams distribute parallel for private(ii) // OK
250 for (ii
= 0; ii
< 10; ii
++)
253 #pragma omp target teams distribute parallel for lastprivate(ii) // OK
254 for (ii
= 0; ii
< 10; ii
++)
257 #pragma omp target teams distribute parallel for
258 // expected-error@+1 {{loop iteration variable in the associated loop of 'omp target teams distribute parallel for' directive may not be threadprivate or thread local, predetermined as private}}
259 for (sii
= 0; sii
< 10; sii
++)
263 #pragma omp target teams distribute parallel for collapse(2)
264 for (ii
= 0; ii
< 10; ii
+= 1)
265 for (globalii
= 0; globalii
< 10; globalii
+= 1)
266 c
[globalii
] += a
[globalii
] + ii
;
269 #pragma omp target teams distribute parallel for
270 // omp4-error@+1 {{statement after '#pragma omp target teams distribute parallel for' must be a for loop}}
271 for (auto &item
: a
) {
275 #pragma omp target teams distribute parallel for
276 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
277 // expected-error@+1 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
278 for (unsigned i
= 9; i
< 10; i
--) {
282 int(*lb
)[4] = nullptr;
283 #pragma omp target teams distribute parallel for
284 for (int(*p
)[4] = lb
; p
< lb
+ 8; ++p
) {
287 #pragma omp target teams distribute parallel for
288 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
289 for (int a
{0}; a
< 10; ++a
) {
295 // Iterators allowed in openmp for-loops.
297 struct random_access_iterator_tag
{};
298 template <class Iter
>
299 struct iterator_traits
{
300 typedef typename
Iter::difference_type difference_type
;
301 typedef typename
Iter::iterator_category iterator_category
;
303 template <class Iter
>
304 typename iterator_traits
<Iter
>::difference_type
305 distance(Iter first
, Iter last
) { return first
- last
; }
310 Iter0(const Iter0
&) {}
311 Iter0
operator++() { return *this; }
312 Iter0
operator--() { return *this; }
313 bool operator<(Iter0 a
) { return true; }
315 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
316 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
317 int operator-(Iter0 a
, Iter0 b
) { return 0; }
320 Iter1(float f
= 0.0f
, double d
= 0.0) {}
321 Iter1(const Iter1
&) {}
322 Iter1
operator++() { return *this; }
323 Iter1
operator--() { return *this; }
324 bool operator<(Iter1 a
) { return true; }
325 bool operator>=(Iter1 a
) { return false; }
330 GoodIter(const GoodIter
&) {}
331 GoodIter(int fst
, int snd
) {}
332 GoodIter
&operator=(const GoodIter
&that
) { return *this; }
333 GoodIter
&operator=(const Iter0
&that
) { return *this; }
334 GoodIter
&operator+=(int x
) { return *this; }
335 explicit GoodIter(void *) {}
336 GoodIter
operator++() { return *this; }
337 GoodIter
operator--() { return *this; }
338 bool operator!() { return true; }
339 bool operator<(GoodIter a
) { return true; }
340 bool operator<=(GoodIter a
) { return true; }
341 bool operator>=(GoodIter a
) { return false; }
342 typedef int difference_type
;
343 typedef std::random_access_iterator_tag iterator_category
;
345 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
346 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
347 int operator-(GoodIter a
, GoodIter b
) { return 0; }
348 // expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
349 GoodIter
operator-(GoodIter a
) { return a
; }
350 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
351 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
352 GoodIter
operator-(GoodIter a
, int v
) { return GoodIter(); }
353 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
354 GoodIter
operator+(GoodIter a
, int v
) { return GoodIter(); }
355 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
356 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
357 GoodIter
operator-(int v
, GoodIter a
) { return GoodIter(); }
358 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
359 GoodIter
operator+(int v
, GoodIter a
) { return GoodIter(); }
361 int test_with_random_access_iterator() {
364 #pragma omp target teams distribute parallel for
365 for (GoodIter I
= begin
; I
< end
; ++I
)
367 #pragma omp target teams distribute parallel for
368 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
369 for (GoodIter
&I
= begin
; I
< end
; ++I
)
371 #pragma omp target teams distribute parallel for
372 for (GoodIter I
= begin
; I
>= end
; --I
)
374 #pragma omp target teams distribute parallel for
375 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
376 for (GoodIter
I(begin
); I
< end
; ++I
)
378 #pragma omp target teams distribute parallel for
379 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
380 for (GoodIter
I(nullptr); I
< end
; ++I
)
382 #pragma omp target teams distribute parallel for
383 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
384 for (GoodIter
I(0); I
< end
; ++I
)
386 #pragma omp target teams distribute parallel for
387 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
388 for (GoodIter
I(1, 2); I
< end
; ++I
)
390 #pragma omp target teams distribute parallel for
391 for (begin
= GoodIter(0); begin
< end
; ++begin
)
393 #pragma omp target teams distribute parallel for
394 // expected-error@+2 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
395 // expected-error@+1 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
396 for (begin
= begin0
; begin
< end
; ++begin
)
398 #pragma omp target teams distribute parallel for
399 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
400 for (++begin
; begin
< end
; ++begin
)
402 #pragma omp target teams distribute parallel for
403 for (begin
= end
; begin
< end
; ++begin
)
405 #pragma omp target teams distribute parallel for
406 // omp4-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp5-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}
407 for (GoodIter I
= begin
; I
- I
; ++I
)
409 #pragma omp target teams distribute parallel for
410 // omp4-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp5-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}
411 for (GoodIter I
= begin
; begin
< end
; ++I
)
413 #pragma omp target teams distribute parallel for
414 // omp4-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp5-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}
415 for (GoodIter I
= begin
; !I
; ++I
)
417 #pragma omp target teams distribute parallel for
418 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
419 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
420 for (GoodIter I
= begin
; I
>= end
; I
= I
+ 1)
422 #pragma omp target teams distribute parallel for
423 for (GoodIter I
= begin
; I
>= end
; I
= I
- 1)
425 #pragma omp target teams distribute parallel for
426 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
427 for (GoodIter I
= begin
; I
>= end
; I
= -I
)
429 #pragma omp target teams distribute parallel for
430 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
431 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
432 for (GoodIter I
= begin
; I
>= end
; I
= 2 + I
)
434 #pragma omp target teams distribute parallel for
435 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
436 for (GoodIter I
= begin
; I
>= end
; I
= 2 - I
)
438 #pragma omp target teams distribute parallel for
439 // expected-error@+1 {{invalid operands to binary expression ('Iter0' and 'int')}}
440 for (Iter0 I
= begin0
; I
< end0
; ++I
)
442 #pragma omp target teams distribute parallel for
443 // Initializer is constructor without params.
444 // expected-error@+2 {{invalid operands to binary expression ('Iter0' and 'int')}}
445 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
446 for (Iter0 I
; I
< end0
; ++I
)
449 #pragma omp target teams distribute parallel for
450 // expected-error@+2 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
451 // expected-error@+1 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
452 for (Iter1 I
= begin1
; I
< end1
; ++I
)
454 #pragma omp target teams distribute parallel for
455 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
456 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
457 for (Iter1 I
= begin1
; I
>= end1
; ++I
)
459 #pragma omp target teams distribute parallel for
460 // expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'float')}}
461 // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
462 // Initializer is constructor with all default params.
463 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
464 for (Iter1 I
; I
< end1
; ++I
) {
469 template <typename IT
, int ST
>
472 int dotest_lt(IT begin
, IT end
) {
473 #pragma omp target teams distribute parallel for
474 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
475 // expected-error@+1 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
476 for (IT I
= begin
; I
< end
; I
= I
+ ST
) {
479 #pragma omp target teams distribute parallel for
480 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
481 // expected-error@+1 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
482 for (IT I
= begin
; I
<= end
; I
+= ST
) {
485 #pragma omp target teams distribute parallel for
486 for (IT I
= begin
; I
< end
; ++I
) {
495 template <typename IT
, int ST
= 0>
496 int dotest_gt(IT begin
, IT end
) {
497 #pragma omp target teams distribute parallel for
498 // expected-note@+2 2 {{loop step is expected to be negative due to this condition}}
499 // expected-error@+1 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
500 for (IT I
= begin
; I
>= end
; I
= I
+ ST
) {
503 #pragma omp target teams distribute parallel for
504 // expected-note@+2 2 {{loop step is expected to be negative due to this condition}}
505 // expected-error@+1 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
506 for (IT I
= begin
; I
>= end
; I
+= ST
) {
510 #pragma omp target teams distribute parallel for
511 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
512 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
513 for (IT I
= begin
; I
>= end
; ++I
) {
517 #pragma omp target teams distribute parallel for
518 for (IT I
= begin
; I
< end
; I
+= TC
<int, ST
>::step()) {
523 void test_with_template() {
525 TC
<GoodIter
, 100> t1
;
526 TC
<GoodIter
, -100> t2
;
527 t1
.dotest_lt(begin
, end
);
528 t2
.dotest_lt(begin
, end
); // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
529 dotest_gt(begin
, end
); // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
530 dotest_gt
<unsigned, 10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, 10>' requested here}}
533 void test_loop_break() {
535 float a
[N
], b
[N
], c
[N
];
536 #pragma omp target teams distribute parallel for
537 for (int i
= 0; i
< 10; i
++) {
539 for (int j
= 0; j
< 10; ++j
) {
541 break; // OK in nested loop
551 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
554 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
557 #pragma omp target teams distribute parallel for
558 for (int i
= 0; i
< 10; i
++) {
559 for (int j
= 0; j
< 10; j
++) {
570 void test_loop_eh() {
572 float a
[N
], b
[N
], c
[N
];
573 #pragma omp target teams distribute parallel for
574 for (int i
= 0; i
< 10; i
++) {
577 for (int j
= 0; j
< 10; ++j
) {
585 return; // expected-error {{cannot return from OpenMP region}}
594 for (int j
= 0; j
< 10; j
++) {
602 #pragma omp target teams distribute parallel for
603 for (int i
= 0; i
< 10; ++i
) {
605 void g() { throw 0; }
610 void test_loop_firstprivate_lastprivate() {
612 // expected-error@+1 {{lastprivate variable cannot be firstprivate}} expected-note@+1 {{defined as lastprivate}}
613 #pragma omp target teams distribute parallel for lastprivate(s) firstprivate(s) // expected-error {{calling a private constructor of class 'S'}}
614 for (int i
= 0; i
< 16; ++i
)
618 void test_ordered() {
619 #pragma omp target teams distribute parallel for ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp target teams distribute parallel for'}}
620 for (int i
= 0; i
< 16; ++i
)
625 #pragma omp target teams distribute parallel for nowait nowait // expected-error {{directive '#pragma omp target teams distribute parallel for' cannot contain more than one 'nowait' clause}}
626 for (int i
= 0; i
< 16; ++i
)