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}}
34 for (int i
= 0; i
< 10; i
+= 1) {
39 for (char i
= 0; i
< 10; i
++) {
44 for (char i
= 0; i
< 10; i
+= '\1') {
49 for (long long i
= 0; i
< 10; i
++) {
53 // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'double'}}
55 for (long long i
= 0; i
< 10; i
+= 1.5) {
60 for (long long i
= 0; i
< 'z'; i
+= 1u) {
64 // expected-error@+2 {{variable must be of integer or random access iterator type}}
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}}
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')}}
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')}}
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')}}
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')}}
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')}}
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')}}
108 for (c
[ii
] = 0; ii
< 10; ++ii
)
112 // Ok to skip parenthesises.
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'}}
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'}}
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'}}
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'}}
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'}}
145 for (int i
= 0;; i
++)
151 for (int i
= 11; i
> 10; i
--)
157 for (int i
= 0; i
< 10; ++i
)
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'}}
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'}}
175 for (ii
= 0; ii
< 10; ++++ii
)
179 // Ok but undefined behavior (in general, cannot check that incr
180 // is really loop-invariant).
182 for (ii
= 0; ii
< 10; ii
= ii
+ ii
)
186 // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'float'}}
188 for (ii
= 0; ii
< 10; ii
= ii
+ 1.0f
)
192 // Ok - step was converted to integer type.
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'}}
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'}}
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'}}
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'}}
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'}}
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'}}
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}}
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}}
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}}
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}}
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}}
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}}
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}}
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}}
288 for (ii
= 0; (ii
< 10); (ii
-= 0))
292 // expected-error@+3 {{the loop initializer expression depends on the current loop control variable}}
293 // expected-error@+2 2 {{the loop condition expression depends on the current loop control variable}}
295 for (ii
= ii
* 10 + 25; ii
< ii
/ ii
- 23; ii
+= 1)
298 // expected-error@+3 {{expected loop invariant expression or '<invariant1> * ii + <invariant2>' kind of expression}}
299 #pragma omp for collapse(2)
300 for (ii
= 10 + 25; ii
< 1000; ii
+= 1)
301 for (kk
= ii
* 10 + 25; kk
< ii
/ ii
- 23; kk
+= 1)
304 // expected-error@+4 {{expected loop invariant expression or '<invariant1> * ii + <invariant2>' kind of expression}}
305 #pragma omp for collapse(3)
306 for (ii
= 10 + 25; ii
< 1000; ii
+= 1)
307 for (jj
= 10 + 25; jj
< 1000; jj
+= 1)
308 for (kk
= ii
* 10 + 25; kk
< jj
- 23; kk
+= 1)
312 // expected-note@+2 {{defined as firstprivate}}
313 // expected-error@+2 {{loop iteration variable in the associated loop of 'omp for' directive may not be firstprivate, predetermined as private}}
314 #pragma omp for firstprivate(ii)
315 for (ii
= 0; ii
< 10; ii
++)
319 // expected-note@+2 {{defined as linear}}
320 // expected-error@+2 {{loop iteration variable in the associated loop of 'omp for' directive may not be linear, predetermined as private}}
321 #pragma omp for linear(ii)
322 for (ii
= 0; ii
< 10; ii
++)
326 #pragma omp for private(ii)
327 for (ii
= 0; ii
< 10; ii
++)
331 #pragma omp for lastprivate(ii)
332 for (ii
= 0; ii
< 10; ii
++)
337 // expected-error@+2 {{loop iteration variable in the associated loop of 'omp for' directive may not be threadprivate or thread local, predetermined as private}}
339 for (sii
= 0; sii
< 10; sii
+= 1)
346 for (reg0
= 0; reg0
< 10; reg0
+= 1)
353 for (reg
= 0; reg
< 10; reg
+= 1)
360 for (globalii
= 0; globalii
< 10; globalii
+= 1)
361 c
[globalii
] = a
[globalii
];
366 #pragma omp for collapse(2)
367 for (ii
= 0; ii
< 10; ii
+= 1)
368 for (globalii
= 0; globalii
< 10; globalii
+= 1)
369 c
[globalii
] += a
[globalii
] + ii
;
373 // omp4-error@+2 {{statement after '#pragma omp for' must be a for loop}}
375 for (auto &item
: a
) {
380 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
381 // expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
383 for (unsigned i
= 9; i
< 10; i
--) {
387 int(*lb
)[4] = nullptr;
390 for (int(*p
)[4] = lb
; p
< lb
+ 8; ++p
) {
394 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
396 for (int a
{0}; a
< 10; ++a
) {
402 // Iterators allowed in openmp for-loops.
404 struct random_access_iterator_tag
{};
405 template <class Iter
>
406 struct iterator_traits
{
407 typedef typename
Iter::difference_type difference_type
;
408 typedef typename
Iter::iterator_category iterator_category
;
410 template <class Iter
>
411 typename iterator_traits
<Iter
>::difference_type
412 distance(Iter first
, Iter last
) { return first
- last
; }
417 Iter0(const Iter0
&) {}
418 Iter0
operator++() { return *this; }
419 Iter0
operator--() { return *this; }
420 bool operator<(Iter0 a
) { return true; }
422 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
423 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
424 int operator-(Iter0 a
, Iter0 b
) { return 0; }
427 Iter1(float f
= 0.0f
, double d
= 0.0) {}
428 Iter1(const Iter1
&) {}
429 Iter1
operator++() { return *this; }
430 Iter1
operator--() { return *this; }
431 bool operator<(Iter1 a
) { return true; }
432 bool operator>=(Iter1 a
) { return false; }
437 GoodIter(const GoodIter
&) {}
438 GoodIter(int fst
, int snd
) {}
439 GoodIter
&operator=(const GoodIter
&that
) { return *this; }
440 GoodIter
&operator=(const Iter0
&that
) { return *this; }
441 GoodIter
&operator+=(int x
) { return *this; }
442 GoodIter
&operator-=(int x
) { return *this; }
443 explicit GoodIter(void *) {}
444 GoodIter
operator++() { return *this; }
445 GoodIter
operator--() { return *this; }
446 bool operator!() { return true; }
447 bool operator<(GoodIter a
) { return true; }
448 bool operator<=(GoodIter a
) { return true; }
449 bool operator>=(GoodIter a
) { return false; }
450 typedef int difference_type
;
451 typedef std::random_access_iterator_tag iterator_category
;
456 GoodIter1(const GoodIter1
&) {}
457 GoodIter1
&operator++(int) { return *this; }
458 GoodIter1
&operator=(const GoodIter1
&that
) { return *this; }
459 GoodIter1
&operator+=(int x
) { return *this; }
460 friend long operator-(const GoodIter1
&, const GoodIter1
&);
461 GoodIter1
&operator-(int) { return *this; }
462 bool operator<(GoodIter1 a
) { return true; }
463 typedef int difference_type
;
464 typedef std::random_access_iterator_tag iterator_category
;
466 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
467 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
468 int operator-(GoodIter a
, GoodIter b
) { return 0; }
469 // expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
470 GoodIter
operator-(GoodIter a
) { return a
; }
471 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
472 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
473 GoodIter
operator-(GoodIter a
, int v
) { return GoodIter(); }
474 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
475 GoodIter
operator+(GoodIter a
, int v
) { return GoodIter(); }
476 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
477 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
478 GoodIter
operator-(int v
, GoodIter a
) { return GoodIter(); }
479 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
480 GoodIter
operator+(int v
, GoodIter a
) { return GoodIter(); }
482 int test_with_random_access_iterator() {
487 for (GoodIter I
= begin
; I
< end
; ++I
)
490 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
492 for (GoodIter
&I
= begin
; I
< end
; ++I
)
496 for (GoodIter I
= begin
; I
>= end
; --I
)
499 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
501 for (GoodIter
I(begin
); I
< end
; ++I
)
504 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
506 for (GoodIter
I(nullptr); I
< end
; ++I
)
509 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
511 for (GoodIter
I(0); I
< end
; ++I
)
514 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
516 for (GoodIter
I(1, 2); I
< end
; ++I
)
520 for (begin
= GoodIter(0); begin
< end
; ++begin
)
522 // expected-error@+4 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
523 // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
526 for (begin
= begin0
; begin
< end
; ++begin
)
529 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
531 for (++begin
; begin
< end
; ++begin
)
535 for (begin
= end
; begin
< end
; ++begin
)
538 // 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'}}
540 for (GoodIter I
= begin
; I
- I
; ++I
)
543 // 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'}}
545 for (GoodIter I
= begin
; begin
< end
; ++I
)
548 // 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'}}
550 for (GoodIter I
= begin
; !I
; ++I
)
553 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
554 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
556 for (GoodIter I
= begin
; I
>= end
; I
= I
+ 1)
560 for (GoodIter I
= begin
; I
>= end
; I
= I
- 1)
563 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
565 for (GoodIter I
= begin
; I
>= end
; I
= -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}}
571 for (GoodIter I
= begin
; I
>= end
; I
= 2 + I
)
574 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
576 for (GoodIter I
= begin
; I
>= end
; I
= 2 - I
)
578 // In the following example, we cannot update the loop variable using '+='
579 // expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
582 for (Iter0 I
= begin0
; I
< end0
; ++I
)
585 // Initializer is constructor without params.
586 // expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
587 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
589 for (Iter0 I
; I
< end0
; ++I
)
592 // expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
593 // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
596 for (Iter1 I
= begin1
; I
< end1
; ++I
)
599 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
600 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
602 for (Iter1 I
= begin1
; I
>= end1
; ++I
)
605 // expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'float')}}
606 // expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
607 // Initializer is constructor with all default params.
608 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
610 for (Iter1 I
; I
< end1
; ++I
) {
613 // expected-error@+4 {{expected an integer or a pointer type of the outer loop counter 'I' for non-rectangular nests}}
614 // expected-error@+4 {{expected an integer or a pointer type of the outer loop counter 'I' for non-rectangular nests}}
615 #pragma omp for collapse(3)
616 for (GoodIter1 I
= I1
; I
< E1
; I
++) // expected-note 2 {{'I' declared here}}
617 for (int i
= (I
- I1
) * 10 + 25; i
< 23; i
+= 1)
618 for (int j
= 10 + 25; j
< 23 + (I
- E1
); j
+= 1)
622 for (GoodIter1 I
= I1
; I
< E1
; I
++)
627 template <typename IT
, int ST
>
631 enum { myconstant
= 42 };
633 int dotest_lt(IT begin
, IT end
) {
635 // expected-error@+3 3 {{the loop initializer expression depends on the current loop control variable}}
636 // expected-error@+2 6 {{the loop condition expression depends on the current loop control variable}}
638 for (ii
= ii
* 10 + 25; ii
< ii
/ ii
- 23; ii
+= 1)
641 // Check that member function calls and enum constants in the condition is
644 for (ii
= 0; ii
< ub() + this->myconstant
; ii
+= 1) // expected-no-error
648 // expected-error@+4 2 {{expected loop invariant expression or '<invariant1> * ii + <invariant2>' kind of expression}}
649 // expected-error@+3 {{expected loop invariant expression or '<invariant1> * TC::ii + <invariant2>' kind of expression}}
650 #pragma omp for collapse(2)
651 for (ii
= 10 + 25; ii
< 1000; ii
+= 1)
652 for (iii
= ii
* 10 + 25; iii
< ii
/ ii
- 23; iii
+= 1)
656 // expected-error@+6 {{expected loop invariant expression or '<invariant1> * TC::ii + <invariant2>' kind of expression}}
657 // expected-error@+6 {{expected loop invariant expression or '<invariant1> * TC::ii + <invariant2>' kind of expression}}
658 // expected-error@+4 2 {{expected loop invariant expression or '<invariant1> * ii + <invariant2>' kind of expression}}
659 // expected-error@+4 2 {{expected loop invariant expression or '<invariant1> * ii + <invariant2>' kind of expression}}
660 #pragma omp for collapse(3)
661 for (ii
= 10 + 25; ii
< 1000; ii
+= 1)
662 for (iii
= ii
* 10 + 25; iii
< ii
/ ii
- 23; iii
+= 1)
663 for (kk
= ii
* 10 + 25; kk
< iii
- 23; kk
+= 1)
667 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
668 // expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
670 for (IT I
= begin
; I
< end
; I
= I
+ ST
) {
674 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
675 // expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
677 for (IT I
= begin
; I
<= end
; I
+= ST
) {
682 for (IT I
= begin
; I
< end
; ++I
) {
691 template <typename IT
, int ST
= 0>
692 int dotest_gt(IT begin
, IT end
) {
694 // expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
695 // expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
697 for (IT I
= begin
; I
>= end
; I
= I
+ ST
) {
701 // expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
702 // expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
704 for (IT I
= begin
; I
>= end
; I
+= ST
) {
709 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
710 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
712 for (IT I
= begin
; I
>= end
; ++I
) {
718 for (IT I
= begin
; I
< end
; I
+= TC
<int, ST
>::step()) {
723 void test_with_template() {
725 TC
<GoodIter
, 100> t1
;
726 TC
<GoodIter
, -100> t2
;
727 t1
.dotest_lt(begin
, end
); // expected-note {{in instantiation of member function 'TC<GoodIter, 100>::dotest_lt' requested here}}
728 t2
.dotest_lt(begin
, end
); // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
729 dotest_gt(begin
, end
); // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
730 dotest_gt
<unsigned, 10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, 10>' requested here}}
733 void test_loop_break() {
735 float a
[N
], b
[N
], c
[N
];
738 for (int i
= 0; i
< 10; i
++) {
740 for (int j
= 0; j
< 10; ++j
) {
742 break; // OK in nested loop
752 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
755 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
760 for (int i
= 0; i
< 10; i
++) {
761 for (int j
= 0; j
< 10; j
++) {
772 void test_loop_eh() {
774 float a
[N
], b
[N
], c
[N
];
777 for (int i
= 0; i
< 10; i
++) {
780 for (int j
= 0; j
< 10; ++j
) {
788 return; // expected-error {{cannot return from OpenMP region}}
797 for (int j
= 0; j
< 10; j
++) {
807 for (int i
= 0; i
< 10; ++i
) {
809 void g() { throw 0; }
814 void test_loop_firstprivate_lastprivate() {
817 #pragma omp for lastprivate(s) firstprivate(s)
818 for (int i
= 0; i
< 16; ++i
)
822 void test_ordered() {
824 #pragma omp for ordered ordered // expected-error {{directive '#pragma omp for' cannot contain more than one 'ordered' clause}}
825 for (int i
= 0; i
< 16; ++i
)
831 #pragma omp for nowait nowait // expected-error {{directive '#pragma omp for' cannot contain more than one 'nowait' clause}}
832 for (int i
= 0; i
< 16; ++i
)
836 void test_static_data_member() {
839 for (int i
= 0; i
< 16; ++i
) {
841 static int x
; // expected-error {{static data member 'x' not allowed in local class 'X'}}