1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp4 %s -Wuninitialized
2 // RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp5 %s -Wuninitialized
4 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp4 %s -Wuninitialized
5 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp5 %s -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
];
28 #pragma omp teams distribute parallel for
29 for (int i
= 0; i
< 10; i
+= 1) {
33 #pragma omp teams distribute parallel for
34 for (char i
= 0; i
< 10; i
++) {
38 #pragma omp teams distribute parallel for
39 for (char i
= 0; i
< 10; i
+= '\1') {
43 #pragma omp teams distribute parallel for
44 for (long long i
= 0; i
< 10; i
++) {
48 #pragma omp teams distribute parallel for
49 // expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'double'}}
50 for (long long i
= 0; i
< 10; i
+= 1.5) {
54 #pragma omp teams distribute parallel for
55 for (long long i
= 0; i
< 'z'; i
+= 1u) {
59 #pragma omp teams distribute parallel for
60 // expected-error@+1 {{variable must be of integer or random access iterator type}}
61 for (float fi
= 0; fi
< 10.0; fi
++) {
62 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
65 #pragma omp teams distribute parallel for
66 // expected-error@+1 {{variable must be of integer or random access iterator type}}
67 for (double fi
= 0; fi
< 10.0; fi
++) {
68 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
71 #pragma omp 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 &ref
= ii
; ref
< 10; ref
++) {
76 #pragma omp 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')}}
78 for (int i
; i
< 10; i
++)
82 #pragma omp teams distribute parallel for
83 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
84 for (int i
= 0, j
= 0; i
< 10; ++i
)
88 #pragma omp teams distribute parallel for
89 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
94 #pragma omp teams distribute parallel for
95 // expected-warning@+2 {{expression result unused}}
96 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
97 for (ii
+ 1; ii
< 10; ++ii
)
101 #pragma omp teams distribute parallel for
102 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
103 for (c
[ii
] = 0; ii
< 10; ++ii
)
107 #pragma omp teams distribute parallel for
108 // Ok to skip parenthesises.
109 for (((ii
)) = 0; ii
< 10; ++ii
)
113 #pragma omp teams distribute parallel for
114 // 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'}}
115 for (int i
= 0; i
; i
++)
119 #pragma omp teams distribute parallel for
120 // 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'}}
121 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}}
122 for (int i
= 0; jj
< kk
; ii
++)
126 #pragma omp teams distribute parallel for
127 // 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'}}
128 for (int i
= 0; !!i
; i
++)
132 #pragma omp teams distribute parallel for
133 // omp4-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
134 for (int i
= 0; i
!= 1; i
++)
138 #pragma omp teams distribute parallel for
139 // 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'}}
140 for (int i
= 0;; i
++)
145 #pragma omp teams distribute parallel for
146 for (int i
= 11; i
> 10; i
--)
151 #pragma omp teams distribute parallel for
152 for (int i
= 0; i
< 10; ++i
)
157 #pragma omp teams distribute parallel for
158 for (ii
= 0; ii
< 10; ++ii
)
162 #pragma omp teams distribute parallel for
163 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
164 for (ii
= 0; ii
< 10; ++jj
)
168 #pragma omp teams distribute parallel for
169 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
170 for (ii
= 0; ii
< 10; ++++ii
)
173 // Ok but undefined behavior (in general, cannot check that incr
174 // is really loop-invariant).
176 #pragma omp teams distribute parallel for
177 for (ii
= 0; ii
< 10; ii
= ii
+ ii
)
181 #pragma omp teams distribute parallel for
182 // expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'float'}}
183 for (ii
= 0; ii
< 10; ii
= ii
+ 1.0f
)
186 // Ok - step was converted to integer type.
188 #pragma omp teams distribute parallel for
189 for (ii
= 0; ii
< 10; ii
= ii
+ (int)1.1f
)
193 #pragma omp teams distribute parallel for
194 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
195 for (ii
= 0; ii
< 10; jj
= ii
+ 2)
199 #pragma omp teams distribute parallel for
200 // expected-warning@+2 {{relational comparison result unused}}
201 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
202 for (ii
= 0; ii
<10; jj
> kk
+ 2)
206 #pragma omp teams distribute parallel for
207 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
208 for (ii
= 0; ii
< 10;)
212 #pragma omp teams distribute parallel for
213 // expected-warning@+2 {{expression result unused}}
214 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
215 for (ii
= 0; ii
< 10; !ii
)
219 #pragma omp teams distribute parallel for
220 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
221 for (ii
= 0; ii
< 10; ii
? ++ii
: ++jj
)
225 #pragma omp teams distribute parallel for
226 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
227 for (ii
= 0; ii
< 10; ii
= ii
< 10)
231 #pragma omp teams distribute parallel for
232 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
233 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
234 for (ii
= 0; ii
< 10; ii
= ii
+ 0)
238 #pragma omp 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
= ii
+ (int)(0.8 - 0.45))
245 #pragma omp teams distribute parallel for
246 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
247 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
248 for (ii
= 0; (ii
) < 10; ii
-= 25)
252 #pragma omp teams distribute parallel for
253 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
254 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
255 for (ii
= 0; (ii
< 10); ii
-= 0)
259 #pragma omp teams distribute parallel for
260 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
261 // expected-error@+1 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
262 for (ii
= 0; ii
> 10; (ii
+= 0))
266 #pragma omp teams distribute parallel for
267 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
268 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
269 for (ii
= 0; ii
< 10; (ii
) = (1 - 1) + (ii
))
273 #pragma omp teams distribute parallel for
274 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
275 // expected-error@+1 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
276 for ((ii
= 0); ii
> 10; (ii
-= 0))
280 #pragma omp teams distribute parallel for
281 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
282 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
283 for (ii
= 0; (ii
< 10); (ii
-= 0))
287 #pragma omp teams distribute parallel for firstprivate(ii) // expected-note {{defined as firstprivate}}
288 // expected-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute parallel for' directive may not be firstprivate, predetermined as private}}
289 for (ii
= 0; ii
< 10; ii
++)
293 #pragma omp teams distribute parallel for private(ii) // OK
294 for (ii
= 0; ii
< 10; ii
++)
298 #pragma omp teams distribute parallel for lastprivate(ii) // OK
299 for (ii
= 0; ii
< 10; ii
++)
303 #pragma omp teams distribute parallel for
304 // expected-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute parallel for' directive may not be threadprivate or thread local, predetermined as private}}
305 for (sii
= 0; sii
< 10; sii
++)
310 #pragma omp teams distribute parallel for collapse(2)
311 for (ii
= 0; ii
< 10; ii
+= 1)
312 for (globalii
= 0; globalii
< 10; globalii
+= 1)
313 c
[globalii
] += a
[globalii
] + ii
;
317 #pragma omp teams distribute parallel for
318 // omp4-error@+1 {{statement after '#pragma omp teams distribute parallel for' must be a for loop}}
319 for (auto &item
: a
) {
324 #pragma omp teams distribute parallel for
325 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
326 // expected-error@+1 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
327 for (unsigned i
= 9; i
< 10; i
--) {
331 int(*lb
)[4] = nullptr;
333 #pragma omp teams distribute parallel for
334 for (int(*p
)[4] = lb
; p
< lb
+ 8; ++p
) {
338 #pragma omp teams distribute parallel for
339 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
340 for (int a
{0}; a
< 10; ++a
) {
346 // Iterators allowed in openmp for-loops.
348 struct random_access_iterator_tag
{};
349 template <class Iter
>
350 struct iterator_traits
{
351 typedef typename
Iter::difference_type difference_type
;
352 typedef typename
Iter::iterator_category iterator_category
;
354 template <class Iter
>
355 typename iterator_traits
<Iter
>::difference_type
356 distance(Iter first
, Iter last
) { return first
- last
; }
361 Iter0(const Iter0
&) {}
362 Iter0
operator++() { return *this; }
363 Iter0
operator--() { return *this; }
364 bool operator<(Iter0 a
) { return true; }
366 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
367 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
368 int operator-(Iter0 a
, Iter0 b
) { return 0; }
371 Iter1(float f
= 0.0f
, double d
= 0.0) {}
372 Iter1(const Iter1
&) {}
373 Iter1
operator++() { return *this; }
374 Iter1
operator--() { return *this; }
375 bool operator<(Iter1 a
) { return true; }
376 bool operator>=(Iter1 a
) { return false; }
381 GoodIter(const GoodIter
&) {}
382 GoodIter(int fst
, int snd
) {}
383 GoodIter
&operator=(const GoodIter
&that
) { return *this; }
384 GoodIter
&operator=(const Iter0
&that
) { return *this; }
385 GoodIter
&operator+=(int x
) { return *this; }
386 explicit GoodIter(void *) {}
387 GoodIter
operator++() { return *this; }
388 GoodIter
operator--() { return *this; }
389 bool operator!() { return true; }
390 bool operator<(GoodIter a
) { return true; }
391 bool operator<=(GoodIter a
) { return true; }
392 bool operator>=(GoodIter a
) { return false; }
393 typedef int difference_type
;
394 typedef std::random_access_iterator_tag iterator_category
;
396 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
397 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
398 int operator-(GoodIter a
, GoodIter b
) { return 0; }
399 // expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
400 GoodIter
operator-(GoodIter a
) { return a
; }
401 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
402 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
403 GoodIter
operator-(GoodIter a
, int v
) { return GoodIter(); }
404 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
405 GoodIter
operator+(GoodIter a
, int v
) { return GoodIter(); }
406 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
407 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
408 GoodIter
operator-(int v
, GoodIter a
) { return GoodIter(); }
409 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
410 GoodIter
operator+(int v
, GoodIter a
) { return GoodIter(); }
412 int test_with_random_access_iterator() {
416 #pragma omp teams distribute parallel for
417 for (GoodIter I
= begin
; I
< end
; ++I
) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
420 #pragma omp teams distribute parallel for
421 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
422 for (GoodIter
&I
= begin
; I
< end
; ++I
)
425 #pragma omp teams distribute parallel for
426 for (GoodIter I
= begin
; I
>= end
; --I
) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
429 #pragma omp teams distribute parallel for
430 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
431 for (GoodIter
I(begin
); I
< end
; ++I
) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
434 #pragma omp teams distribute parallel for
435 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
436 for (GoodIter
I(nullptr); I
< end
; ++I
) // expected-warning {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
439 #pragma omp teams distribute parallel for
440 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
441 for (GoodIter
I(0); I
< end
; ++I
) // expected-warning {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
444 #pragma omp teams distribute parallel for
445 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
446 for (GoodIter
I(1, 2); I
< end
; ++I
) // expected-warning {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
449 #pragma omp teams distribute parallel for
450 for (begin
= GoodIter(0); begin
< end
; ++begin
) // expected-warning {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
453 #pragma omp teams distribute parallel for
454 // expected-error@+2 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
455 // expected-error@+1 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
456 for (begin
= begin0
; begin
< end
; ++begin
)
459 #pragma omp teams distribute parallel for
460 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
461 for (++begin
; begin
< end
; ++begin
)
464 #pragma omp teams distribute parallel for
465 for (begin
= end
; begin
< end
; ++begin
) // expected-warning {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
468 #pragma omp teams distribute parallel for
469 // 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'}}
470 for (GoodIter I
= begin
; I
- I
; ++I
)
473 #pragma omp teams distribute parallel for
474 // 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'}}
475 for (GoodIter I
= begin
; begin
< end
; ++I
)
478 #pragma omp teams distribute parallel for
479 // 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'}}
480 for (GoodIter I
= begin
; !I
; ++I
)
483 #pragma omp teams distribute parallel for
484 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
485 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
486 for (GoodIter I
= begin
; I
>= end
; I
= I
+ 1)
489 #pragma omp teams distribute parallel for
490 for (GoodIter I
= begin
; I
>= end
; I
= I
- 1) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
493 #pragma omp teams distribute parallel for
494 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
495 for (GoodIter I
= begin
; I
>= end
; I
= -I
)
498 #pragma omp teams distribute parallel for
499 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
500 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
501 for (GoodIter I
= begin
; I
>= end
; I
= 2 + I
)
504 #pragma omp teams distribute parallel for
505 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
506 for (GoodIter I
= begin
; I
>= end
; I
= 2 - I
)
509 #pragma omp teams distribute parallel for
510 // expected-error@+1 {{invalid operands to binary expression ('Iter0' and 'int')}}
511 for (Iter0 I
= begin0
; I
< end0
; ++I
)
514 #pragma omp teams distribute parallel for
515 // Initializer is constructor without params.
516 // expected-error@+2 {{invalid operands to binary expression ('Iter0' and 'int')}}
517 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
518 for (Iter0 I
; I
< end0
; ++I
)
522 #pragma omp teams distribute parallel for
523 // expected-error@+2 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
524 // expected-error@+1 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
525 for (Iter1 I
= begin1
; I
< end1
; ++I
)
528 #pragma omp teams distribute parallel for
529 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
530 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
531 for (Iter1 I
= begin1
; I
>= end1
; ++I
)
534 #pragma omp teams distribute parallel for
535 // expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'float')}}
536 // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
537 // Initializer is constructor with all default params.
538 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
539 for (Iter1 I
; I
< end1
; ++I
) {
544 template <typename IT
, int ST
>
547 int dotest_lt(IT begin
, IT end
) {
549 #pragma omp teams distribute parallel for
550 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
551 // expected-error@+1 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
552 for (IT I
= begin
; I
< end
; I
= I
+ ST
) { // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
556 #pragma omp teams distribute parallel for
557 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
558 // expected-error@+1 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
559 for (IT I
= begin
; I
<= end
; I
+= ST
) { // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
563 #pragma omp teams distribute parallel for
564 for (IT I
= begin
; I
< end
; ++I
) { // expected-warning 4 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
573 template <typename IT
, int ST
= 0>
574 int dotest_gt(IT begin
, IT end
) {
576 #pragma omp teams distribute parallel for
577 // expected-note@+2 2 {{loop step is expected to be negative due to this condition}}
578 // expected-error@+1 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
579 for (IT I
= begin
; I
>= end
; I
= I
+ ST
) {
583 #pragma omp teams distribute parallel for
584 // expected-note@+2 2 {{loop step is expected to be negative due to this condition}}
585 // expected-error@+1 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
586 for (IT I
= begin
; I
>= end
; I
+= ST
) {
591 #pragma omp teams distribute parallel for
592 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
593 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
594 for (IT I
= begin
; I
>= end
; ++I
) {
599 #pragma omp teams distribute parallel for
600 for (IT I
= begin
; I
< end
; I
+= TC
<int, ST
>::step()) { // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
605 void test_with_template() {
607 TC
<GoodIter
, 100> t1
;
608 TC
<GoodIter
, -100> t2
;
609 t1
.dotest_lt(begin
, end
); // expected-note {{in instantiation of member function 'TC<GoodIter, 100>::dotest_lt' requested here}}
610 t2
.dotest_lt(begin
, end
); // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
611 dotest_gt(begin
, end
); // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
612 dotest_gt
<unsigned, 10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, 10>' requested here}}
615 void test_loop_break() {
617 float a
[N
], b
[N
], c
[N
];
619 #pragma omp teams distribute parallel for
620 for (int i
= 0; i
< 10; i
++) {
622 for (int j
= 0; j
< 10; ++j
) {
624 break; // OK in nested loop
634 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
637 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
641 #pragma omp teams distribute parallel for
642 for (int i
= 0; i
< 10; i
++) {
643 for (int j
= 0; j
< 10; j
++) {
654 void test_loop_eh() {
656 float a
[N
], b
[N
], c
[N
];
658 #pragma omp teams distribute parallel for
659 for (int i
= 0; i
< 10; i
++) {
662 for (int j
= 0; j
< 10; ++j
) {
670 return; // expected-error {{cannot return from OpenMP region}}
679 for (int j
= 0; j
< 10; j
++) {
688 #pragma omp teams distribute parallel for
689 for (int i
= 0; i
< 10; ++i
) {
691 void g() { throw 0; }
696 void test_loop_firstprivate_lastprivate() {
698 // expected-error@+2 {{lastprivate variable cannot be firstprivate}} expected-note@+2 {{defined as lastprivate}}
700 #pragma omp teams distribute parallel for lastprivate(s) firstprivate(s) // expected-error {{calling a private constructor of class 'S'}} expected-warning {{Type 'S' is not trivially copyable and not guaranteed to be mapped correctly}}
701 for (int i
= 0; i
< 16; ++i
)
705 void test_ordered() {
707 #pragma omp teams distribute parallel for ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp teams distribute parallel for'}}
708 for (int i
= 0; i
< 16; ++i
)
714 // expected-error@+1 2 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp teams distribute parallel for'}}
715 #pragma omp teams distribute parallel for nowait nowait // expected-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'nowait' clause}}
716 for (int i
= 0; i
< 16; ++i
)