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 int test_iteration_spaces() {
23 float a
[N
], b
[N
], c
[N
];
27 #pragma omp parallel for simd
28 for (int i
= 0; i
< 10; i
+= 1) {
31 #pragma omp parallel for simd
32 for (char i
= 0; i
< 10; i
++) {
35 #pragma omp parallel for simd
36 for (char i
= 0; i
< 10; i
+= '\1') {
39 #pragma omp parallel for simd
40 for (long long i
= 0; i
< 10; i
++) {
43 // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'double'}}
44 #pragma omp parallel for simd
45 for (long long i
= 0; i
< 10; i
+= 1.5) {
48 #pragma omp parallel for simd
49 for (long long i
= 0; i
< 'z'; i
+= 1u) {
52 // expected-error@+2 {{variable must be of integer or random access iterator type}}
53 #pragma omp parallel for simd
54 for (float fi
= 0; fi
< 10.0; fi
++) {
55 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
57 // expected-error@+2 {{variable must be of integer or random access iterator type}}
58 #pragma omp parallel for simd
59 for (double fi
= 0; fi
< 10.0; fi
++) {
60 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
62 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
63 #pragma omp parallel for simd
64 for (int &ref
= ii
; ref
< 10; ref
++) {
66 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
67 #pragma omp parallel for simd
68 for (int i
; i
< 10; i
++)
71 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
72 #pragma omp parallel for simd
73 for (int i
= 0, j
= 0; i
< 10; ++i
)
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 for simd
81 // expected-warning@+3 {{expression result unused}}
82 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
83 #pragma omp parallel for simd
84 for (ii
+ 1; ii
< 10; ++ii
)
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 for simd
89 for (c
[ii
] = 0; ii
< 10; ++ii
)
92 // Ok to skip parenthesises.
93 #pragma omp parallel for simd
94 for (((ii
)) = 0; ii
< 10; ++ii
)
97 // 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'}}
98 #pragma omp parallel for simd
99 for (int i
= 0; i
; i
++)
102 // 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'}}
103 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}}
104 #pragma omp parallel for simd
105 for (int i
= 0; jj
< kk
; ii
++)
108 // 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'}}
109 #pragma omp parallel for simd
110 for (int i
= 0; !!i
; i
++)
113 // omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
114 #pragma omp parallel for simd
115 for (int i
= 0; i
!= 1; i
++)
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 for simd
120 for (int i
= 0;; i
++)
124 #pragma omp parallel for simd
125 for (int i
= 11; i
> 10; i
--)
129 #pragma omp parallel for simd
130 for (int i
= 0; i
< 10; ++i
)
134 #pragma omp parallel for simd
135 for (ii
= 0; ii
< 10; ++ii
)
138 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
139 #pragma omp parallel for simd
140 for (ii
= 0; ii
< 10; ++jj
)
143 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
144 #pragma omp parallel for simd
145 for (ii
= 0; ii
< 10; ++++ii
)
148 // Ok but undefined behavior (in general, cannot check that incr
149 // is really loop-invariant).
150 #pragma omp parallel for simd
151 for (ii
= 0; ii
< 10; ii
= ii
+ ii
)
154 // expected-error@+2 {{expression must have integral or unscoped enumeration type, not 'float'}}
155 #pragma omp parallel for simd
156 for (ii
= 0; ii
< 10; ii
= ii
+ 1.0f
)
159 // Ok - step was converted to integer type.
160 #pragma omp parallel for simd
161 for (ii
= 0; ii
< 10; ii
= ii
+ (int)1.1f
)
164 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
165 #pragma omp parallel for simd
166 for (ii
= 0; ii
< 10; jj
= ii
+ 2)
169 // expected-warning@+3 {{relational comparison result unused}}
170 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
171 #pragma omp parallel for simd
172 for (ii
= 0; ii
<10; jj
> kk
+ 2)
175 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
176 #pragma omp parallel for simd
177 for (ii
= 0; ii
< 10;)
180 // expected-warning@+3 {{expression result unused}}
181 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
182 #pragma omp parallel for simd
183 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 parallel for simd
188 for (ii
= 0; ii
< 10; ii
? ++ii
: ++jj
)
191 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
192 #pragma omp parallel for simd
193 for (ii
= 0; ii
< 10; ii
= ii
< 10)
196 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
197 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
198 #pragma omp parallel for simd
199 for (ii
= 0; ii
< 10; ii
= ii
+ 0)
202 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
203 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
204 #pragma omp parallel for simd
205 for (ii
= 0; ii
< 10; ii
= ii
+ (int)(0.8 - 0.45))
208 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
209 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
210 #pragma omp parallel for simd
211 for (ii
= 0; (ii
) < 10; ii
-= 25)
214 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
215 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
216 #pragma omp parallel for simd
217 for (ii
= 0; (ii
< 10); ii
-= 0)
220 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
221 // expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
222 #pragma omp parallel for simd
223 for (ii
= 0; ii
> 10; (ii
+= 0))
226 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
227 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
228 #pragma omp parallel for simd
229 for (ii
= 0; ii
< 10; (ii
) = (1 - 1) + (ii
))
232 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
233 // expected-error@+2 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
234 #pragma omp parallel for simd
235 for ((ii
= 0); ii
> 10; (ii
-= 0))
238 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
239 // expected-error@+2 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
240 #pragma omp parallel for simd
241 for (ii
= 0; (ii
< 10); (ii
-= 0))
244 // expected-note@+2 {{defined as firstprivate}}
245 // expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be firstprivate, predetermined as linear}}
246 #pragma omp parallel for simd firstprivate(ii)
247 for (ii
= 0; ii
< 10; ii
++)
250 #pragma omp parallel for simd linear(ii)
251 for (ii
= 0; ii
< 10; ii
++)
254 // omp4-note@+2 {{defined as private}}
255 // omp4-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be private, predetermined as linear}}
256 #pragma omp parallel for simd private(ii)
257 for (ii
= 0; ii
< 10; ii
++)
260 // omp4-note@+2 {{defined as lastprivate}}
261 // omp4-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be lastprivate, predetermined as linear}}
262 #pragma omp parallel for simd lastprivate(ii)
263 for (ii
= 0; ii
< 10; ii
++)
267 // expected-error@+2 {{loop iteration variable in the associated loop of 'omp parallel for simd' directive may not be threadprivate or thread local, predetermined as linear}}
268 #pragma omp parallel for simd
269 for (sii
= 0; sii
< 10; sii
+= 1)
274 #pragma omp parallel for simd
275 for (globalii
= 0; globalii
< 10; globalii
+= 1)
276 c
[globalii
] = a
[globalii
];
280 #pragma omp parallel for simd collapse(2)
281 for (ii
= 0; ii
< 10; ii
+= 1)
282 for (globalii
= 0; globalii
< 10; globalii
+= 1)
283 c
[globalii
] += a
[globalii
] + ii
;
286 // omp4-error@+2 {{statement after '#pragma omp parallel for simd' must be a for loop}}
287 #pragma omp parallel for simd
288 for (auto &item
: a
) {
292 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
293 // expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
294 #pragma omp parallel for simd
295 for (unsigned i
= 9; i
< 10; i
--) {
299 int(*lb
)[4] = nullptr;
300 #pragma omp parallel for simd
301 for (int(*p
)[4] = lb
; p
< lb
+ 8; ++p
) {
304 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
305 #pragma omp parallel for simd
306 for (int a
{0}; a
< 10; ++a
) {
312 // Iterators allowed in openmp for-loops.
314 struct random_access_iterator_tag
{};
315 template <class Iter
>
316 struct iterator_traits
{
317 typedef typename
Iter::difference_type difference_type
;
318 typedef typename
Iter::iterator_category iterator_category
;
320 template <class Iter
>
321 typename iterator_traits
<Iter
>::difference_type
322 distance(Iter first
, Iter last
) { return first
- last
; }
327 Iter0(const Iter0
&) {}
328 Iter0
operator++() { return *this; }
329 Iter0
operator--() { return *this; }
330 bool operator<(Iter0 a
) { return true; }
332 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
333 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
334 int operator-(Iter0 a
, Iter0 b
) { return 0; }
337 Iter1(float f
= 0.0f
, double d
= 0.0) {}
338 Iter1(const Iter1
&) {}
339 Iter1
operator++() { return *this; }
340 Iter1
operator--() { return *this; }
341 bool operator<(Iter1 a
) { return true; }
342 bool operator>=(Iter1 a
) { return false; }
347 GoodIter(const GoodIter
&) {}
348 GoodIter(int fst
, int snd
) {}
349 GoodIter
&operator=(const GoodIter
&that
) { return *this; }
350 GoodIter
&operator=(const Iter0
&that
) { return *this; }
351 GoodIter
&operator+=(int x
) { return *this; }
352 explicit GoodIter(void *) {}
353 GoodIter
operator++() { return *this; }
354 GoodIter
operator--() { return *this; }
355 bool operator!() { return true; }
356 bool operator<(GoodIter a
) { return true; }
357 bool operator<=(GoodIter a
) { return true; }
358 bool operator>=(GoodIter a
) { return false; }
359 typedef int difference_type
;
360 typedef std::random_access_iterator_tag iterator_category
;
362 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
363 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
364 int operator-(GoodIter a
, GoodIter b
) { return 0; }
365 // expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
366 GoodIter
operator-(GoodIter a
) { return a
; }
367 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
368 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
369 GoodIter
operator-(GoodIter a
, int v
) { return GoodIter(); }
370 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
371 GoodIter
operator+(GoodIter a
, int v
) { return GoodIter(); }
372 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
373 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
374 GoodIter
operator-(int v
, GoodIter a
) { return GoodIter(); }
375 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
376 GoodIter
operator+(int v
, GoodIter a
) { return GoodIter(); }
378 int test_with_random_access_iterator() {
381 #pragma omp parallel for simd
382 for (GoodIter I
= begin
; I
< end
; ++I
)
384 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
385 #pragma omp parallel for simd
386 for (GoodIter
&I
= begin
; I
< end
; ++I
)
388 #pragma omp parallel for simd
389 for (GoodIter I
= begin
; I
>= end
; --I
)
391 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
392 #pragma omp parallel for simd
393 for (GoodIter
I(begin
); I
< end
; ++I
)
395 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
396 #pragma omp parallel for simd
397 for (GoodIter
I(nullptr); I
< end
; ++I
)
399 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
400 #pragma omp parallel for simd
401 for (GoodIter
I(0); I
< end
; ++I
)
403 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
404 #pragma omp parallel for simd
405 for (GoodIter
I(1, 2); I
< end
; ++I
)
407 #pragma omp parallel for simd
408 for (begin
= GoodIter(0); begin
< end
; ++begin
)
410 // expected-error@+3 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
411 // expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
412 #pragma omp parallel for simd
413 for (begin
= begin0
; begin
< end
; ++begin
)
415 // expected-error@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
416 #pragma omp parallel for simd
417 for (++begin
; begin
< end
; ++begin
)
419 #pragma omp parallel for simd
420 for (begin
= end
; begin
< end
; ++begin
)
422 // 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'}}
423 #pragma omp parallel for simd
424 for (GoodIter I
= begin
; I
- I
; ++I
)
426 // 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'}}
427 #pragma omp parallel for simd
428 for (GoodIter I
= begin
; begin
< end
; ++I
)
430 // 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'}}
431 #pragma omp parallel for simd
432 for (GoodIter I
= begin
; !I
; ++I
)
434 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
435 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
436 #pragma omp parallel for simd
437 for (GoodIter I
= begin
; I
>= end
; I
= I
+ 1)
439 #pragma omp parallel for simd
440 for (GoodIter I
= begin
; I
>= end
; I
= I
- 1)
442 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
443 #pragma omp parallel for simd
444 for (GoodIter I
= begin
; I
>= end
; I
= -I
)
446 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
447 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
448 #pragma omp parallel for simd
449 for (GoodIter I
= begin
; I
>= end
; I
= 2 + I
)
451 // expected-error@+2 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
452 #pragma omp parallel for simd
453 for (GoodIter I
= begin
; I
>= end
; I
= 2 - I
)
455 // expected-error@+2 {{invalid operands to binary expression ('Iter0' and 'int')}}
456 #pragma omp parallel for simd
457 for (Iter0 I
= begin0
; I
< end0
; ++I
)
459 // Initializer is constructor without params.
460 // expected-error@+3 {{invalid operands to binary expression ('Iter0' and 'int')}}
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 for simd
463 for (Iter0 I
; I
< end0
; ++I
)
466 // expected-error@+3 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
467 // expected-error@+2 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
468 #pragma omp parallel for simd
469 for (Iter1 I
= begin1
; I
< end1
; ++I
)
471 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
472 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
473 #pragma omp parallel for simd
474 for (Iter1 I
= begin1
; I
>= end1
; ++I
)
476 // expected-error@+5 {{invalid operands to binary expression ('Iter1' and 'float')}}
477 // expected-error@+4 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
478 // Initializer is constructor with all default params.
479 // expected-warning@+2 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
480 #pragma omp parallel for simd
481 for (Iter1 I
; I
< end1
; ++I
) {
486 template <typename IT
, int ST
>
489 int dotest_lt(IT begin
, IT end
) {
490 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
491 // expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
492 #pragma omp parallel for simd
493 for (IT I
= begin
; I
< end
; I
= I
+ ST
) {
496 // expected-note@+3 {{loop step is expected to be positive due to this condition}}
497 // expected-error@+2 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
498 #pragma omp parallel for simd
499 for (IT I
= begin
; I
<= end
; I
+= ST
) {
502 #pragma omp parallel for simd
503 for (IT I
= begin
; I
< end
; ++I
) {
512 template <typename IT
, int ST
= 0>
513 int dotest_gt(IT begin
, IT end
) {
514 // expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
515 // expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
516 #pragma omp parallel for simd
517 for (IT I
= begin
; I
>= end
; I
= I
+ ST
) {
520 // expected-note@+3 2 {{loop step is expected to be negative due to this condition}}
521 // expected-error@+2 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
522 #pragma omp parallel for simd
523 for (IT I
= begin
; I
>= end
; I
+= ST
) {
527 // expected-note@+3 {{loop step is expected to be negative due to this condition}}
528 // expected-error@+2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
529 #pragma omp parallel for simd
530 for (IT I
= begin
; I
>= end
; ++I
) {
534 #pragma omp parallel for simd
535 for (IT I
= begin
; I
< end
; I
+= TC
<int, ST
>::step()) {
540 void test_with_template() {
542 TC
<GoodIter
, 100> t1
;
543 TC
<GoodIter
, -100> t2
;
544 t1
.dotest_lt(begin
, end
);
545 t2
.dotest_lt(begin
, end
); // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
546 dotest_gt(begin
, end
); // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
547 dotest_gt
<unsigned, 10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, 10>' requested here}}
550 void test_loop_break() {
552 float a
[N
], b
[N
], c
[N
];
553 #pragma omp parallel for simd
554 for (int i
= 0; i
< 10; i
++) {
556 for (int j
= 0; j
< 10; ++j
) {
558 break; // OK in nested loop
568 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
571 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
574 #pragma omp parallel for simd
575 for (int i
= 0; i
< 10; i
++) {
576 for (int j
= 0; j
< 10; j
++) {
587 void test_loop_eh() {
589 float a
[N
], b
[N
], c
[N
];
590 #pragma omp parallel for simd
591 for (int i
= 0; i
< 10; i
++) {
593 try { // expected-error {{'try' statement cannot be used in OpenMP simd region}}
594 for (int j
= 0; j
< 10; ++j
) {
596 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
598 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
601 throw a
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
602 return; // expected-error {{cannot return from OpenMP region}}
611 for (int j
= 0; j
< 10; j
++) {
613 throw c
[i
]; // expected-error {{'throw' statement cannot be used in OpenMP simd region}}
619 #pragma omp parallel for simd
620 for (int i
= 0; i
< 10; ++i
) {
622 void g() { throw 0; }
627 void test_loop_firstprivate_lastprivate() {
629 #pragma omp parallel for simd lastprivate(s) firstprivate(s)
630 for (int i
= 0; i
< 16; ++i
)
634 void test_ordered() {
635 #pragma omp parallel for simd ordered ordered // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'ordered' clause}}
636 for (int i
= 0; i
< 16; ++i
)
638 #pragma omp parallel for simd ordered
639 for (int i
= 0; i
< 16; ++i
)
641 //expected-error@+1 {{'ordered' clause with a parameter can not be specified in '#pragma omp parallel for simd' directive}}
642 #pragma omp parallel for simd ordered(1)
643 for (int i
= 0; i
< 16; ++i
)
648 // expected-error@+1 2 {{unexpected OpenMP clause 'nowait' in directive '#pragma omp parallel for simd'}}
649 #pragma omp parallel for simd nowait nowait // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'nowait' clause}}
650 for (int i
= 0; i
< 16; ++i
)