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
13 S(const S
&s
) : a(s
.a
) {}
17 // expected-note@+1 {{defined as threadprivate or thread local}}
18 #pragma omp threadprivate(sii)
21 // Currently, we cannot use "0" for global register variables.
22 // register int reg0 __asm__("0");
25 int test_iteration_spaces() {
27 float a
[N
], b
[N
], c
[N
];
31 register int reg
; // expected-warning {{'register' storage class specifier is deprecated}}
33 #pragma omp master taskloop simd
34 for (int i
= 0; i
< 10; i
+= 1) {
38 #pragma omp master taskloop simd
39 for (char i
= 0; i
< 10; i
++) {
43 #pragma omp master taskloop simd
44 for (char i
= 0; i
< 10; i
+= '\1') {
48 #pragma omp master taskloop simd
49 for (long long i
= 0; i
< 10; i
++) {
53 // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'double'}}
54 #pragma omp master taskloop simd
55 for (long long i
= 0; i
< 10; i
+= 1.5) {
59 #pragma omp master taskloop simd
60 for (long long i
= 0; i
< 'z'; i
+= 1u) {
64 // expected-error@+2 {{variable must be of integer or random access iterator type}}
65 #pragma omp master taskloop simd
66 for (float fi
= 0; fi
< 10.0; fi
++) {
67 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
70 // expected-error@+2 {{variable must be of integer or random access iterator type}}
71 #pragma omp master taskloop simd
72 for (double fi
= 0; fi
< 10.0; fi
++) {
73 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
76 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
77 #pragma omp master taskloop simd
78 for (int &ref
= ii
; ref
< 10; ref
++) {
81 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
82 #pragma omp master taskloop simd
83 for (int i
; i
< 10; i
++)
87 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
88 #pragma omp master taskloop simd
89 for (int i
= 0, j
= 0; i
< 10; ++i
)
93 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
94 #pragma omp master taskloop simd
99 // expected-warning@+3 {{expression result unused}}
100 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
101 #pragma omp master taskloop simd
102 for (ii
+ 1; ii
< 10; ++ii
)
106 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
107 #pragma omp master taskloop simd
108 for (c
[ii
] = 0; ii
< 10; ++ii
)
112 // Ok to skip parenthesises.
113 #pragma omp master taskloop simd
114 for (((ii
)) = 0; ii
< 10; ++ii
)
118 // 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'}}
119 #pragma omp master taskloop simd
120 for (int i
= 0; i
; i
++)
124 // omp4-error@+3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+3 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
125 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}}
126 #pragma omp master taskloop simd
127 for (int i
= 0; jj
< kk
; ii
++)
131 // 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'}}
132 #pragma omp master taskloop simd
133 for (int i
= 0; !!i
; i
++)
137 // omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
138 #pragma omp master taskloop simd
139 for (int i
= 0; i
!= 1; i
++)
143 // 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'}}
144 #pragma omp master taskloop simd
145 for (int i
= 0;; i
++)
150 #pragma omp master taskloop simd
151 for (int i
= 11; i
> 10; i
--)
156 #pragma omp master taskloop simd
157 for (int i
= 0; i
< 10; ++i
)
162 #pragma omp master taskloop simd
163 for (ii
= 0; ii
< 10; ++ii
)
167 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
168 #pragma omp master taskloop simd
169 for (ii
= 0; ii
< 10; ++jj
)
173 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
174 #pragma omp master taskloop simd
175 for (ii
= 0; ii
< 10; ++++ii
)
179 // Ok but undefined behavior (in general, cannot check that incr
180 // is really loop-invariant).
181 #pragma omp master taskloop simd
182 for (ii
= 0; ii
< 10; ii
= ii
+ ii
)
186 // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'float'}}
187 #pragma omp master taskloop simd
188 for (ii
= 0; ii
< 10; ii
= ii
+ 1.0f
)
192 // Ok - step was converted to integer type.
193 #pragma omp master taskloop simd
194 for (ii
= 0; ii
< 10; ii
= ii
+ (int)1.1f
)
198 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
199 #pragma omp master taskloop simd
200 for (ii
= 0; ii
< 10; jj
= ii
+ 2)
204 // expected-warning@+3 {{relational comparison result unused}}
205 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
206 #pragma omp master taskloop simd
207 for (ii
= 0; ii
<10; jj
> kk
+ 2)
211 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
212 #pragma omp master taskloop simd
213 for (ii
= 0; ii
< 10;)
217 // expected-warning@+3 {{expression result unused}}
218 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
219 #pragma omp master taskloop simd
220 for (ii
= 0; ii
< 10; !ii
)
224 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
225 #pragma omp master taskloop simd
226 for (ii
= 0; ii
< 10; ii
? ++ii
: ++jj
)
230 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
231 #pragma omp master taskloop simd
232 for (ii
= 0; ii
< 10; ii
= ii
< 10)
236 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
237 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
238 #pragma omp master taskloop simd
239 for (ii
= 0; ii
< 10; ii
= ii
+ 0)
243 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
244 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
245 #pragma omp master taskloop simd
246 for (ii
= 0; ii
< 10; ii
= ii
+ (int)(0.8 - 0.45))
250 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
251 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
252 #pragma omp master taskloop simd
253 for (ii
= 0; (ii
) < 10; ii
-= 25)
257 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
258 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
259 #pragma omp master taskloop simd
260 for (ii
= 0; (ii
< 10); ii
-= 0)
264 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
265 // expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
266 #pragma omp master taskloop simd
267 for (ii
= 0; ii
> 10; (ii
+= 0))
271 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
272 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
273 #pragma omp master taskloop simd
274 for (ii
= 0; ii
< 10; (ii
) = (1 - 1) + (ii
))
278 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
279 // expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
280 #pragma omp master taskloop simd
281 for ((ii
= 0); ii
> 10; (ii
-= 0))
285 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
286 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
287 #pragma omp master taskloop simd
288 for (ii
= 0; (ii
< 10); (ii
-= 0))
292 // expected-note@+2 {{defined as firstprivate}}
293 // expected-error@+2 {{loop iteration variable in the associated loop of 'omp master taskloop simd' directive may not be firstprivate, predetermined as linear}}
294 #pragma omp master taskloop simd firstprivate(ii)
295 for (ii
= 0; ii
< 10; ii
++)
299 #pragma omp master taskloop simd linear(ii)
300 for (ii
= 0; ii
< 10; ii
++)
303 // omp4-note@+3 {{defined as private}}
304 // omp4-error@+3 {{loop iteration variable in the associated loop of 'omp master taskloop simd' directive may not be private, predetermined as linear}}
306 #pragma omp master taskloop simd private(ii)
307 for (ii
= 0; ii
< 10; ii
++)
310 // omp4-note@+3 {{defined as lastprivate}}
311 // omp4-error@+3 {{loop iteration variable in the associated loop of 'omp master taskloop simd' directive may not be lastprivate, predetermined as linear}}
313 #pragma omp master taskloop simd lastprivate(ii)
314 for (ii
= 0; ii
< 10; ii
++)
319 // expected-error@+2 {{loop iteration variable in the associated loop of 'omp master taskloop simd' directive may not be threadprivate or thread local, predetermined as linear}}
320 #pragma omp master taskloop simd
321 for (sii
= 0; sii
< 10; sii
+= 1)
327 #pragma omp master taskloop simd
328 for (reg0
= 0; reg0
< 10; reg0
+= 1)
334 #pragma omp master taskloop simd
335 for (reg
= 0; reg
< 10; reg
+= 1)
341 #pragma omp master taskloop simd
342 for (globalii
= 0; globalii
< 10; globalii
+= 1)
343 c
[globalii
] = a
[globalii
];
348 #pragma omp master taskloop simd collapse(2)
349 for (ii
= 0; ii
< 10; ii
+= 1)
350 for (globalii
= 0; globalii
< 10; globalii
+= 1)
351 c
[globalii
] += a
[globalii
] + ii
;
355 // omp4-error@+2 {{statement after '#pragma omp master taskloop simd' must be a for loop}}
356 #pragma omp master taskloop simd
357 for (auto &item
: a
) {
362 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
363 // expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
364 #pragma omp master taskloop simd
365 for (unsigned i
= 9; i
< 10; i
--) {
369 int(*lb
)[4] = nullptr;
371 #pragma omp master taskloop simd
372 for (int(*p
)[4] = lb
; p
< lb
+ 8; ++p
) {
376 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
377 #pragma omp master taskloop simd
378 for (int a
{0}; a
< 10; ++a
) {
384 // Iterators allowed in openmp for-loops.
386 struct random_access_iterator_tag
{};
387 template <class Iter
>
388 struct iterator_traits
{
389 typedef typename
Iter::difference_type difference_type
;
390 typedef typename
Iter::iterator_category iterator_category
;
392 template <class Iter
>
393 typename iterator_traits
<Iter
>::difference_type
394 distance(Iter first
, Iter last
) { return first
- last
; }
399 Iter0(const Iter0
&) {}
400 Iter0
operator++() { return *this; }
401 Iter0
operator--() { return *this; }
402 bool operator<(Iter0 a
) { return true; }
404 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
405 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
406 int operator-(Iter0 a
, Iter0 b
) { return 0; }
409 Iter1(float f
= 0.0f
, double d
= 0.0) {}
410 Iter1(const Iter1
&) {}
411 Iter1
operator++() { return *this; }
412 Iter1
operator--() { return *this; }
413 bool operator<(Iter1 a
) { return true; }
414 bool operator>=(Iter1 a
) { return false; }
419 GoodIter(const GoodIter
&) {}
420 GoodIter(int fst
, int snd
) {}
421 GoodIter
&operator=(const GoodIter
&that
) { return *this; }
422 GoodIter
&operator=(const Iter0
&that
) { return *this; }
423 GoodIter
&operator+=(int x
) { return *this; }
424 GoodIter
&operator-=(int x
) { return *this; }
425 explicit GoodIter(void *) {}
426 GoodIter
operator++() { return *this; }
427 GoodIter
operator--() { return *this; }
428 bool operator!() { return true; }
429 bool operator<(GoodIter a
) { return true; }
430 bool operator<=(GoodIter a
) { return true; }
431 bool operator>=(GoodIter a
) { return false; }
432 typedef int difference_type
;
433 typedef std::random_access_iterator_tag iterator_category
;
435 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
436 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
437 int operator-(GoodIter a
, GoodIter b
) { return 0; }
438 // expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
439 GoodIter
operator-(GoodIter a
) { return a
; }
440 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
441 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
442 GoodIter
operator-(GoodIter a
, int v
) { return GoodIter(); }
443 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
444 GoodIter
operator+(GoodIter a
, int v
) { return GoodIter(); }
445 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
446 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
447 GoodIter
operator-(int v
, GoodIter a
) { return GoodIter(); }
448 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
449 GoodIter
operator+(int v
, GoodIter a
) { return GoodIter(); }
451 int test_with_random_access_iterator() {
455 #pragma omp master taskloop simd
456 for (GoodIter I
= begin
; I
< end
; ++I
)
459 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
460 #pragma omp master taskloop simd
461 for (GoodIter
&I
= begin
; I
< end
; ++I
)
464 #pragma omp master taskloop simd
465 for (GoodIter I
= begin
; I
>= end
; --I
)
468 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
469 #pragma omp master taskloop simd
470 for (GoodIter
I(begin
); I
< end
; ++I
)
473 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
474 #pragma omp master taskloop simd
475 for (GoodIter
I(nullptr); I
< end
; ++I
)
478 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
479 #pragma omp master taskloop simd
480 for (GoodIter
I(0); I
< end
; ++I
)
483 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
484 #pragma omp master taskloop simd
485 for (GoodIter
I(1, 2); I
< end
; ++I
)
488 #pragma omp master taskloop simd
489 for (begin
= GoodIter(0); begin
< end
; ++begin
)
491 // expected-error@+4 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
492 // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
494 #pragma omp master taskloop simd
495 for (begin
= begin0
; begin
< end
; ++begin
)
498 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
499 #pragma omp master taskloop simd
500 for (++begin
; begin
< end
; ++begin
)
503 #pragma omp master taskloop simd
504 for (begin
= end
; begin
< end
; ++begin
)
507 // 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'}}
508 #pragma omp master taskloop simd
509 for (GoodIter I
= begin
; I
- I
; ++I
)
512 // 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'}}
513 #pragma omp master taskloop simd
514 for (GoodIter I
= begin
; begin
< end
; ++I
)
517 // 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'}}
518 #pragma omp master taskloop simd
519 for (GoodIter I
= begin
; !I
; ++I
)
522 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
523 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
524 #pragma omp master taskloop simd
525 for (GoodIter I
= begin
; I
>= end
; I
= I
+ 1)
528 #pragma omp master taskloop simd
529 for (GoodIter I
= begin
; I
>= end
; I
= I
- 1)
532 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
533 #pragma omp master taskloop simd
534 for (GoodIter I
= begin
; I
>= end
; I
= -I
)
537 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
538 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
539 #pragma omp master taskloop simd
540 for (GoodIter I
= begin
; I
>= end
; I
= 2 + I
)
543 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
544 #pragma omp master taskloop simd
545 for (GoodIter I
= begin
; I
>= end
; I
= 2 - I
)
547 // In the following example, we cannot update the loop variable using '+='
548 // expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
550 #pragma omp master taskloop simd
551 for (Iter0 I
= begin0
; I
< end0
; ++I
)
554 // Initializer is constructor without params.
555 // expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
556 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
557 #pragma omp master taskloop simd
558 for (Iter0 I
; I
< end0
; ++I
)
561 // expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
562 // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
564 #pragma omp master taskloop simd
565 for (Iter1 I
= begin1
; I
< end1
; ++I
)
568 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
569 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
570 #pragma omp master taskloop simd
571 for (Iter1 I
= begin1
; I
>= end1
; ++I
)
574 // expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'float')}}
575 // expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
576 // Initializer is constructor with all default params.
577 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
578 #pragma omp master taskloop simd
579 for (Iter1 I
; I
< end1
; ++I
) {
584 template <typename IT
, int ST
>
587 int dotest_lt(IT begin
, IT end
) {
589 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
590 // expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
591 #pragma omp master taskloop simd
592 for (IT I
= begin
; I
< end
; I
= I
+ ST
) {
596 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
597 // expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
598 #pragma omp master taskloop simd
599 for (IT I
= begin
; I
<= end
; I
+= ST
) {
603 #pragma omp master taskloop simd
604 for (IT I
= begin
; I
< end
; ++I
) {
613 template <typename IT
, int ST
= 0>
614 int dotest_gt(IT begin
, IT end
) {
616 // expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
617 // expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
618 #pragma omp master taskloop simd
619 for (IT I
= begin
; I
>= end
; I
= I
+ ST
) {
623 // expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
624 // expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
625 #pragma omp master taskloop simd
626 for (IT I
= begin
; I
>= end
; I
+= ST
) {
631 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
632 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
633 #pragma omp master taskloop simd
634 for (IT I
= begin
; I
>= end
; ++I
) {
639 #pragma omp master taskloop simd
640 for (IT I
= begin
; I
< end
; I
+= TC
<int, ST
>::step()) {
645 void test_with_template() {
647 TC
<GoodIter
, 100> t1
;
648 TC
<GoodIter
, -100> t2
;
649 t1
.dotest_lt(begin
, end
);
650 t2
.dotest_lt(begin
, end
); // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
651 dotest_gt(begin
, end
); // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
652 dotest_gt
<unsigned, 10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, 10>' requested here}}
655 void test_loop_break() {
657 float a
[N
], b
[N
], c
[N
];
659 #pragma omp master taskloop simd
660 for (int i
= 0; i
< 10; i
++) {
662 for (int j
= 0; j
< 10; ++j
) {
664 break; // OK in nested loop
674 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
677 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
681 #pragma omp master taskloop simd
682 for (int i
= 0; i
< 10; i
++) {
683 for (int j
= 0; j
< 10; j
++) {
694 void test_loop_eh() {
696 float a
[N
], b
[N
], c
[N
];
698 #pragma omp master taskloop simd
699 for (int i
= 0; i
< 10; i
++) {
701 try { // expected-error {{'try' statement cannot be used in OpenMP simd region}}
702 for (int j
= 0; j
< 10; ++j
) {
704 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
706 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
709 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
710 return; // expected-error {{cannot return from OpenMP region}}
719 for (int j
= 0; j
< 10; j
++) {
721 throw c
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
728 #pragma omp master taskloop simd
729 for (int i
= 0; i
< 10; ++i
) {
731 void g() { throw 0; }
736 void test_loop_firstprivate_lastprivate() {
739 #pragma omp master taskloop simd lastprivate(s) firstprivate(s)
740 for (int i
= 0; i
< 16; ++i
)