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 parallel master taskloop simd
34 for (int i
= 0; i
< 10; i
+= 1) {
38 #pragma omp parallel master taskloop simd
39 for (char i
= 0; i
< 10; i
++) {
43 #pragma omp parallel master taskloop simd
44 for (char i
= 0; i
< 10; i
+= '\1') {
48 #pragma omp parallel 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 parallel master taskloop simd
55 for (long long i
= 0; i
< 10; i
+= 1.5) {
59 #pragma omp parallel 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 parallel 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 parallel 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 parallel 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 parallel 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 parallel 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 parallel 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 parallel 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 parallel master taskloop simd
108 for (c
[ii
] = 0; ii
< 10; ++ii
)
112 // Ok to skip parenthesises.
113 #pragma omp parallel 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 parallel 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 parallel 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 parallel master taskloop simd
133 for (int i
= 0; !!i
; i
++)
138 // omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
139 #pragma omp parallel master taskloop simd
140 for (int i
= 0; i
!= 1; i
++)
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 parallel master taskloop simd
146 for (int i
= 0;; i
++)
151 #pragma omp parallel master taskloop simd
152 for (int i
= 11; i
> 10; i
--)
157 #pragma omp parallel master taskloop simd
158 for (int i
= 0; i
< 10; ++i
)
163 #pragma omp parallel master taskloop simd
164 for (ii
= 0; ii
< 10; ++ii
)
168 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
169 #pragma omp parallel master taskloop simd
170 for (ii
= 0; ii
< 10; ++jj
)
174 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
175 #pragma omp parallel master taskloop simd
176 for (ii
= 0; ii
< 10; ++++ii
)
180 // Ok but undefined behavior (in general, cannot check that incr
181 // is really loop-invariant).
182 #pragma omp parallel master taskloop simd
183 for (ii
= 0; ii
< 10; ii
= ii
+ ii
)
187 // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'float'}}
188 #pragma omp parallel master taskloop simd
189 for (ii
= 0; ii
< 10; ii
= ii
+ 1.0f
)
193 // Ok - step was converted to integer type.
194 #pragma omp parallel master taskloop simd
195 for (ii
= 0; ii
< 10; ii
= ii
+ (int)1.1f
)
199 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
200 #pragma omp parallel master taskloop simd
201 for (ii
= 0; ii
< 10; jj
= ii
+ 2)
205 // expected-warning@+3 {{relational comparison result unused}}
206 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
207 #pragma omp parallel master taskloop simd
208 for (ii
= 0; ii
<10; jj
> kk
+ 2)
212 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
213 #pragma omp parallel master taskloop simd
214 for (ii
= 0; ii
< 10;)
218 // expected-warning@+3 {{expression result unused}}
219 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
220 #pragma omp parallel master taskloop simd
221 for (ii
= 0; ii
< 10; !ii
)
225 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
226 #pragma omp parallel master taskloop simd
227 for (ii
= 0; ii
< 10; ii
? ++ii
: ++jj
)
231 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
232 #pragma omp parallel master taskloop simd
233 for (ii
= 0; ii
< 10; ii
= ii
< 10)
237 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
238 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
239 #pragma omp parallel master taskloop simd
240 for (ii
= 0; ii
< 10; ii
= ii
+ 0)
244 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
245 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
246 #pragma omp parallel master taskloop simd
247 for (ii
= 0; ii
< 10; ii
= ii
+ (int)(0.8 - 0.45))
251 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
252 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
253 #pragma omp parallel master taskloop simd
254 for (ii
= 0; (ii
) < 10; ii
-= 25)
258 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
259 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
260 #pragma omp parallel master taskloop simd
261 for (ii
= 0; (ii
< 10); ii
-= 0)
265 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
266 // expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
267 #pragma omp parallel master taskloop simd
268 for (ii
= 0; ii
> 10; (ii
+= 0))
272 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
273 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
274 #pragma omp parallel master taskloop simd
275 for (ii
= 0; ii
< 10; (ii
) = (1 - 1) + (ii
))
279 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
280 // expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
281 #pragma omp parallel master taskloop simd
282 for ((ii
= 0); ii
> 10; (ii
-= 0))
286 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
287 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
288 #pragma omp parallel master taskloop simd
289 for (ii
= 0; (ii
< 10); (ii
-= 0))
293 // expected-note@+2 {{defined as firstprivate}}
294 // expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel master taskloop simd' directive may not be firstprivate, predetermined as linear}}
295 #pragma omp parallel master taskloop simd firstprivate(ii)
296 for (ii
= 0; ii
< 10; ii
++)
300 // expected-error@+1 {{unexpected OpenMP clause 'in_reduction' in directive '#pragma omp parallel master taskloop simd'}}
301 #pragma omp parallel master taskloop simd in_reduction(+:ii)
302 for (ii
= 0; ii
< 10; ii
++)
306 #pragma omp parallel master taskloop simd linear(ii)
307 for (ii
= 0; ii
< 10; ii
++)
312 // expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel master taskloop simd' directive may not be threadprivate or thread local, predetermined as linear}}
313 #pragma omp parallel master taskloop simd
314 for (sii
= 0; sii
< 10; sii
+= 1)
320 #pragma omp parallel master taskloop simd
321 for (reg0
= 0; reg0
< 10; reg0
+= 1)
327 #pragma omp parallel master taskloop simd
328 for (reg
= 0; reg
< 10; reg
+= 1)
334 #pragma omp parallel master taskloop simd
335 for (globalii
= 0; globalii
< 10; globalii
+= 1)
336 c
[globalii
] = a
[globalii
];
341 #pragma omp parallel master taskloop simd collapse(2)
342 for (ii
= 0; ii
< 10; ii
+= 1)
343 for (globalii
= 0; globalii
< 10; globalii
+= 1)
344 c
[globalii
] += a
[globalii
] + ii
;
348 // omp4-error@+2 {{statement after '#pragma omp parallel master taskloop simd' must be a for loop}}
349 #pragma omp parallel master taskloop simd
350 for (auto &item
: a
) {
355 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
356 // expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
357 #pragma omp parallel master taskloop simd
358 for (unsigned i
= 9; i
< 10; i
--) {
362 int(*lb
)[4] = nullptr;
364 #pragma omp parallel master taskloop simd
365 for (int(*p
)[4] = lb
; p
< lb
+ 8; ++p
) {
369 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
370 #pragma omp parallel master taskloop simd
371 for (int a
{0}; a
< 10; ++a
) {
377 // Iterators allowed in openmp for-loops.
379 struct random_access_iterator_tag
{};
380 template <class Iter
>
381 struct iterator_traits
{
382 typedef typename
Iter::difference_type difference_type
;
383 typedef typename
Iter::iterator_category iterator_category
;
385 template <class Iter
>
386 typename iterator_traits
<Iter
>::difference_type
387 distance(Iter first
, Iter last
) { return first
- last
; }
392 Iter0(const Iter0
&) {}
393 Iter0
operator++() { return *this; }
394 Iter0
operator--() { return *this; }
395 bool operator<(Iter0 a
) { return true; }
397 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
398 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
399 int operator-(Iter0 a
, Iter0 b
) { return 0; }
402 Iter1(float f
= 0.0f
, double d
= 0.0) {}
403 Iter1(const Iter1
&) {}
404 Iter1
operator++() { return *this; }
405 Iter1
operator--() { return *this; }
406 bool operator<(Iter1 a
) { return true; }
407 bool operator>=(Iter1 a
) { return false; }
412 GoodIter(const GoodIter
&) {}
413 GoodIter(int fst
, int snd
) {}
414 GoodIter
&operator=(const GoodIter
&that
) { return *this; }
415 GoodIter
&operator=(const Iter0
&that
) { return *this; }
416 GoodIter
&operator+=(int x
) { return *this; }
417 GoodIter
&operator-=(int x
) { return *this; }
418 explicit GoodIter(void *) {}
419 GoodIter
operator++() { return *this; }
420 GoodIter
operator--() { return *this; }
421 bool operator!() { return true; }
422 bool operator<(GoodIter a
) { return true; }
423 bool operator<=(GoodIter a
) { return true; }
424 bool operator>=(GoodIter a
) { return false; }
425 typedef int difference_type
;
426 typedef std::random_access_iterator_tag iterator_category
;
428 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
429 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
430 int operator-(GoodIter a
, GoodIter b
) { return 0; }
431 // expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
432 GoodIter
operator-(GoodIter a
) { return a
; }
433 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
434 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
435 GoodIter
operator-(GoodIter a
, int v
) { return GoodIter(); }
436 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
437 GoodIter
operator+(GoodIter a
, int v
) { return GoodIter(); }
438 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
439 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
440 GoodIter
operator-(int v
, GoodIter a
) { return GoodIter(); }
441 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
442 GoodIter
operator+(int v
, GoodIter a
) { return GoodIter(); }
444 int test_with_random_access_iterator() {
448 #pragma omp parallel master taskloop simd
449 for (GoodIter I
= begin
; I
< end
; ++I
)
452 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
453 #pragma omp parallel master taskloop simd
454 for (GoodIter
&I
= begin
; I
< end
; ++I
)
457 #pragma omp parallel master taskloop simd
458 for (GoodIter I
= begin
; I
>= end
; --I
)
461 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
462 #pragma omp parallel master taskloop simd
463 for (GoodIter
I(begin
); I
< end
; ++I
)
466 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
467 #pragma omp parallel master taskloop simd
468 for (GoodIter
I(nullptr); I
< end
; ++I
)
471 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
472 #pragma omp parallel master taskloop simd
473 for (GoodIter
I(0); I
< end
; ++I
)
476 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
477 #pragma omp parallel master taskloop simd
478 for (GoodIter
I(1, 2); I
< end
; ++I
)
481 #pragma omp parallel master taskloop simd
482 for (begin
= GoodIter(0); begin
< end
; ++begin
)
484 // expected-error@+4 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
485 // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
487 #pragma omp parallel master taskloop simd
488 for (begin
= begin0
; begin
< end
; ++begin
)
491 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
492 #pragma omp parallel master taskloop simd
493 for (++begin
; begin
< end
; ++begin
)
496 #pragma omp parallel master taskloop simd
497 for (begin
= end
; begin
< end
; ++begin
)
500 // 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'}}
501 #pragma omp parallel master taskloop simd
502 for (GoodIter I
= begin
; I
- I
; ++I
)
505 // 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'}}
506 #pragma omp parallel master taskloop simd
507 for (GoodIter I
= begin
; begin
< end
; ++I
)
510 // 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'}}
511 #pragma omp parallel master taskloop simd
512 for (GoodIter I
= begin
; !I
; ++I
)
515 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
516 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
517 #pragma omp parallel master taskloop simd
518 for (GoodIter I
= begin
; I
>= end
; I
= I
+ 1)
521 #pragma omp parallel master taskloop simd
522 for (GoodIter I
= begin
; I
>= end
; I
= I
- 1)
525 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
526 #pragma omp parallel master taskloop simd
527 for (GoodIter I
= begin
; I
>= end
; I
= -I
)
530 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
531 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
532 #pragma omp parallel master taskloop simd
533 for (GoodIter I
= begin
; I
>= end
; I
= 2 + I
)
536 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
537 #pragma omp parallel master taskloop simd
538 for (GoodIter I
= begin
; I
>= end
; I
= 2 - I
)
540 // In the following example, we cannot update the loop variable using '+='
541 // expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
543 #pragma omp parallel master taskloop simd
544 for (Iter0 I
= begin0
; I
< end0
; ++I
)
547 // Initializer is constructor without params.
548 // expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
549 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
550 #pragma omp parallel master taskloop simd
551 for (Iter0 I
; I
< end0
; ++I
)
554 // expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
555 // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
557 #pragma omp parallel master taskloop simd
558 for (Iter1 I
= begin1
; I
< end1
; ++I
)
561 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
562 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
563 #pragma omp parallel master taskloop simd
564 for (Iter1 I
= begin1
; I
>= end1
; ++I
)
567 // expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'float')}}
568 // expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
569 // Initializer is constructor with all default params.
570 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
571 #pragma omp parallel master taskloop simd
572 for (Iter1 I
; I
< end1
; ++I
) {
577 template <typename IT
, int ST
>
580 int dotest_lt(IT begin
, IT end
) {
582 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
583 // expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
584 #pragma omp parallel master taskloop simd
585 for (IT I
= begin
; I
< end
; I
= I
+ ST
) {
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 parallel master taskloop simd
592 for (IT I
= begin
; I
<= end
; I
+= ST
) {
596 #pragma omp parallel master taskloop simd
597 for (IT I
= begin
; I
< end
; ++I
) {
606 template <typename IT
, int ST
= 0>
607 int dotest_gt(IT begin
, IT end
) {
609 // expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
610 // expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
611 #pragma omp parallel master taskloop simd
612 for (IT I
= begin
; I
>= end
; I
= I
+ ST
) {
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 parallel master taskloop simd
619 for (IT I
= begin
; I
>= end
; I
+= ST
) {
624 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
625 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
626 #pragma omp parallel master taskloop simd
627 for (IT I
= begin
; I
>= end
; ++I
) {
632 #pragma omp parallel master taskloop simd
633 for (IT I
= begin
; I
< end
; I
+= TC
<int, ST
>::step()) {
638 void test_with_template() {
640 TC
<GoodIter
, 100> t1
;
641 TC
<GoodIter
, -100> t2
;
642 t1
.dotest_lt(begin
, end
);
643 t2
.dotest_lt(begin
, end
); // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
644 dotest_gt(begin
, end
); // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
645 dotest_gt
<unsigned, 10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, 10>' requested here}}
648 void test_loop_break() {
650 float a
[N
], b
[N
], c
[N
];
652 #pragma omp parallel master taskloop simd
653 for (int i
= 0; i
< 10; i
++) {
655 for (int j
= 0; j
< 10; ++j
) {
657 break; // OK in nested loop
667 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
670 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
674 #pragma omp parallel master taskloop simd
675 for (int i
= 0; i
< 10; i
++) {
676 for (int j
= 0; j
< 10; j
++) {
687 void test_loop_eh() {
689 float a
[N
], b
[N
], c
[N
];
691 #pragma omp parallel master taskloop simd
692 for (int i
= 0; i
< 10; i
++) {
694 try { // expected-error {{'try' statement cannot be used in OpenMP simd region}}
695 for (int j
= 0; j
< 10; ++j
) {
697 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
699 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
702 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
703 return; // expected-error {{cannot return from OpenMP region}}
712 for (int j
= 0; j
< 10; j
++) {
714 throw c
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
721 #pragma omp parallel master taskloop simd
722 for (int i
= 0; i
< 10; ++i
) {
724 void g() { throw 0; }
729 void test_loop_firstprivate_lastprivate() {
733 #pragma omp parallel master taskloop simd lastprivate(s) firstprivate(s)
734 for (int i
= 0; i
< 16; ++i
)
736 #pragma omp parallel master taskloop simd if(c) default(none) // expected-error {{variable 'c' must have explicitly specified data sharing attributes}} expected-note {{explicit data sharing attribute requested here}}
737 for (int i
= 0; i
< 16; ++i
)
739 #pragma omp parallel master taskloop simd if(taskloop:c) default(none) // expected-error {{variable 'c' must have explicitly specified data sharing attributes}} expected-note {{explicit data sharing attribute requested here}}
740 for (int i
= 0; i
< 16; ++i
)
742 #pragma omp parallel master taskloop simd if(parallel:c) default(none)
743 for (int i
= 0; i
< 16; ++i
)