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 simd
29 for (int i
= 0; i
< 10; i
+= 1) {
33 #pragma omp teams distribute simd
34 for (char i
= 0; i
< 10; i
++) {
38 #pragma omp teams distribute simd
39 for (char i
= 0; i
< 10; i
+= '\1') {
43 #pragma omp teams distribute simd
44 for (long long i
= 0; i
< 10; i
++) {
48 #pragma omp teams distribute simd
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 simd
55 for (long long i
= 0; i
< 'z'; i
+= 1u) {
59 #pragma omp teams distribute simd
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 simd
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 simd
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 simd
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 simd
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 simd
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 simd
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 simd
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 simd
108 // Ok to skip parenthesises.
109 for (((ii
)) = 0; ii
< 10; ++ii
)
113 #pragma omp teams distribute simd
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 simd
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 simd
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 simd
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 simd
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 simd
146 for (int i
= 11; i
> 10; i
--)
151 #pragma omp teams distribute simd
152 for (int i
= 0; i
< 10; ++i
)
157 #pragma omp teams distribute simd
158 for (ii
= 0; ii
< 10; ++ii
)
162 #pragma omp teams distribute simd
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 simd
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 simd
177 for (ii
= 0; ii
< 10; ii
= ii
+ ii
)
181 #pragma omp teams distribute simd
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 simd
189 for (ii
= 0; ii
< 10; ii
= ii
+ (int)1.1f
)
193 #pragma omp teams distribute simd
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 simd
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 simd
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 simd
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 simd
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 simd
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 simd
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 simd
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 simd
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 simd
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 simd
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 simd
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 simd
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 simd
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 simd firstprivate(ii) // expected-note {{defined as firstprivate}}
288 // expected-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute simd' directive may not be firstprivate, predetermined as linear}}
289 for (ii
= 0; ii
< 10; ii
++)
293 #pragma omp teams distribute simd private(ii) // omp4-note {{defined as private}}
294 // omp4-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute simd' directive may not be private, predetermined as linear}}
295 for (ii
= 0; ii
< 10; ii
++)
299 #pragma omp teams distribute simd lastprivate(ii) // omp4-note {{defined as lastprivate}}
300 // omp4-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute simd' directive may not be lastprivate, predetermined as linear}}
301 for (ii
= 0; ii
< 10; ii
++)
305 #pragma omp teams distribute simd
306 // expected-error@+1 {{loop iteration variable in the associated loop of 'omp teams distribute simd' directive may not be threadprivate or thread local, predetermined as linear}}
307 for (sii
= 0; sii
< 10; sii
++)
312 #pragma omp teams distribute simd collapse(2)
313 for (ii
= 0; ii
< 10; ii
+= 1)
314 for (globalii
= 0; globalii
< 10; globalii
+= 1)
315 c
[globalii
] += a
[globalii
] + ii
;
319 #pragma omp teams distribute simd
320 // omp4-error@+1 {{statement after '#pragma omp teams distribute simd' must be a for loop}}
321 for (auto &item
: a
) {
326 #pragma omp teams distribute simd
327 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
328 // expected-error@+1 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
329 for (unsigned i
= 9; i
< 10; i
--) {
333 int(*lb
)[4] = nullptr;
335 #pragma omp teams distribute simd
336 for (int(*p
)[4] = lb
; p
< lb
+ 8; ++p
) {
340 #pragma omp teams distribute simd
341 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
342 for (int a
{0}; a
< 10; ++a
) {
348 // Iterators allowed in openmp for-loops.
350 struct random_access_iterator_tag
{};
351 template <class Iter
>
352 struct iterator_traits
{
353 typedef typename
Iter::difference_type difference_type
;
354 typedef typename
Iter::iterator_category iterator_category
;
356 template <class Iter
>
357 typename iterator_traits
<Iter
>::difference_type
358 distance(Iter first
, Iter last
) { return first
- last
; }
363 Iter0(const Iter0
&) {}
364 Iter0
operator++() { return *this; }
365 Iter0
operator--() { return *this; }
366 bool operator<(Iter0 a
) { return true; }
368 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
369 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
370 int operator-(Iter0 a
, Iter0 b
) { return 0; }
373 Iter1(float f
= 0.0f
, double d
= 0.0) {}
374 Iter1(const Iter1
&) {}
375 Iter1
operator++() { return *this; }
376 Iter1
operator--() { return *this; }
377 bool operator<(Iter1 a
) { return true; }
378 bool operator>=(Iter1 a
) { return false; }
383 GoodIter(const GoodIter
&) {}
384 GoodIter(int fst
, int snd
) {}
385 GoodIter
&operator=(const GoodIter
&that
) { return *this; }
386 GoodIter
&operator=(const Iter0
&that
) { return *this; }
387 GoodIter
&operator+=(int x
) { return *this; }
388 explicit GoodIter(void *) {}
389 GoodIter
operator++() { return *this; }
390 GoodIter
operator--() { return *this; }
391 bool operator!() { return true; }
392 bool operator<(GoodIter a
) { return true; }
393 bool operator<=(GoodIter a
) { return true; }
394 bool operator>=(GoodIter a
) { return false; }
395 typedef int difference_type
;
396 typedef std::random_access_iterator_tag iterator_category
;
398 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
399 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
400 int operator-(GoodIter a
, GoodIter b
) { return 0; }
401 // expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
402 GoodIter
operator-(GoodIter a
) { return a
; }
403 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
404 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
405 GoodIter
operator-(GoodIter a
, int v
) { return GoodIter(); }
406 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
407 GoodIter
operator+(GoodIter a
, int v
) { return GoodIter(); }
408 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
409 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
410 GoodIter
operator-(int v
, GoodIter a
) { return GoodIter(); }
411 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
412 GoodIter
operator+(int v
, GoodIter a
) { return GoodIter(); }
414 int test_with_random_access_iterator() {
418 #pragma omp teams distribute simd
419 for (GoodIter I
= begin
; I
< end
; ++I
) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
422 #pragma omp teams distribute simd
423 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
424 for (GoodIter
&I
= begin
; I
< end
; ++I
)
427 #pragma omp teams distribute simd
428 for (GoodIter I
= begin
; I
>= end
; --I
) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
431 #pragma omp teams distribute simd
432 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
433 for (GoodIter
I(begin
); I
< end
; ++I
) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
436 #pragma omp teams distribute simd
437 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
438 for (GoodIter
I(nullptr); I
< end
; ++I
) // expected-warning {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
441 #pragma omp teams distribute simd
442 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
443 for (GoodIter
I(0); I
< end
; ++I
) // expected-warning {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
446 #pragma omp teams distribute simd
447 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
448 for (GoodIter
I(1, 2); I
< end
; ++I
) // expected-warning {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
451 #pragma omp teams distribute simd
452 for (begin
= GoodIter(0); begin
< end
; ++begin
) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
455 #pragma omp teams distribute simd
456 // expected-error@+2 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
457 // expected-error@+1 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
458 for (begin
= begin0
; begin
< end
; ++begin
)
461 #pragma omp teams distribute simd
462 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
463 for (++begin
; begin
< end
; ++begin
)
466 #pragma omp teams distribute simd
467 for (begin
= end
; begin
< end
; ++begin
) // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
470 #pragma omp teams distribute simd
471 // 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'}}
472 for (GoodIter I
= begin
; I
- I
; ++I
)
475 #pragma omp teams distribute simd
476 // 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'}}
477 for (GoodIter I
= begin
; begin
< end
; ++I
)
480 #pragma omp teams distribute simd
481 // 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'}}
482 for (GoodIter I
= begin
; !I
; ++I
)
485 #pragma omp teams distribute simd
486 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
487 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
488 for (GoodIter I
= begin
; I
>= end
; I
= I
+ 1)
491 #pragma omp teams distribute simd
492 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}}
495 #pragma omp teams distribute simd
496 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
497 for (GoodIter I
= begin
; I
>= end
; I
= -I
)
500 #pragma omp teams distribute simd
501 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
502 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
503 for (GoodIter I
= begin
; I
>= end
; I
= 2 + I
)
506 #pragma omp teams distribute simd
507 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
508 for (GoodIter I
= begin
; I
>= end
; I
= 2 - I
)
511 #pragma omp teams distribute simd
512 // expected-error@+1 {{invalid operands to binary expression ('Iter0' and 'int')}}
513 for (Iter0 I
= begin0
; I
< end0
; ++I
)
516 #pragma omp teams distribute simd
517 // Initializer is constructor without params.
518 // expected-error@+2 {{invalid operands to binary expression ('Iter0' and 'int')}}
519 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
520 for (Iter0 I
; I
< end0
; ++I
)
524 #pragma omp teams distribute simd
525 // expected-error@+2 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
526 // expected-error@+1 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
527 for (Iter1 I
= begin1
; I
< end1
; ++I
)
530 #pragma omp teams distribute simd
531 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
532 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
533 for (Iter1 I
= begin1
; I
>= end1
; ++I
)
536 #pragma omp teams distribute simd
537 // expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'float')}}
538 // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
539 // Initializer is constructor with all default params.
540 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
541 for (Iter1 I
; I
< end1
; ++I
) {
546 template <typename IT
, int ST
>
549 int dotest_lt(IT begin
, IT end
) {
551 #pragma omp teams distribute simd
552 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
553 // expected-error@+1 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
554 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}}
558 #pragma omp teams distribute simd
559 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
560 // expected-error@+1 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
561 for (IT I
= begin
; I
<= end
; I
+= ST
) { // expected-warning 2 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
565 #pragma omp teams distribute simd
566 for (IT I
= begin
; I
< end
; ++I
) { // expected-warning 4 {{Type 'GoodIter' is not trivially copyable and not guaranteed to be mapped correctly}}
575 template <typename IT
, int ST
= 0>
576 int dotest_gt(IT begin
, IT end
) {
578 #pragma omp teams distribute simd
579 // expected-note@+2 2 {{loop step is expected to be negative due to this condition}}
580 // expected-error@+1 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
581 for (IT I
= begin
; I
>= end
; I
= I
+ ST
) {
585 #pragma omp teams distribute simd
586 // expected-note@+2 2 {{loop step is expected to be negative due to this condition}}
587 // expected-error@+1 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
588 for (IT I
= begin
; I
>= end
; I
+= ST
) {
593 #pragma omp teams distribute simd
594 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
595 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
596 for (IT I
= begin
; I
>= end
; ++I
) {
601 #pragma omp teams distribute simd
602 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}}
607 void test_with_template() {
609 TC
<GoodIter
, 100> t1
;
610 TC
<GoodIter
, -100> t2
;
611 t1
.dotest_lt(begin
, end
); // expected-note {{in instantiation of member function 'TC<GoodIter, 100>::dotest_lt' requested here}}
612 t2
.dotest_lt(begin
, end
); // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
613 dotest_gt(begin
, end
); // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
614 dotest_gt
<unsigned, 10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, 10>' requested here}}
617 void test_loop_break() {
619 float a
[N
], b
[N
], c
[N
];
621 #pragma omp teams distribute simd
622 for (int i
= 0; i
< 10; i
++) {
624 for (int j
= 0; j
< 10; ++j
) {
626 break; // OK in nested loop
636 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
639 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
643 #pragma omp teams distribute simd
644 for (int i
= 0; i
< 10; i
++) {
645 for (int j
= 0; j
< 10; j
++) {
656 void test_loop_eh() {
658 float a
[N
], b
[N
], c
[N
];
660 #pragma omp teams distribute simd
661 for (int i
= 0; i
< 10; i
++) {
663 try { // expected-error {{'try' statement cannot be used in OpenMP simd region}}
664 for (int j
= 0; j
< 10; ++j
) {
666 throw a
[i
]; // expected-error {{throw' statement cannot be used in OpenMP simd region}}
668 throw a
[i
]; // expected-error {{throw' statement cannot be used in OpenMP simd region}}
671 throw a
[i
]; // expected-error {{throw' statement cannot be used in OpenMP simd region}}
672 return; // expected-error {{cannot return from OpenMP region}}
681 for (int j
= 0; j
< 10; j
++) {
683 throw c
[i
]; // expected-error {{throw' statement cannot be used in OpenMP simd region}}
690 #pragma omp teams distribute simd
691 for (int i
= 0; i
< 10; ++i
) {
693 void g() { throw 0; }
698 void test_loop_firstprivate_lastprivate() {
700 // expected-error@+2 {{lastprivate variable cannot be firstprivate}} expected-note@+2 {{defined as lastprivate}}
702 #pragma omp teams distribute simd 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}}
703 for (int i
= 0; i
< 16; ++i
)
707 void test_ordered() {
709 #pragma omp teams distribute simd ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp teams distribute simd'}}
710 for (int i
= 0; i
< 16; ++i
)
716 // expected-error@+1 2 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp teams distribute simd'}}
717 #pragma omp teams distribute simd nowait nowait // expected-error {{directive '#pragma omp teams distribute simd' cannot contain more than one 'nowait' clause}}
718 for (int i
= 0; i
< 16; ++i
)