1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp4 %s -Wno-openmp-mapping -Wuninitialized
2 // RUN: %clang_cc1 -fsyntax-only -fopenmp -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp5 %s -Wno-openmp-mapping -Wuninitialized
4 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp4 %s -Wno-openmp-mapping -Wuninitialized
5 // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -x c++ -std=c++11 -fexceptions -fcxx-exceptions -verify=expected,omp5 %s -Wno-openmp-mapping -Wuninitialized
9 S() : a(0) {} // expected-note {{implicitly declared private here}}
13 S(const S
&s
) : a(s
.a
) {}
17 // expected-note@+1 {{defined as threadprivate or thread local}}
18 #pragma omp threadprivate(sii)
21 int test_iteration_spaces() {
23 float a
[N
], b
[N
], c
[N
];
29 #pragma omp distribute parallel for simd
30 for (int i
= 0; i
< 10; i
+= 1) {
35 #pragma omp distribute parallel for simd
36 for (char i
= 0; i
< 10; i
++) {
41 #pragma omp distribute parallel for simd
42 for (char i
= 0; i
< 10; i
+= '\1') {
47 #pragma omp distribute parallel for simd
48 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 distribute parallel for simd
55 for (long long i
= 0; i
< 10; i
+= 1.5) {
60 #pragma omp distribute parallel for simd
61 for (long long i
= 0; i
< 'z'; i
+= 1u) {
66 // expected-error@+2 {{variable must be of integer or random access iterator type}}
67 #pragma omp distribute parallel for simd
68 for (float fi
= 0; fi
< 10.0; fi
++) {
69 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
73 // expected-error@+2 {{variable must be of integer or random access iterator type}}
74 #pragma omp distribute parallel for simd
75 for (double fi
= 0; fi
< 10.0; fi
++) {
76 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
80 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
81 #pragma omp distribute parallel for simd
82 for (int &ref
= ii
; ref
< 10; ref
++) {
86 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
87 #pragma omp distribute parallel for simd
88 for (int i
; 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 distribute parallel for simd
95 for (int i
= 0, j
= 0; i
< 10; ++i
)
100 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
101 #pragma omp distribute parallel for simd
102 for (; ii
< 10; ++ii
)
107 // expected-warning@+3 {{expression result unused}}
108 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
109 #pragma omp distribute parallel for simd
110 for (ii
+ 1; ii
< 10; ++ii
)
115 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
116 #pragma omp distribute parallel for simd
117 for (c
[ii
] = 0; ii
< 10; ++ii
)
122 // Ok to skip parenthesises.
123 #pragma omp distribute parallel for simd
124 for (((ii
)) = 0; ii
< 10; ++ii
)
129 // 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'}}
130 #pragma omp distribute parallel for simd
131 for (int i
= 0; i
; i
++)
136 // 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'}}
137 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}}
138 #pragma omp distribute parallel for simd
139 for (int i
= 0; jj
< kk
; ii
++)
144 // 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 #pragma omp distribute parallel for simd
146 for (int i
= 0; !!i
; i
++)
151 // omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
152 #pragma omp distribute parallel for simd
153 for (int i
= 0; i
!= 1; i
++)
158 // 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'}}
159 #pragma omp distribute parallel for simd
160 for (int i
= 0;; i
++)
166 #pragma omp distribute parallel for simd
167 for (int i
= 11; i
> 10; i
--)
173 #pragma omp distribute parallel for simd
174 for (int i
= 0; i
< 10; ++i
)
180 #pragma omp distribute parallel for simd
181 for (ii
= 0; ii
< 10; ++ii
)
186 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
187 #pragma omp distribute parallel for simd
188 for (ii
= 0; ii
< 10; ++jj
)
193 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
194 #pragma omp distribute parallel for simd
195 for (ii
= 0; ii
< 10; ++++ii
)
198 // Ok but undefined behavior (in general, cannot check that incr
199 // is really loop-invariant).
202 #pragma omp distribute parallel for simd
203 for (ii
= 0; ii
< 10; ii
= ii
+ ii
)
208 // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'float'}}
209 #pragma omp distribute parallel for simd
210 for (ii
= 0; ii
< 10; ii
= ii
+ 1.0f
)
213 // Ok - step was converted to integer type.
216 #pragma omp distribute parallel for simd
217 for (ii
= 0; ii
< 10; ii
= ii
+ (int)1.1f
)
222 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
223 #pragma omp distribute parallel for simd
224 for (ii
= 0; ii
< 10; jj
= ii
+ 2)
229 // expected-warning@+3 {{relational comparison result unused}}
230 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
231 #pragma omp distribute parallel for simd
232 for (ii
= 0; ii
<10; jj
> kk
+ 2)
237 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
238 #pragma omp distribute parallel for simd
239 for (ii
= 0; ii
< 10;)
244 // expected-warning@+3 {{expression result unused}}
245 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
246 #pragma omp distribute parallel for simd
247 for (ii
= 0; ii
< 10; !ii
)
252 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
253 #pragma omp distribute parallel for simd
254 for (ii
= 0; ii
< 10; ii
? ++ii
: ++jj
)
259 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
260 #pragma omp distribute parallel for simd
261 for (ii
= 0; ii
< 10; ii
= ii
< 10)
266 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
267 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
268 #pragma omp distribute parallel for simd
269 for (ii
= 0; ii
< 10; ii
= ii
+ 0)
274 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
275 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
276 #pragma omp distribute parallel for simd
277 for (ii
= 0; ii
< 10; ii
= ii
+ (int)(0.8 - 0.45))
282 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
283 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
284 #pragma omp distribute parallel for simd
285 for (ii
= 0; (ii
) < 10; ii
-= 25)
290 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
291 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
292 #pragma omp distribute parallel for simd
293 for (ii
= 0; (ii
< 10); ii
-= 0)
298 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
299 // expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
300 #pragma omp distribute parallel for simd
301 for (ii
= 0; ii
> 10; (ii
+= 0))
306 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
307 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
308 #pragma omp distribute parallel for simd
309 for (ii
= 0; ii
< 10; (ii
) = (1 - 1) + (ii
))
314 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
315 // expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
316 #pragma omp distribute parallel for simd
317 for ((ii
= 0); ii
> 10; (ii
-= 0))
322 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
323 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
324 #pragma omp distribute parallel for simd
325 for (ii
= 0; (ii
< 10); (ii
-= 0))
330 // expected-note@+2 {{defined as firstprivate}}
331 // expected-error@+2 {{loop iteration variable in the associated loop of 'omp distribute parallel for simd' directive may not be firstprivate, predetermined as linear}}
332 #pragma omp distribute parallel for simd firstprivate(ii)
333 for (ii
= 0; ii
< 10; ii
++)
338 #pragma omp distribute parallel for simd linear(ii)
339 for (ii
= 0; ii
< 10; ii
++)
344 // omp4-note@+2 {{defined as private}}
345 // omp4-error@+2 {{loop iteration variable in the associated loop of 'omp distribute parallel for simd' directive may not be private, predetermined as linear}}
346 #pragma omp distribute parallel for simd private(ii)
347 for (ii
= 0; ii
< 10; ii
++)
352 // omp4-note@+2 {{defined as lastprivate}}
353 // omp4-error@+2 {{loop iteration variable in the associated loop of 'omp distribute parallel for simd' directive may not be lastprivate, predetermined as linear}}
354 #pragma omp distribute parallel for simd lastprivate(ii)
355 for (ii
= 0; ii
< 10; ii
++)
359 // expected-error@+2 {{loop iteration variable in the associated loop of 'omp distribute parallel for simd' directive may not be threadprivate or thread local, predetermined as linear}}
360 #pragma omp distribute parallel for simd
361 for (sii
= 0; sii
< 10; sii
+= 1)
366 #pragma omp distribute parallel for simd
367 for (globalii
= 0; globalii
< 10; globalii
+= 1)
368 c
[globalii
] = a
[globalii
];
374 #pragma omp distribute parallel for simd collapse(2)
375 for (ii
= 0; ii
< 10; ii
+= 1)
376 for (globalii
= 0; globalii
< 10; globalii
+= 1)
377 c
[globalii
] += a
[globalii
] + ii
;
382 // omp4-error@+2 {{statement after '#pragma omp distribute parallel for simd' must be a for loop}}
383 #pragma omp distribute parallel for simd
384 for (auto &item
: a
) {
390 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
391 // expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
392 #pragma omp distribute parallel for simd
393 for (unsigned i
= 9; i
< 10; i
--) {
397 int(*lb
)[4] = nullptr;
400 #pragma omp distribute parallel for simd
401 for (int(*p
)[4] = lb
; p
< lb
+ 8; ++p
) {
406 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
407 #pragma omp distribute parallel for simd
408 for (int a
{0}; a
< 10; ++a
) {
414 // Iterators allowed in openmp for-loops.
416 struct random_access_iterator_tag
{};
417 template <class Iter
>
418 struct iterator_traits
{
419 typedef typename
Iter::difference_type difference_type
;
420 typedef typename
Iter::iterator_category iterator_category
;
422 template <class Iter
>
423 typename iterator_traits
<Iter
>::difference_type
424 distance(Iter first
, Iter last
) { return first
- last
; }
429 Iter0(const Iter0
&) {}
430 Iter0
operator++() { return *this; }
431 Iter0
operator--() { return *this; }
432 bool operator<(Iter0 a
) { return true; }
434 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
435 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
436 int operator-(Iter0 a
, Iter0 b
) { return 0; }
439 Iter1(float f
= 0.0f
, double d
= 0.0) {}
440 Iter1(const Iter1
&) {}
441 Iter1
operator++() { return *this; }
442 Iter1
operator--() { return *this; }
443 bool operator<(Iter1 a
) { return true; }
444 bool operator>=(Iter1 a
) { return false; }
449 GoodIter(const GoodIter
&) {}
450 GoodIter(int fst
, int snd
) {}
451 GoodIter
&operator=(const GoodIter
&that
) { return *this; }
452 GoodIter
&operator=(const Iter0
&that
) { return *this; }
453 GoodIter
&operator+=(int x
) { return *this; }
454 explicit GoodIter(void *) {}
455 GoodIter
operator++() { return *this; }
456 GoodIter
operator--() { return *this; }
457 bool operator!() { return true; }
458 bool operator<(GoodIter a
) { return true; }
459 bool operator<=(GoodIter a
) { return true; }
460 bool operator>=(GoodIter a
) { return false; }
461 typedef int difference_type
;
462 typedef std::random_access_iterator_tag iterator_category
;
464 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
465 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
466 int operator-(GoodIter a
, GoodIter b
) { return 0; }
467 // expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
468 GoodIter
operator-(GoodIter a
) { return a
; }
469 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
470 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
471 GoodIter
operator-(GoodIter a
, int v
) { return GoodIter(); }
472 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
473 GoodIter
operator+(GoodIter a
, int v
) { return GoodIter(); }
474 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
475 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
476 GoodIter
operator-(int v
, GoodIter a
) { return GoodIter(); }
477 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
478 GoodIter
operator+(int v
, GoodIter a
) { return GoodIter(); }
480 int test_with_random_access_iterator() {
485 #pragma omp distribute parallel for simd
486 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')}}
491 #pragma omp distribute parallel for simd
492 for (GoodIter
&I
= begin
; I
< end
; ++I
)
496 #pragma omp distribute parallel for simd
497 for (GoodIter I
= begin
; I
>= end
; --I
)
501 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
502 #pragma omp distribute parallel for simd
503 for (GoodIter
I(begin
); I
< end
; ++I
)
507 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
508 #pragma omp distribute parallel for simd
509 for (GoodIter
I(nullptr); I
< end
; ++I
)
513 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
514 #pragma omp distribute parallel for simd
515 for (GoodIter
I(0); I
< end
; ++I
)
519 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
520 #pragma omp distribute parallel for simd
521 for (GoodIter
I(1, 2); I
< end
; ++I
)
525 #pragma omp distribute parallel for simd
526 for (begin
= GoodIter(0); begin
< end
; ++begin
)
530 // expected-error@+3 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
531 // expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
532 #pragma omp distribute parallel for simd
533 for (begin
= begin0
; begin
< end
; ++begin
)
537 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
538 #pragma omp distribute parallel for simd
539 for (++begin
; begin
< end
; ++begin
)
543 #pragma omp distribute parallel for simd
544 for (begin
= end
; begin
< end
; ++begin
)
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'}}
549 #pragma omp distribute parallel for simd
550 for (GoodIter I
= begin
; I
- I
; ++I
)
554 // 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'}}
555 #pragma omp distribute parallel for simd
556 for (GoodIter I
= begin
; begin
< end
; ++I
)
560 // 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'}}
561 #pragma omp distribute parallel for simd
562 for (GoodIter I
= begin
; !I
; ++I
)
566 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
567 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
568 #pragma omp distribute parallel for simd
569 for (GoodIter I
= begin
; I
>= end
; I
= I
+ 1)
573 #pragma omp distribute parallel for simd
574 for (GoodIter I
= begin
; I
>= end
; I
= I
- 1)
578 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
579 #pragma omp distribute parallel for simd
580 for (GoodIter I
= begin
; I
>= end
; I
= -I
)
584 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
585 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
586 #pragma omp distribute parallel for simd
587 for (GoodIter I
= begin
; I
>= end
; I
= 2 + I
)
591 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
592 #pragma omp distribute parallel for simd
593 for (GoodIter I
= begin
; I
>= end
; I
= 2 - I
)
597 // expected-error@+2 {{invalid operands to binary expression ('Iter0' and 'int')}}
598 #pragma omp distribute parallel for simd
599 for (Iter0 I
= begin0
; I
< end0
; ++I
)
603 // Initializer is constructor without params.
604 // expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
605 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
606 #pragma omp distribute parallel for simd
607 for (Iter0 I
; I
< end0
; ++I
)
612 // expected-error@+3 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
613 // expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
614 #pragma omp distribute parallel for simd
615 for (Iter1 I
= begin1
; I
< end1
; ++I
)
619 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
620 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
621 #pragma omp distribute parallel for simd
622 for (Iter1 I
= begin1
; I
>= end1
; ++I
)
626 // expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'float')}}
627 // expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
628 // Initializer is constructor with all default params.
629 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
630 #pragma omp distribute parallel for simd
631 for (Iter1 I
; I
< end1
; ++I
) {
636 template <typename IT
, int ST
>
639 int dotest_lt(IT begin
, IT end
) {
642 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
643 // expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
644 #pragma omp distribute parallel for simd
645 for (IT I
= begin
; I
< end
; I
= I
+ ST
) {
650 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
651 // expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
652 #pragma omp distribute parallel for simd
653 for (IT I
= begin
; I
<= end
; I
+= ST
) {
658 #pragma omp distribute parallel for simd
659 for (IT I
= begin
; I
< end
; ++I
) {
668 template <typename IT
, int ST
= 0>
669 int dotest_gt(IT begin
, IT end
) {
672 // expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
673 // expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
674 #pragma omp distribute parallel for simd
675 for (IT I
= begin
; I
>= end
; I
= I
+ ST
) {
680 // expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
681 // expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
682 #pragma omp distribute parallel for simd
683 for (IT I
= begin
; I
>= end
; I
+= ST
) {
689 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
690 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
691 #pragma omp distribute parallel for simd
692 for (IT I
= begin
; I
>= end
; ++I
) {
696 #pragma omp distribute parallel for simd
697 for (IT I
= begin
; I
< end
; I
+= TC
<int, ST
>::step()) {
702 void test_with_template() {
704 TC
<GoodIter
, 100> t1
;
705 TC
<GoodIter
, -100> t2
;
706 t1
.dotest_lt(begin
, end
);
707 t2
.dotest_lt(begin
, end
); // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
708 dotest_gt(begin
, end
); // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
709 dotest_gt
<unsigned, 10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, 10>' requested here}}
712 void test_loop_break() {
714 float a
[N
], b
[N
], c
[N
];
717 #pragma omp distribute parallel for simd
718 for (int i
= 0; i
< 10; i
++) {
720 for (int j
= 0; j
< 10; ++j
) {
722 break; // OK in nested loop
732 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
735 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
740 #pragma omp distribute parallel for simd
741 for (int i
= 0; i
< 10; i
++) {
742 for (int j
= 0; j
< 10; j
++) {
753 void test_loop_eh() {
755 float a
[N
], b
[N
], c
[N
];
758 #pragma omp distribute parallel for simd
759 for (int i
= 0; i
< 10; i
++) {
761 try { // expected-error {{'try' statement cannot be used in OpenMP simd region}}
762 for (int j
= 0; j
< 10; ++j
) {
764 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
766 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
769 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
770 return; // expected-error {{cannot return from OpenMP region}}
779 for (int j
= 0; j
< 10; j
++) {
781 throw c
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
787 #pragma omp distribute parallel for simd
788 for (int i
= 0; i
< 10; ++i
) {
790 void g() { throw 0; }
795 void test_loop_firstprivate_lastprivate() {
797 // expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}}
800 #pragma omp distribute parallel for simd lastprivate(s) firstprivate(s) // expected-error {{calling a private constructor of class 'S'}}
801 for (int i
= 0; i
< 16; ++i
)
805 void test_ordered() {
808 #pragma omp distribute parallel for simd ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp distribute parallel for simd'}}
809 for (int i
= 0; i
< 16; ++i
)
816 // expected-error@+1 2 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp distribute parallel for simd'}}
817 #pragma omp distribute parallel for simd nowait nowait // expected-error {{directive '#pragma omp distribute parallel for simd' cannot contain more than one 'nowait' clause}}
818 for (int i
= 0; i
< 16; ++i
)