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
];
27 #pragma omp target teams distribute simd
28 for (int i
= 0; i
< 10; i
+= 1) {
31 #pragma omp target teams distribute simd
32 for (char i
= 0; i
< 10; i
++) {
35 #pragma omp target teams distribute simd
36 for (char i
= 0; i
< 10; i
+= '\1') {
39 #pragma omp target teams distribute simd
40 for (long long i
= 0; i
< 10; i
++) {
43 #pragma omp target teams distribute simd
44 // expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'double'}}
45 for (long long i
= 0; i
< 10; i
+= 1.5) {
48 #pragma omp target teams distribute simd
49 for (long long i
= 0; i
< 'z'; i
+= 1u) {
52 #pragma omp target teams distribute simd
53 // expected-error@+1 {{variable must be of integer or random access iterator type}}
54 for (float fi
= 0; fi
< 10.0; fi
++) {
55 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
57 #pragma omp target teams distribute simd
58 // expected-error@+1 {{variable must be of integer or random access iterator type}}
59 for (double fi
= 0; fi
< 10.0; fi
++) {
60 c
[(int)fi
] = a
[(int)fi
] + b
[(int)fi
];
62 #pragma omp target teams distribute simd
63 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
64 for (int &ref
= ii
; ref
< 10; ref
++) {
66 #pragma omp target teams distribute simd
67 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
68 for (int i
; i
< 10; i
++)
71 #pragma omp target teams distribute simd
72 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
73 for (int i
= 0, j
= 0; i
< 10; ++i
)
76 #pragma omp target teams distribute simd
77 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
81 #pragma omp target teams distribute simd
82 // expected-warning@+2 {{expression result unused}}
83 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
84 for (ii
+ 1; ii
< 10; ++ii
)
87 #pragma omp target teams distribute simd
88 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
89 for (c
[ii
] = 0; ii
< 10; ++ii
)
92 #pragma omp target teams distribute simd
93 // Ok to skip parenthesises.
94 for (((ii
)) = 0; ii
< 10; ++ii
)
97 #pragma omp target teams distribute simd
98 // omp4-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'i'}} omp5-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
99 for (int i
= 0; jj
< kk
; ii
++)
102 #pragma omp target teams distribute simd
103 // omp4-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
104 for (int i
= 0; !!i
; i
++)
107 // omp4-error@+2 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}}
108 #pragma omp target teams distribute simd
109 for (int i
= 0; i
!= 1; i
++)
112 #pragma omp target teams distribute simd
113 // omp4-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'i'}} omp5-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'i'}}
114 for (int i
= 0;; i
++)
118 #pragma omp target teams distribute simd
119 for (int i
= 11; i
> 10; i
--)
123 #pragma omp target teams distribute simd
124 for (int i
= 0; i
< 10; ++i
)
128 #pragma omp target teams distribute simd
129 for (ii
= 0; ii
< 10; ++ii
)
132 #pragma omp target teams distribute simd
133 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
134 for (ii
= 0; ii
< 10; ++jj
)
137 #pragma omp target teams distribute simd
138 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
139 for (ii
= 0; ii
< 10; ++++ii
)
142 // Ok but undefined behavior (in general, cannot check that incr
143 // is really loop-invariant).
144 #pragma omp target teams distribute simd
145 for (ii
= 0; ii
< 10; ii
= ii
+ ii
)
148 #pragma omp target teams distribute simd
149 // expected-error@+1 {{expression must have integral or unscoped enumeration type, not 'float'}}
150 for (ii
= 0; ii
< 10; ii
= ii
+ 1.0f
)
153 // Ok - step was converted to integer type.
154 #pragma omp target teams distribute simd
155 for (ii
= 0; ii
< 10; ii
= ii
+ (int)1.1f
)
158 #pragma omp target teams distribute simd
159 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
160 for (ii
= 0; ii
< 10; jj
= ii
+ 2)
163 #pragma omp target teams distribute simd
164 // expected-warning@+2 {{relational comparison result unused}}
165 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
166 for (ii
= 0; ii
<10; jj
> kk
+ 2)
169 #pragma omp target teams distribute simd
170 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
171 for (ii
= 0; ii
< 10;)
174 #pragma omp target teams distribute simd
175 // expected-warning@+2 {{expression result unused}}
176 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
177 for (ii
= 0; ii
< 10; !ii
)
180 #pragma omp target teams distribute simd
181 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
182 for (ii
= 0; ii
< 10; ii
? ++ii
: ++jj
)
185 #pragma omp target teams distribute simd
186 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'ii'}}
187 for (ii
= 0; ii
< 10; ii
= ii
< 10)
190 #pragma omp target teams distribute simd
191 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
192 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
193 for (ii
= 0; ii
< 10; ii
= ii
+ 0)
196 #pragma omp target teams distribute simd
197 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
198 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
199 for (ii
= 0; ii
< 10; ii
= ii
+ (int)(0.8 - 0.45))
202 #pragma omp target teams distribute simd
203 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
204 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
205 for (ii
= 0; (ii
) < 10; ii
-= 25)
208 #pragma omp target teams distribute simd
209 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
210 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
211 for (ii
= 0; (ii
< 10); ii
-= 0)
214 #pragma omp target teams distribute simd
215 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
216 // expected-error@+1 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
217 for (ii
= 0; ii
> 10; (ii
+= 0))
220 #pragma omp target teams distribute simd
221 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
222 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
223 for (ii
= 0; ii
< 10; (ii
) = (1 - 1) + (ii
))
226 #pragma omp target teams distribute simd
227 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
228 // expected-error@+1 {{increment expression must cause 'ii' to decrease on each iteration of OpenMP for loop}}
229 for ((ii
= 0); ii
> 10; (ii
-= 0))
232 #pragma omp target teams distribute simd
233 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
234 // expected-error@+1 {{increment expression must cause 'ii' to increase on each iteration of OpenMP for loop}}
235 for (ii
= 0; (ii
< 10); (ii
-= 0))
238 #pragma omp target teams distribute simd firstprivate(ii) // expected-note {{defined as firstprivate}}
239 // expected-error@+1 {{loop iteration variable in the associated loop of 'omp target teams distribute simd' directive may not be firstprivate, predetermined as linear}}
240 for (ii
= 0; ii
< 10; ii
++)
243 #pragma omp target teams distribute simd private(ii) // omp4-note {{defined as private}}
244 // omp4-error@+1 {{loop iteration variable in the associated loop of 'omp target teams distribute simd' directive may not be private, predetermined as linear}}
245 for (ii
= 0; ii
< 10; ii
++)
248 #pragma omp target teams distribute simd lastprivate(ii) // omp4-note {{defined as lastprivate}}
249 // omp4-error@+1 {{loop iteration variable in the associated loop of 'omp target teams distribute simd' directive may not be lastprivate, predetermined as linear}}
250 for (ii
= 0; ii
< 10; ii
++)
253 #pragma omp target teams distribute simd
254 // expected-error@+1 {{loop iteration variable in the associated loop of 'omp target teams distribute simd' directive may not be threadprivate or thread local, predetermined as linear}}
255 for (sii
= 0; sii
< 10; sii
++)
259 #pragma omp target teams distribute simd collapse(2)
260 for (ii
= 0; ii
< 10; ii
+= 1)
261 for (globalii
= 0; globalii
< 10; globalii
+= 1)
262 c
[globalii
] += a
[globalii
] + ii
;
265 #pragma omp target teams distribute simd
266 // omp4-error@+1 {{statement after '#pragma omp target teams distribute simd' must be a for loop}}
267 for (auto &item
: a
) {
271 #pragma omp target teams distribute simd
272 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
273 // expected-error@+1 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}}
274 for (unsigned i
= 9; i
< 10; i
--) {
278 int(*lb
)[4] = nullptr;
279 #pragma omp target teams distribute simd
280 for (int(*p
)[4] = lb
; p
< lb
+ 8; ++p
) {
283 #pragma omp target teams distribute simd
284 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
285 for (int a
{0}; a
< 10; ++a
) {
291 // Iterators allowed in openmp for-loops.
293 struct random_access_iterator_tag
{};
294 template <class Iter
>
295 struct iterator_traits
{
296 typedef typename
Iter::difference_type difference_type
;
297 typedef typename
Iter::iterator_category iterator_category
;
299 template <class Iter
>
300 typename iterator_traits
<Iter
>::difference_type
301 distance(Iter first
, Iter last
) { return first
- last
; }
306 Iter0(const Iter0
&) {}
307 Iter0
operator++() { return *this; }
308 Iter0
operator--() { return *this; }
309 bool operator<(Iter0 a
) { return true; }
311 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'Iter0' for 1st argument}}
312 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'Iter0' for 1st argument}}
313 int operator-(Iter0 a
, Iter0 b
) { return 0; }
316 Iter1(float f
= 0.0f
, double d
= 0.0) {}
317 Iter1(const Iter1
&) {}
318 Iter1
operator++() { return *this; }
319 Iter1
operator--() { return *this; }
320 bool operator<(Iter1 a
) { return true; }
321 bool operator>=(Iter1 a
) { return false; }
326 GoodIter(const GoodIter
&) {}
327 GoodIter(int fst
, int snd
) {}
328 GoodIter
&operator=(const GoodIter
&that
) { return *this; }
329 GoodIter
&operator=(const Iter0
&that
) { return *this; }
330 GoodIter
&operator+=(int x
) { return *this; }
331 explicit GoodIter(void *) {}
332 GoodIter
operator++() { return *this; }
333 GoodIter
operator--() { return *this; }
334 bool operator!() { return true; }
335 bool operator<(GoodIter a
) { return true; }
336 bool operator<=(GoodIter a
) { return true; }
337 bool operator>=(GoodIter a
) { return false; }
338 typedef int difference_type
;
339 typedef std::random_access_iterator_tag iterator_category
;
341 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'GoodIter' for 2nd argument}}
342 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
343 int operator-(GoodIter a
, GoodIter b
) { return 0; }
344 // expected-note@+1 3 {{candidate function not viable: requires single argument 'a', but 2 arguments were provided}}
345 GoodIter
operator-(GoodIter a
) { return a
; }
346 // expected-note@+2 {{candidate function not viable: no known conversion from 'const Iter0' to 'int' for 2nd argument}}
347 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'GoodIter' for 1st argument}}
348 GoodIter
operator-(GoodIter a
, int v
) { return GoodIter(); }
349 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'GoodIter' for 1st argument}}
350 GoodIter
operator+(GoodIter a
, int v
) { return GoodIter(); }
351 // expected-note@+2 {{candidate function not viable: no known conversion from 'GoodIter' to 'int' for 1st argument}}
352 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter1' to 'int' for 1st argument}}
353 GoodIter
operator-(int v
, GoodIter a
) { return GoodIter(); }
354 // expected-note@+1 2 {{candidate function not viable: no known conversion from 'Iter0' to 'int' for 1st argument}}
355 GoodIter
operator+(int v
, GoodIter a
) { return GoodIter(); }
357 int test_with_random_access_iterator() {
360 #pragma omp target teams distribute simd
361 for (GoodIter I
= begin
; I
< end
; ++I
)
363 #pragma omp target teams distribute simd
364 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
365 for (GoodIter
&I
= begin
; I
< end
; ++I
)
367 #pragma omp target teams distribute simd
368 for (GoodIter I
= begin
; I
>= end
; --I
)
370 #pragma omp target teams distribute simd
371 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
372 for (GoodIter
I(begin
); I
< end
; ++I
)
374 #pragma omp target teams distribute simd
375 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
376 for (GoodIter
I(nullptr); I
< end
; ++I
)
378 #pragma omp target teams distribute simd
379 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
380 for (GoodIter
I(0); I
< end
; ++I
)
382 #pragma omp target teams distribute simd
383 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
384 for (GoodIter
I(1, 2); I
< end
; ++I
)
386 #pragma omp target teams distribute simd
387 for (begin
= GoodIter(0); begin
< end
; ++begin
)
389 #pragma omp target teams distribute simd
390 // expected-error@+2 {{invalid operands to binary expression ('GoodIter' and 'const Iter0')}}
391 // expected-error@+1 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
392 for (begin
= begin0
; begin
< end
; ++begin
)
394 #pragma omp target teams distribute simd
395 // expected-error@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
396 for (++begin
; begin
< end
; ++begin
)
398 #pragma omp target teams distribute simd
399 for (begin
= end
; begin
< end
; ++begin
)
401 #pragma omp target teams distribute simd
402 // omp4-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp5-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}
403 for (GoodIter I
= begin
; I
- I
; ++I
)
405 #pragma omp target teams distribute simd
406 // omp4-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp5-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}
407 for (GoodIter I
= begin
; begin
< end
; ++I
)
409 #pragma omp target teams distribute simd
410 // omp4-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', or '>=') of loop variable 'I'}} omp5-error@+1 {{condition of OpenMP for loop must be a relational comparison ('<', '<=', '>', '>=', or '!=') of loop variable 'I'}}
411 for (GoodIter I
= begin
; !I
; ++I
)
413 #pragma omp target teams distribute simd
414 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
415 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
416 for (GoodIter I
= begin
; I
>= end
; I
= I
+ 1)
418 #pragma omp target teams distribute simd
419 for (GoodIter I
= begin
; I
>= end
; I
= I
- 1)
421 #pragma omp target teams distribute simd
422 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
423 for (GoodIter I
= begin
; I
>= end
; I
= -I
)
425 #pragma omp target teams distribute simd
426 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
427 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
428 for (GoodIter I
= begin
; I
>= end
; I
= 2 + I
)
430 #pragma omp target teams distribute simd
431 // expected-error@+1 {{increment clause of OpenMP for loop must perform simple addition or subtraction on loop variable 'I'}}
432 for (GoodIter I
= begin
; I
>= end
; I
= 2 - I
)
434 #pragma omp target teams distribute simd
435 // expected-error@+1 {{invalid operands to binary expression ('Iter0' and 'int')}}
436 for (Iter0 I
= begin0
; I
< end0
; ++I
)
438 #pragma omp target teams distribute simd
439 // Initializer is constructor without params.
440 // expected-error@+2 {{invalid operands to binary expression ('Iter0' and 'int')}}
441 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
442 for (Iter0 I
; I
< end0
; ++I
)
445 #pragma omp target teams distribute simd
446 // expected-error@+2 {{invalid operands to binary expression ('Iter1' and 'Iter1')}}
447 // expected-error@+1 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
448 for (Iter1 I
= begin1
; I
< end1
; ++I
)
450 #pragma omp target teams distribute simd
451 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
452 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
453 for (Iter1 I
= begin1
; I
>= end1
; ++I
)
455 #pragma omp target teams distribute simd
456 // expected-error@+4 {{invalid operands to binary expression ('Iter1' and 'float')}}
457 // expected-error@+3 {{could not calculate number of iterations calling 'operator-' with upper and lower loop bounds}}
458 // Initializer is constructor with all default params.
459 // expected-warning@+1 {{initialization clause of OpenMP for loop is not in canonical form ('var = init' or 'T var = init')}}
460 for (Iter1 I
; I
< end1
; ++I
) {
465 template <typename IT
, int ST
>
468 int dotest_lt(IT begin
, IT end
) {
469 #pragma omp target teams distribute simd
470 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
471 // expected-error@+1 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
472 for (IT I
= begin
; I
< end
; I
= I
+ ST
) {
475 #pragma omp target teams distribute simd
476 // expected-note@+2 {{loop step is expected to be positive due to this condition}}
477 // expected-error@+1 {{increment expression must cause 'I' to increase on each iteration of OpenMP for loop}}
478 for (IT I
= begin
; I
<= end
; I
+= ST
) {
481 #pragma omp target teams distribute simd
482 for (IT I
= begin
; I
< end
; ++I
) {
491 template <typename IT
, int ST
= 0>
492 int dotest_gt(IT begin
, IT end
) {
493 #pragma omp target teams distribute simd
494 // expected-note@+2 2 {{loop step is expected to be negative due to this condition}}
495 // expected-error@+1 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
496 for (IT I
= begin
; I
>= end
; I
= I
+ ST
) {
499 #pragma omp target teams distribute simd
500 // expected-note@+2 2 {{loop step is expected to be negative due to this condition}}
501 // expected-error@+1 2 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
502 for (IT I
= begin
; I
>= end
; I
+= ST
) {
506 #pragma omp target teams distribute simd
507 // expected-note@+2 {{loop step is expected to be negative due to this condition}}
508 // expected-error@+1 {{increment expression must cause 'I' to decrease on each iteration of OpenMP for loop}}
509 for (IT I
= begin
; I
>= end
; ++I
) {
513 #pragma omp target teams distribute simd
514 for (IT I
= begin
; I
< end
; I
+= TC
<int, ST
>::step()) {
519 void test_with_template() {
521 TC
<GoodIter
, 100> t1
;
522 TC
<GoodIter
, -100> t2
;
523 t1
.dotest_lt(begin
, end
);
524 t2
.dotest_lt(begin
, end
); // expected-note {{in instantiation of member function 'TC<GoodIter, -100>::dotest_lt' requested here}}
525 dotest_gt(begin
, end
); // expected-note {{in instantiation of function template specialization 'dotest_gt<GoodIter, 0>' requested here}}
526 dotest_gt
<unsigned, 10>(0, 100); // expected-note {{in instantiation of function template specialization 'dotest_gt<unsigned int, 10>' requested here}}
529 void test_loop_break() {
531 float a
[N
], b
[N
], c
[N
];
532 #pragma omp target teams distribute simd
533 for (int i
= 0; i
< 10; i
++) {
535 for (int j
= 0; j
< 10; ++j
) {
537 break; // OK in nested loop
547 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
550 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
553 #pragma omp target teams distribute simd
554 for (int i
= 0; i
< 10; i
++) {
555 for (int j
= 0; j
< 10; j
++) {
566 void test_loop_eh() {
568 float a
[N
], b
[N
], c
[N
];
569 #pragma omp target teams distribute simd
570 for (int i
= 0; i
< 10; i
++) {
572 try { // expected-error {{'try' statement cannot be used in OpenMP simd region}}
573 for (int j
= 0; j
< 10; ++j
) {
575 throw a
[i
]; // expected-error {{throw' statement cannot be used in OpenMP simd region}}
577 throw a
[i
]; // expected-error {{throw' statement cannot be used in OpenMP simd region}}
580 throw a
[i
]; // expected-error {{throw' statement cannot be used in OpenMP simd region}}
581 return; // expected-error {{cannot return from OpenMP region}}
590 for (int j
= 0; j
< 10; j
++) {
592 throw c
[i
]; // expected-error {{throw' statement cannot be used in OpenMP simd region}}
598 #pragma omp target teams distribute simd
599 for (int i
= 0; i
< 10; ++i
) {
601 void g() { throw 0; }
606 void test_loop_firstprivate_lastprivate() {
608 // expected-error@+1 {{lastprivate variable cannot be firstprivate}} expected-note@+1 {{defined as lastprivate}}
609 #pragma omp target teams distribute simd lastprivate(s) firstprivate(s) // expected-error {{calling a private constructor of class 'S'}}
610 for (int i
= 0; i
< 16; ++i
)
614 void test_ordered() {
615 #pragma omp target teams distribute simd ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp target teams distribute simd'}}
616 for (int i
= 0; i
< 16; ++i
)
621 // expected-error@+1 {{directive '#pragma omp target teams distribute simd' cannot contain more than one 'nowait' clause}}
622 #pragma omp target teams distribute simd nowait nowait
623 for (int i
= 0; i
< 16; ++i
)