Debian Codegraph @

clang/test/SemaOpenACC/atomic-construct.cpp

raw
1 // RUN: %clang_cc1 %s -fopenacc -Wno-unused-value -verify
2
3 void NormalFunc(int I) {
4 // No clauses are valid, but we parse them anyway, just mark them as not valid
5 // on this construct.
6
7 // expected-error@+1{{OpenACC 'copy' clause is not valid on 'atomic' directive}}
8 #pragma acc atomic copy(I)
9 I = I + 1;
10 // expected-error@+1{{OpenACC 'copy' clause is not valid on 'atomic' directive}}
11 #pragma acc atomic read copy(I)
12 I = I;
13 }
14
15 struct Struct{
16 Struct *getPtr();
17 Struct &operator++();
18 Struct &operator--();
19 Struct &operator++(int);
20 Struct &operator--(int);
21
22 Struct &operator+=(int);
23 Struct &operator*=(int);
24 Struct &operator-=(int);
25 Struct &operator/=(int);
26 Struct &operator&=(int);
27 Struct &operator|=(int);
28 Struct &operator<<=(int);
29 Struct &operator>>=(int);
30 Struct &operator^=(int);
31 Struct &operator%=(int);
32 Struct &operator!=(int);
33 Struct &operator+();
34 Struct &operator-();
35
36 operator int();
37 void operator()();
38 Struct &operator*();
39 Struct &operator=(int);
40 };
41
42 int operator+(Struct&, int);
43 int operator+(int, Struct&);
44 Struct &operator+(Struct&, Struct&);
45 Struct &operator*(Struct&, Struct&);
46 Struct &operator-(Struct&, Struct&);
47
48 Struct S1, S2;
49
50 struct NotCondition{} NC;
51
52 template<typename T>
53 T &getRValue();
54
55 void IfClause(int x, int v) {
56 // expected-error@+1{{OpenACC 'seq' clause is not valid on 'atomic' directive}}
57 #pragma acc atomic read seq
58 x = v;
59
60 // expected-error@+1{{expected '('}}
61 #pragma acc atomic read if
62 x = v;
63
64 // expected-error@+1{{value of type 'struct NotCondition' is not contextually convertible to 'bool'}}
65 #pragma acc atomic read if(NC)
66 x = v;
67
68 // expected-error@+2{{OpenACC 'if' clause cannot appear more than once on a 'atomic' directive}}
69 // expected-note@+1{{previous 'if' clause is here}}
70 #pragma acc atomic read if(x) if (v)
71 x = v;
72 }
73
74 template<typename T>
75 void AtomicReadTemplate(T LHS, T RHS) {
76 #pragma acc atomic read
77 LHS = RHS;
78
79 T *LHSPtr, *RHSPtr;
80
81 #pragma acc atomic read
82 LHSPtr = RHSPtr;
83
84 // expected-error@+2{{statement associated with OpenACC 'atomic read' directive is invalid}}
85 // expected-note@+2{{right operand to assignment expression must be an l-value}}
86 #pragma acc atomic read
87 LHS = RHS + 1;
88
89 #pragma acc atomic read
90 *LHSPtr = RHS;
91
92 #pragma acc atomic read
93 LHS = *RHSPtr;
94
95 // expected-error@+2{{statement associated with OpenACC 'atomic read' directive is invalid}}
96 // expected-note@+2{{right operand to assignment expression must be an l-value}}
97 #pragma acc atomic read
98 LHS = getRValue<T>();
99 }
100
101 template<typename T>
102 void AtomicReadTemplate2(T LHS, T RHS) {
103 // expected-error@+2{{statement associated with OpenACC 'atomic read' directive is invalid}}
104 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
105 #pragma acc atomic read
106 LHS = RHS;
107
108 T *LHSPtr, *RHSPtr;
109 // Fine, now a pointer.
110 #pragma acc atomic read
111 LHSPtr = RHSPtr;
112
113 // expected-error@+2{{statement associated with OpenACC 'atomic read' directive is invalid}}
114 // expected-note@+2{{right operand to assignment expression must be an l-value}}
115 #pragma acc atomic read
116 LHS = *RHS.getPtr();
117
118 // expected-error@+2{{statement associated with OpenACC 'atomic read' directive is invalid}}
119 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
120 #pragma acc atomic read
121 *LHSPtr = RHS;
122
123 // expected-error@+2{{statement associated with OpenACC 'atomic read' directive is invalid}}
124 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
125 #pragma acc atomic read
126 LHS = *RHSPtr;
127
128 // expected-error@+2{{statement associated with OpenACC 'atomic read' directive is invalid}}
129 // expected-note@+2{{left operand to assignment expression must be an l-value}}
130 #pragma acc atomic read
131 getRValue<T>() = getRValue<T>();
132
133 // expected-error@+2{{statement associated with OpenACC 'atomic read' directive is invalid}}
134 // expected-note@+2{{right operand to assignment expression must be an l-value}}
135 #pragma acc atomic read
136 LHS = getRValue<T>();
137 }
138
139 void AtomicRead(int LHS, int RHS) {
140 AtomicReadTemplate(LHS, RHS);
141 AtomicReadTemplate2(S1, S2); // expected-note{{in instantiation of function template specialization}}
142
143 #pragma acc atomic read
144 LHS = RHS;
145
146 int *LHSPtr, *RHSPtr;
147
148 #pragma acc atomic read
149 LHSPtr = RHSPtr;
150
151 // expected-error@+2{{statement associated with OpenACC 'atomic read' directive is invalid}}
152 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
153 #pragma acc atomic read
154 S1 = S2;
155
156 // expected-error@+2{{statement associated with OpenACC 'atomic read' directive is invalid}}
157 // expected-note@+2{{right operand to assignment expression must be an l-value}}
158 #pragma acc atomic read
159 LHS = RHS + 1;
160
161 #pragma acc atomic read
162 *LHSPtr = RHS;
163
164 #pragma acc atomic read
165 LHS = *RHSPtr;
166
167 // There is no way to test that = is an overloaded operator, since there
168 // really isn't a way to create an operator= without a class type on one side
169 // or the other.
170 }
171
172 template<typename T>
173 void AtomicWriteTemplate(T LHS, T RHS) {
174 #pragma acc atomic write
175 LHS = RHS;
176
177 T *LHSPtr, *RHSPtr;
178 #pragma acc atomic write
179 LHSPtr = RHSPtr;
180
181 #pragma acc atomic write
182 *LHSPtr = *RHSPtr;
183
184 // allowed, expr is ok.
185 #pragma acc atomic write
186 LHS = *RHSPtr;
187
188 #pragma acc atomic write
189 LHS = RHS * 2;
190
191 // expected-error@+2{{statement associated with OpenACC 'atomic write' directive is invalid}}
192 // expected-note@+2{{left operand to assignment expression must be an l-value}}
193 #pragma acc atomic write
194 getRValue<T>() = getRValue<T>();
195
196 #pragma acc atomic write
197 LHS = getRValue<T>();
198 }
199
200 template<typename T>
201 void AtomicWriteTemplate2(T LHS, T RHS) {
202 // expected-error@+2{{statement associated with OpenACC 'atomic write' directive is invalid}}
203 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
204 #pragma acc atomic write
205 LHS = RHS;
206
207 T *LHSPtr, *RHSPtr;
208 #pragma acc atomic write
209 LHSPtr = RHSPtr;
210
211 // expected-error@+2{{statement associated with OpenACC 'atomic write' directive is invalid}}
212 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
213 #pragma acc atomic write
214 LHS = *RHSPtr;
215
216 #pragma acc atomic write
217 LHSPtr = RHS.getPtr();
218
219 // expected-error@+2{{statement associated with OpenACC 'atomic write' directive is invalid}}
220 // expected-note@+2{{left operand to assignment expression must be an l-value}}
221 #pragma acc atomic write
222 getRValue<T>() = getRValue<T>();
223
224 // expected-error@+2{{statement associated with OpenACC 'atomic write' directive is invalid}}
225 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
226 #pragma acc atomic write
227 LHS = getRValue<T>();
228 }
229
230 void AtomicWrite(int LHS, int RHS) {
231 AtomicWriteTemplate(LHS, RHS);
232 AtomicWriteTemplate2(S1, S2); // expected-note{{in instantiation of function template specialization}}
233
234 #pragma acc atomic write
235 LHS = RHS;
236
237 int *LHSPtr, *RHSPtr;
238 #pragma acc atomic write
239 LHSPtr = RHSPtr;
240
241 #pragma acc atomic write
242 *LHSPtr = *RHSPtr;
243
244 // allowed, expr is ok.
245 #pragma acc atomic write
246 LHS = *RHSPtr;
247
248 #pragma acc atomic write
249 LHS = RHS * 2;
250 }
251
252 template<typename T>
253 void AtomicUpdateTemplate(T LHS, T RHS) {
254 #pragma acc atomic
255 LHS++;
256
257 #pragma acc atomic update
258 LHS--;
259
260 #pragma acc atomic
261 ++LHS;
262
263 #pragma acc atomic update
264 --LHS;
265
266 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
267 // expected-note@+2{{unary operator not supported, only increment and decrement operations permitted}}
268 #pragma acc atomic
269 +LHS;
270
271 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
272 // expected-note@+2{{unary operator not supported, only increment and decrement operations permitted}}
273 #pragma acc atomic update
274 -LHS;
275
276 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
277 // expected-note@+2{{expected binary operation on right hand side of assignment operator}}
278 #pragma acc atomic update
279 LHS = RHS;
280
281 T *LHSPtr, *RHSPtr;
282
283 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
284 // expected-note@+2{{expected binary operation on right hand side of assignment operator}}
285 #pragma acc atomic
286 *LHSPtr = *RHSPtr;
287
288 // x binop= expr;
289 #pragma acc atomic
290 LHS += 1 + RHS;
291 #pragma acc atomic update
292 LHS *= 1 + RHS;
293 #pragma acc atomic
294 LHS -= 1 + RHS;
295 #pragma acc atomic update
296 LHS /= 1 + RHS;
297 #pragma acc atomic
298 LHS &= 1 + RHS;
299 #pragma acc atomic update
300 LHS ^= 1 + RHS;
301 #pragma acc atomic
302 LHS |= 1 + RHS;
303 #pragma acc atomic update
304 LHS <<= 1 + RHS;
305 #pragma acc atomic
306 LHS >>= 1 + RHS;
307
308 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
309 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
310 #pragma acc atomic update
311 LHS != 1 + RHS;
312
313 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
314 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
315 #pragma acc atomic update
316 LHS <= 1 + RHS;
317
318 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
319 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
320 #pragma acc atomic update
321 LHS >= 1 + RHS;
322
323 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
324 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
325 #pragma acc atomic update
326 LHS %= 1 + RHS;
327
328 // x = x binop expr.
329 #pragma acc atomic
330 LHS = LHS + getRValue<T>();
331 #pragma acc atomic update
332 LHS = LHS * getRValue<T>();
333 #pragma acc atomic update
334 LHS = LHS - getRValue<T>();
335 #pragma acc atomic update
336 LHS = LHS / getRValue<T>();
337 #pragma acc atomic update
338 LHS = LHS & getRValue<T>();
339 #pragma acc atomic update
340 LHS = LHS ^ getRValue<T>();
341 #pragma acc atomic update
342 LHS = LHS | getRValue<T>();
343 #pragma acc atomic update
344 LHS = LHS << getRValue<T>();
345 #pragma acc atomic update
346 LHS = LHS >> getRValue<T>();
347 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
348 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
349 #pragma acc atomic update
350 LHS = LHS < getRValue<T>();
351 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
352 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
353 #pragma acc atomic update
354 LHS = LHS > getRValue<T>();
355 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
356 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
357 #pragma acc atomic update
358 LHS = LHS <= getRValue<T>();
359 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
360 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
361 #pragma acc atomic update
362 LHS = LHS >= getRValue<T>();
363 #pragma acc atomic update
364 LHS = LHS ^ getRValue<T>();
365
366
367 // x = expr binop x.
368 #pragma acc atomic
369 LHS = getRValue<T>() + LHS;
370 #pragma acc atomic update
371 LHS = getRValue<T>() * LHS;
372 #pragma acc atomic update
373 LHS = getRValue<T>() - LHS;
374 #pragma acc atomic update
375 LHS = getRValue<T>() / LHS;
376 #pragma acc atomic update
377 LHS = getRValue<T>() & LHS;
378 #pragma acc atomic update
379 LHS = getRValue<T>() ^ LHS;
380 #pragma acc atomic update
381 LHS = getRValue<T>() | LHS;
382 #pragma acc atomic update
383 LHS = getRValue<T>() << LHS;
384 #pragma acc atomic update
385 LHS = getRValue<T>() >> LHS;
386 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
387 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
388 #pragma acc atomic update
389 LHS = getRValue<T>() < LHS;
390 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
391 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
392 #pragma acc atomic update
393 LHS = getRValue<T>() > LHS;
394 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
395 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
396 #pragma acc atomic update
397 LHS = getRValue<T>() <= LHS;
398 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
399 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
400 #pragma acc atomic update
401 LHS = getRValue<T>() >= LHS;
402 #pragma acc atomic update
403 LHS = getRValue<T>() ^ LHS;
404
405 #pragma acc atomic update
406 LHS = LHS + getRValue<T>();
407 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
408 // expected-note@+2{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('RHS' and 'getRValue<T>()')}}
409 #pragma acc atomic update
410 LHS = RHS + getRValue<T>();
411
412 #pragma acc atomic update
413 LHS = getRValue<T>() - LHS;
414 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
415 // expected-note@+2{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('getRValue<T>()' and 'RHS')}}
416 #pragma acc atomic update
417 LHS = getRValue<T>() + RHS;
418 }
419
420 template<typename T>
421 void AtomicUpdateTemplate2(T LHS, T RHS) {
422 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
423 // expected-note@+2{{operand to increment expression must be of scalar type (was 'Struct')}}
424 #pragma acc atomic
425 LHS++;
426
427 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
428 // expected-note@+2{{operand to decrement expression must be of scalar type (was 'Struct')}}
429 #pragma acc atomic update
430 LHS--;
431
432 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
433 // expected-note@+2{{operand to increment expression must be of scalar type (was 'Struct')}}
434 #pragma acc atomic
435 ++LHS;
436
437 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
438 // expected-note@+2{{operand to decrement expression must be of scalar type (was 'Struct')}}
439 #pragma acc atomic update
440 --LHS;
441
442 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
443 // expected-note@+2{{unary operator not supported, only increment and decrement operations permitted}}
444 #pragma acc atomic
445 +LHS;
446
447 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
448 // expected-note@+2{{unary operator not supported, only increment and decrement operations permitted}}
449 #pragma acc atomic update
450 -LHS;
451
452 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
453 // expected-note@+2{{expected assignment, compound assignment, increment, or decrement expression}}
454 #pragma acc atomic
455 LHS();
456
457 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
458 // expected-note@+2{{unary operator not supported, only increment and decrement operations permitted}}
459 #pragma acc atomic
460 *LHS;
461
462 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
463 // expected-note@+2{{expected binary operation on right hand side of assignment operator}}
464 #pragma acc atomic update
465 LHS = RHS;
466
467 T *LHSPtr, *RHSPtr;
468
469 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
470 // expected-note@+2{{expected binary operation on right hand side of assignment operator}}
471 #pragma acc atomic
472 *LHSPtr = *RHSPtr;
473
474 // x binop= expr;
475 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
476 // expected-note@+2{{left operand to compound assignment expression must be of scalar type (was 'Struct')}}
477 #pragma acc atomic
478 LHS += 1 + RHS;
479 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
480 // expected-note@+2{{left operand to compound assignment expression must be of scalar type (was 'Struct')}}
481 #pragma acc atomic update
482 LHS *= 1 + RHS;
483 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
484 // expected-note@+2{{left operand to compound assignment expression must be of scalar type (was 'Struct')}}
485 #pragma acc atomic
486 LHS -= 1 + RHS;
487 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
488 // expected-note@+2{{left operand to compound assignment expression must be of scalar type (was 'Struct')}}
489 #pragma acc atomic update
490 LHS /= 1 + RHS;
491 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
492 // expected-note@+2{{left operand to compound assignment expression must be of scalar type (was 'Struct')}}
493 #pragma acc atomic
494 LHS &= 1 + RHS;
495 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
496 // expected-note@+2{{left operand to compound assignment expression must be of scalar type (was 'Struct')}}
497 #pragma acc atomic update
498 LHS ^= 1 + RHS;
499 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
500 // expected-note@+2{{left operand to compound assignment expression must be of scalar type (was 'Struct')}}
501 #pragma acc atomic
502 LHS |= 1 + RHS;
503 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
504 // expected-note@+2{{left operand to compound assignment expression must be of scalar type (was 'Struct')}}
505 #pragma acc atomic update
506 LHS <<= 1 + RHS;
507 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
508 // expected-note@+2{{left operand to compound assignment expression must be of scalar type (was 'Struct')}}
509 #pragma acc atomic
510 LHS >>= 1 + RHS;
511
512 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
513 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
514 #pragma acc atomic update
515 LHS != 1 + RHS;
516
517 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
518 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
519 #pragma acc atomic update
520 LHS %= 1 + RHS;
521
522 // x = x binop expr.
523 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
524 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
525 #pragma acc atomic
526 LHS = LHS + getRValue<T>();
527 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
528 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
529 #pragma acc atomic update
530 LHS = LHS * getRValue<T>();
531 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
532 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
533 #pragma acc atomic update
534 LHS = LHS - getRValue<T>();
535
536 // x = expr binop x.
537 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
538 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
539 #pragma acc atomic
540 LHS = getRValue<T>() + LHS;
541 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
542 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
543 #pragma acc atomic update
544 LHS = getRValue<T>() * LHS;
545 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
546 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
547 #pragma acc atomic update
548 LHS = getRValue<T>() - LHS;
549
550 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
551 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
552 #pragma acc atomic update
553 LHS = LHS + getRValue<T>();
554 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
555 // expected-note@+2{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('RHS' and 'getRValue<T>()')}}
556 #pragma acc atomic update
557 LHS = RHS + getRValue<T>();
558
559 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
560 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
561 #pragma acc atomic update
562 LHS = getRValue<T>() - LHS;
563 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
564 // expected-note@+2{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('getRValue<T>()' and 'RHS')}}
565 #pragma acc atomic update
566 LHS = getRValue<T>() + RHS;
567 }
568
569 void AtomicUpdate() {
570 AtomicUpdateTemplate(1, 2);
571 AtomicUpdateTemplate2(S1, S2); //expected-note{{in instantiation of function template specialization}}
572
573 int I, J;
574
575 #pragma acc atomic
576 I++;
577 #pragma acc atomic update
578 --I;
579 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
580 // expected-note@+2{{operand to increment expression must be of scalar type (was 'Struct')}}
581 #pragma acc atomic
582 S1++;
583 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
584 // expected-note@+2{{operand to decrement expression must be of scalar type (was 'Struct')}}
585 #pragma acc atomic update
586 --S2;
587
588 // expected-error@+2{{statement associated with OpenACC 'atomic' directive is invalid}}
589 // expected-note@+2{{unary operator not supported, only increment and decrement operations permitted}}
590 #pragma acc atomic
591 +I;
592 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
593 // expected-note@+2{{unary operator not supported, only increment and decrement operations permitted}}
594 #pragma acc atomic update
595 -J;
596
597 #pragma acc atomic update
598 I ^= 1 + J;
599
600 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
601 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
602 #pragma acc atomic update
603 I%= 1 + J;
604
605 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
606 // expected-note@+2{{left operand to compound assignment expression must be of scalar type (was 'Struct')}}
607 #pragma acc atomic update
608 S1 ^= 1 + J;
609
610 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
611 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
612 #pragma acc atomic update
613 S2 %= 1 + J;
614
615 #pragma acc atomic update
616 I = I + getRValue<int>();
617 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
618 // expected-note@+2{{left hand side of assignment operation('I') must match one side of the sub-operation on the right hand side('J' and 'getRValue<int>()')}}
619 #pragma acc atomic update
620 I = J + getRValue<int>();
621
622 #pragma acc atomic update
623 I = getRValue<int>() - I;
624 // expected-error@+2{{statement associated with OpenACC 'atomic update' directive is invalid}}
625 // expected-note@+2{{left hand side of assignment operation('I') must match one side of the sub-operation on the right hand side('getRValue<int>()' and 'J')}}
626 #pragma acc atomic update
627 I = getRValue<int>() + J;
628 }
629
630 template<typename T>
631 void AtomicCaptureTemplateSimple(T LHS, T RHS) {
632 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
633 // expected-note@+2{{expected assignment expression}}
634 #pragma acc atomic capture
635 LHS++;
636 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
637 // expected-note@+2{{expected assignment expression}}
638 #pragma acc atomic capture
639 --LHS;
640
641 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
642 // expected-note@+2{{expected assignment expression}}
643 #pragma acc atomic capture
644 LHS += 1 + RHS;
645
646 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
647 // expected-note@+2{{expected assignment, compound assignment, increment, or decrement expression}}
648 #pragma acc atomic capture
649 LHS = RHS;
650
651 #pragma acc atomic capture
652 LHS = RHS++;
653
654 #pragma acc atomic capture
655 LHS = RHS--;
656
657 #pragma acc atomic capture
658 LHS = ++RHS;
659
660 #pragma acc atomic capture
661 LHS = --RHS;
662
663 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
664 // expected-note@+2{{unary operator not supported, only increment and decrement operations permitted}}
665 #pragma acc atomic capture
666 LHS = +RHS;
667
668 #pragma acc atomic capture
669 LHS = RHS += 1 + RHS;
670 #pragma acc atomic capture
671 LHS = RHS *= 1 + RHS;
672 #pragma acc atomic capture
673 LHS = RHS -= 1 + RHS;
674 #pragma acc atomic capture
675 LHS = RHS /= 1 + RHS;
676 #pragma acc atomic capture
677 LHS = RHS &= 1 + RHS;
678 #pragma acc atomic capture
679 LHS = RHS ^= 1 + RHS;
680 #pragma acc atomic capture
681 LHS = RHS >>= 1 + RHS;
682 #pragma acc atomic capture
683 LHS = RHS |= 1 + RHS;
684 #pragma acc atomic capture
685 LHS = RHS <<= 1 + RHS;
686 #pragma acc atomic capture
687 LHS = RHS >>= 1 + RHS;
688
689 #pragma acc atomic capture
690 LHS = RHS ^= 1 + RHS;
691 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
692 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
693 #pragma acc atomic capture
694 LHS = RHS <= 1 + RHS;
695 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
696 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
697 #pragma acc atomic capture
698 LHS = RHS >= 1 + RHS;
699
700 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
701 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
702 #pragma acc atomic capture
703 LHS = RHS + 1;
704 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
705 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
706 #pragma acc atomic capture
707 LHS = RHS < 1 + RHS;
708 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
709 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
710 #pragma acc atomic capture
711 LHS = RHS > 1 + RHS;
712 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
713 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
714 #pragma acc atomic capture
715 LHS = RHS ^ 1 + RHS;
716
717 #pragma acc atomic capture
718 LHS = RHS = RHS + 1;
719 #pragma acc atomic capture
720 LHS = RHS = 1 + RHS;
721 #pragma acc atomic capture
722 LHS = RHS = RHS * 1;
723 #pragma acc atomic capture
724 LHS = RHS = 1 * RHS;
725 #pragma acc atomic capture
726 LHS = RHS = RHS / 1;
727 #pragma acc atomic capture
728 LHS = RHS = 1 / RHS;
729 #pragma acc atomic capture
730 LHS = RHS = RHS ^ 1;
731 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
732 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
733 #pragma acc atomic capture
734 LHS = RHS = 1 % RHS;
735
736 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
737 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
738 #pragma acc atomic capture
739 LHS = RHS = RHS < 1;
740 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
741 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
742 #pragma acc atomic capture
743 LHS = RHS = 1 > RHS;
744
745 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
746 // expected-note@+2{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('RHS' and 'getRValue<T>()')}}
747 #pragma acc atomic capture
748 LHS = LHS = RHS + getRValue<T>();
749
750 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
751 // expected-note@+2{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('getRValue<T>()' and 'RHS')}}
752 #pragma acc atomic capture
753 LHS = LHS = getRValue<T>() + RHS;
754 }
755 template<typename T>
756 void AtomicCaptureTemplateSimple2(T LHS, T RHS) {
757 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
758 // expected-note@+2{{expected assignment expression}}
759 #pragma acc atomic capture
760 LHS++;
761 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
762 // expected-note@+2{{expected assignment expression}}
763 #pragma acc atomic capture
764 --LHS;
765
766 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
767 // expected-note@+2{{expected assignment expression}}
768 #pragma acc atomic capture
769 LHS += 1 + RHS;
770
771 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
772 // expected-note@+2{{expected assignment, compound assignment, increment, or decrement expression}}
773 #pragma acc atomic capture
774 LHS = RHS;
775
776 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
777 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
778 #pragma acc atomic capture
779 LHS = RHS++;
780
781 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
782 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
783 #pragma acc atomic capture
784 LHS = RHS--;
785
786 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
787 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
788 #pragma acc atomic capture
789 LHS = ++RHS;
790
791 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
792 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
793 #pragma acc atomic capture
794 LHS = --RHS;
795
796 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
797 // expected-note@+2{{unary operator not supported, only increment and decrement operations permitted}}
798 #pragma acc atomic capture
799 LHS = +RHS;
800
801
802 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
803 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
804 #pragma acc atomic capture
805 LHS = RHS += 1 + RHS;
806 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
807 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
808 #pragma acc atomic capture
809 LHS = RHS *= 1 + RHS;
810 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
811 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
812 #pragma acc atomic capture
813 LHS = RHS -= 1 + RHS;
814 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
815 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
816 #pragma acc atomic capture
817 LHS = RHS /= 1 + RHS;
818 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
819 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
820 #pragma acc atomic capture
821 LHS = RHS &= 1 + RHS;
822 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
823 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
824 #pragma acc atomic capture
825 LHS = RHS ^= 1 + RHS;
826 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
827 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
828 #pragma acc atomic capture
829 LHS = RHS >>= 1 + RHS;
830 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
831 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
832 #pragma acc atomic capture
833 LHS = RHS |= 1 + RHS;
834 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
835 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
836 #pragma acc atomic capture
837 LHS = RHS <<= 1 + RHS;
838 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
839 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
840 #pragma acc atomic capture
841 LHS = RHS >>= 1 + RHS;
842
843 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
844 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
845 #pragma acc atomic capture
846 LHS = RHS ^= 1 + RHS;
847 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
848 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
849 #pragma acc atomic capture
850 LHS = RHS <= 1 + RHS;
851 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
852 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
853 #pragma acc atomic capture
854 LHS = RHS >= 1 + RHS;
855
856 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
857 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
858 #pragma acc atomic capture
859 LHS = RHS + 1;
860 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
861 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
862 #pragma acc atomic capture
863 LHS = RHS < 1 + RHS;
864 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
865 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
866 #pragma acc atomic capture
867 LHS = RHS > 1 + RHS;
868 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
869 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
870 #pragma acc atomic capture
871 LHS = RHS ^ 1 + RHS;
872
873 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
874 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
875 #pragma acc atomic capture
876 LHS = RHS = RHS + 1;
877 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
878 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
879 #pragma acc atomic capture
880 LHS = RHS = 1 + RHS;
881 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
882 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
883 #pragma acc atomic capture
884 LHS = RHS = RHS * 1;
885 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
886 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
887 #pragma acc atomic capture
888 LHS = RHS = 1 * RHS;
889 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
890 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
891 #pragma acc atomic capture
892 LHS = RHS = RHS / 1;
893 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
894 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
895 #pragma acc atomic capture
896 LHS = RHS = 1 / RHS;
897 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
898 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
899 #pragma acc atomic capture
900 LHS = RHS = RHS ^ 1;
901 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
902 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
903 #pragma acc atomic capture
904 LHS = RHS = 1 % RHS;
905
906 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
907 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
908 #pragma acc atomic capture
909 LHS = RHS = RHS < 1;
910 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
911 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
912 #pragma acc atomic capture
913 LHS = RHS = 1 > RHS;
914
915 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
916 // expected-note@+2{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('RHS' and 'getRValue<T>()')}}
917 #pragma acc atomic capture
918 LHS = LHS = RHS + getRValue<T>();
919
920 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
921 // expected-note@+2{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('getRValue<T>()' and 'RHS')}}
922 #pragma acc atomic capture
923 LHS = LHS = getRValue<T>() + RHS;
924 }
925
926 void AtomicCaptureSimple(int LHS, int RHS) {
927 AtomicCaptureTemplateSimple(1, 2);
928 AtomicCaptureTemplateSimple2(S1, S2); //expected-note{{in instantiation of function template specialization}}
929
930 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
931 // expected-note@+2{{expected assignment expression}}
932 #pragma acc atomic capture
933 LHS++;
934 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
935 // expected-note@+2{{expected assignment expression}}
936 #pragma acc atomic capture
937 --LHS;
938
939 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
940 // expected-note@+2{{expected assignment expression}}
941 #pragma acc atomic capture
942 LHS += 1 + RHS;
943
944 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
945 // expected-note@+2{{expected assignment, compound assignment, increment, or decrement expression}}
946 #pragma acc atomic capture
947 LHS = RHS;
948
949 #pragma acc atomic capture
950 LHS = RHS++;
951
952 #pragma acc atomic capture
953 LHS = RHS--;
954
955 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
956 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
957 #pragma acc atomic capture
958 S1 = ++S2;
959
960 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
961 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
962 #pragma acc atomic capture
963 S1 = --S2 ;
964
965 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
966 // expected-note@+2{{unary operator not supported, only increment and decrement operations permitted}}
967 #pragma acc atomic capture
968 LHS = +RHS;
969
970 #pragma acc atomic capture
971 LHS = RHS += 1 + RHS;
972 #pragma acc atomic capture
973 LHS = RHS *= 1 + RHS;
974 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
975 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
976 #pragma acc atomic capture
977 S1 = RHS -= 1 + RHS;
978 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
979 // expected-note@+2{{expected assignment, compound assignment, increment, or decrement expression}}
980 #pragma acc atomic capture
981 LHS = S1 /= 1 + RHS;
982 #pragma acc atomic capture
983 LHS = RHS &= 1 + S2;
984 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
985 // expected-note@+2{{expected assignment, compound assignment, increment, or decrement expression}}
986 #pragma acc atomic capture
987 LHS = S1^= 1 + S2;
988
989 #pragma acc atomic capture
990 LHS = RHS ^= 1 + RHS;
991 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
992 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
993 #pragma acc atomic capture
994 LHS = RHS <= 1 + RHS;
995 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
996 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
997 #pragma acc atomic capture
998 S1 = RHS ^= 1 + RHS;
999 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1000 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
1001 #pragma acc atomic capture
1002 LHS = S1 <= 1 + RHS;
1003 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1004 // expected-note@+2{{compound binary operator not supported, only +=, *=, -=, /=, &=, ^=, |=, <<=, or >>= are permitted}}
1005 #pragma acc atomic capture
1006 LHS = RHS <= 1 + S2;
1007
1008 #pragma acc atomic capture
1009 LHS = RHS = RHS + 1;
1010 #pragma acc atomic capture
1011 LHS = RHS = 1 + RHS;
1012 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1013 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1014 #pragma acc atomic capture
1015 S1 = RHS = RHS * 1;
1016 // A little weird, because this contains a 'operator int' call here rather
1017 // than a conversion, so the diagnostic could be better.
1018 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1019 // expected-note@+2{{expected assignment, compound assignment, increment, or decrement expression}}
1020 #pragma acc atomic capture
1021 LHS = S2 = 1 * S2;
1022
1023 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1024 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
1025 #pragma acc atomic capture
1026 LHS = RHS = RHS < 1;
1027 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1028 // expected-note@+2{{binary operator not supported, only +, *, -, /, &, ^, |, <<, or >> are permitted}}
1029 #pragma acc atomic capture
1030 LHS = RHS = 1 > RHS;
1031 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1032 // expected-note@+2{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1033 #pragma acc atomic capture
1034 S1 = RHS = RHS < 1;
1035
1036 // A little weird, because this contains a 'operator int' call here rather
1037 // than a conversion, so the diagnostic could be better.
1038 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1039 // expected-note@+2{{expected assignment, compound assignment, increment, or decrement expression}}
1040 #pragma acc atomic capture
1041 LHS = S1 = 1 > S1;
1042
1043 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1044 // expected-note@+2{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('RHS' and 'getRValue<int>()')}}
1045 #pragma acc atomic capture
1046 LHS = LHS = RHS + getRValue<int>();
1047
1048 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1049 // expected-note@+2{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('getRValue<int>()' and 'RHS')}}
1050 #pragma acc atomic capture
1051 LHS = LHS = getRValue<int>() + RHS;
1052 }
1053
1054 template<typename T>
1055 void AtomicCaptureTemplateCompound(T LHS, T RHS) {
1056
1057 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1058 // expected-note@+2{{expected assignment, compound assignment, increment, or decrement expression}}
1059 #pragma acc atomic capture
1060 {
1061 }
1062
1063 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1064 // expected-note@+4{{expected assignment, compound assignment, increment, or decrement expression}}
1065 #pragma acc atomic capture
1066 {
1067 LHS = RHS;
1068 }
1069
1070 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1071 // expected-note@+3{{'atomic capture' with a compound statement only supports two statements}}
1072 #pragma acc atomic capture
1073 {
1074 LHS = RHS; RHS += 1; LHS=RHS;
1075 }
1076
1077
1078 #pragma acc atomic capture
1079 {
1080 LHS++;
1081 RHS = LHS;
1082 }
1083
1084 #pragma acc atomic capture
1085 {
1086 ++LHS;
1087 RHS = LHS;
1088 }
1089
1090 #pragma acc atomic capture
1091 {
1092 --LHS;
1093 RHS = LHS;
1094 }
1095
1096
1097 #pragma acc atomic capture
1098 {
1099 LHS--;
1100 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1101 // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used in unary expression('LHS') from the first statement}}
1102 LHS = RHS;
1103 }
1104
1105 #pragma acc atomic capture
1106 {
1107 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1108 // expected-note@+1{{unary operator not supported, only increment and decrement operations permitted}}
1109 -LHS;
1110 RHS = LHS;
1111 }
1112
1113 #pragma acc atomic capture
1114 {
1115 --LHS;
1116 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1117 // expected-note@+1{{expected assignment expression}}
1118 RHS += LHS;
1119 }
1120
1121 // { x binop = expr; v = x; }
1122 #pragma acc atomic capture
1123 {
1124 LHS += 1;
1125 RHS = LHS;
1126 }
1127 #pragma acc atomic capture
1128 {
1129 LHS *= 1;
1130 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1131 // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of compound assignment('LHS') from the first statement}}
1132 LHS = RHS;
1133 }
1134 #pragma acc atomic capture
1135 {
1136 LHS /= 1;
1137 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1138 // expected-note@+1{{expected assignment expression}}
1139 RHS += LHS;
1140 }
1141
1142 // { x = x binop expr; v = x; }
1143 #pragma acc atomic capture
1144 {
1145 LHS = LHS + 1;
1146 RHS = LHS;
1147 }
1148
1149 #pragma acc atomic capture
1150 {
1151 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1152 // expected-note@+1{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('RHS' and '1')}}
1153 LHS = RHS - 1;
1154 RHS = LHS;
1155 }
1156 #pragma acc atomic capture
1157 {
1158 LHS = LHS * 1;
1159 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1160 // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of assignment('LHS') from the first statement}}
1161 RHS = RHS;
1162 }
1163 #pragma acc atomic capture
1164 {
1165 LHS = LHS / 1;
1166 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1167 // expected-note@+1{{expected assignment expression}}
1168 RHS += LHS;
1169 }
1170
1171 // { x = expr binop x; v = x; }
1172 #pragma acc atomic capture
1173 {
1174 LHS = 1 ^ LHS;
1175 RHS = LHS;
1176 }
1177
1178 #pragma acc atomic capture
1179 {
1180 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1181 // expected-note@+1{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('1' and 'RHS')}}
1182 LHS = 1 & RHS;
1183 RHS = LHS;
1184 }
1185 #pragma acc atomic capture
1186 {
1187 LHS = LHS | 1;
1188 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1189 // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of assignment('LHS') from the first statement}}
1190 RHS = RHS;
1191 }
1192 #pragma acc atomic capture
1193 {
1194 LHS = LHS << 1;
1195 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1196 // expected-note@+1{{expected assignment expression}}
1197 RHS += LHS;
1198 }
1199
1200 // { v = x; x binop = expr; }
1201 #pragma acc atomic capture
1202 {
1203 LHS = RHS;
1204 RHS += 1;
1205 }
1206
1207 // { v = x; x = x binop expr; }
1208 #pragma acc atomic capture
1209 {
1210 LHS = RHS;
1211 RHS = RHS / 1;
1212 }
1213 #pragma acc atomic capture
1214 {
1215 LHS = RHS;
1216 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1217 // expected-note@+1{{left hand side of assignment operation('RHS') must match one side of the sub-operation on the right hand side('LHS' and '1')}}
1218 RHS = LHS ^ 1;
1219 }
1220 #pragma acc atomic capture
1221 {
1222 LHS = RHS;
1223 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1224 // expected-note@+1{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('RHS' and '1')}}
1225 LHS = RHS << 1;
1226 }
1227 // { v = x; x = expr binop x; }
1228 #pragma acc atomic capture
1229 {
1230 LHS = RHS;
1231 RHS = 1 / RHS;
1232 }
1233 #pragma acc atomic capture
1234 {
1235 LHS = RHS;
1236 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1237 // expected-note@+1{{left hand side of assignment operation('RHS') must match one side of the sub-operation on the right hand side('1' and 'LHS')}}
1238 RHS = 1 ^ LHS;
1239 }
1240 #pragma acc atomic capture
1241 {
1242 LHS = RHS;
1243 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1244 // expected-note@+1{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('1' and 'RHS')}}
1245 LHS = 1 << RHS;
1246 }
1247
1248 // { v = x; x = expr; }
1249 #pragma acc atomic capture
1250 {
1251 LHS = RHS;
1252 RHS = 1;
1253 }
1254 #pragma acc atomic capture
1255 {
1256 LHS = RHS;
1257 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1258 // expected-note@+1{{sub-expression on left hand side of assignment('LHS') must match sub-expression used on right hand side of assignment('RHS') from the first statement}}
1259 LHS = 1;
1260 }
1261
1262 // { v = x; x++; }
1263 // { v = x; ++x; }
1264 // { v = x; x--; }
1265 // { v = x; --x; }
1266 #pragma acc atomic capture
1267 {
1268 LHS = RHS;
1269 RHS++;
1270 }
1271 #pragma acc atomic capture
1272 {
1273 LHS = RHS;
1274 RHS--;
1275 }
1276 #pragma acc atomic capture
1277 {
1278 LHS = RHS;
1279 ++RHS;
1280 }
1281 #pragma acc atomic capture
1282 {
1283 LHS = RHS;
1284 --RHS;
1285 }
1286 #pragma acc atomic capture
1287 {
1288 LHS = RHS;
1289 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1290 // expected-note@+1{{unary operator not supported, only increment and decrement operations permitted}}
1291 -RHS;
1292 }
1293 #pragma acc atomic capture
1294 {
1295 LHS = RHS;
1296 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1297 // expected-note@+1{{sub-expression in unary expression('LHS') must match sub-expression used on right hand side of assignment('RHS') from the first statement}}
1298 LHS++;
1299 }
1300 }
1301
1302 template<typename T>
1303 void AtomicCaptureTemplateCompound2(T LHS, T RHS) {
1304
1305 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1306 // expected-note@+2{{expected assignment, compound assignment, increment, or decrement expression}}
1307 #pragma acc atomic capture
1308 {
1309 }
1310
1311 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1312 // expected-note@+4{{expected assignment, compound assignment, increment, or decrement expression}}
1313 #pragma acc atomic capture
1314 {
1315 LHS = RHS;
1316 }
1317
1318 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1319 // expected-note@+3{{'atomic capture' with a compound statement only supports two statements}}
1320 #pragma acc atomic capture
1321 {
1322 LHS = RHS; RHS += 1; LHS=RHS;
1323 }
1324
1325
1326 #pragma acc atomic capture
1327 {
1328 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1329 // expected-note@+1{{operand to increment expression must be of scalar type (was 'Struct')}}
1330 LHS++;
1331 RHS = LHS;
1332 }
1333
1334 #pragma acc atomic capture
1335 {
1336 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1337 // expected-note@+1{{operand to increment expression must be of scalar type (was 'Struct')}}
1338 ++LHS;
1339 RHS = LHS;
1340 }
1341
1342 #pragma acc atomic capture
1343 {
1344 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1345 // expected-note@+1{{operand to decrement expression must be of scalar type (was 'Struct')}}
1346 --LHS;
1347 RHS = LHS;
1348 }
1349
1350
1351 #pragma acc atomic capture
1352 {
1353 LHS--;
1354 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1355 // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used in unary expression('LHS') from the first statement}}
1356 LHS = RHS;
1357 }
1358
1359 #pragma acc atomic capture
1360 {
1361 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1362 // expected-note@+1{{unary operator not supported, only increment and decrement operations permitted}}
1363 -LHS;
1364 RHS = LHS;
1365 }
1366
1367 #pragma acc atomic capture
1368 {
1369 --LHS;
1370 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1371 // expected-note@+1{{expected assignment expression}}
1372 RHS += LHS;
1373 }
1374
1375 // { x binop = expr; v = x; }
1376 #pragma acc atomic capture
1377 {
1378 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1379 // expected-note@+1{{left operand to compound assignment expression must be of scalar type (was 'Struct')}}
1380 LHS += 1;
1381 RHS = LHS;
1382 }
1383 #pragma acc atomic capture
1384 {
1385 LHS *= 1;
1386 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1387 // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of compound assignment('LHS') from the first statement}}
1388 LHS = RHS;
1389 }
1390 #pragma acc atomic capture
1391 {
1392 LHS /= 1;
1393 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1394 // expected-note@+1{{expected assignment expression}}
1395 RHS += LHS;
1396 }
1397
1398 // { x = x binop expr; v = x; }
1399 #pragma acc atomic capture
1400 {
1401 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1402 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1403 LHS = LHS + 1;
1404 RHS = LHS;
1405 }
1406
1407 #pragma acc atomic capture
1408 {
1409 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1410 // expected-note@+1{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('RHS' and '1')}}
1411 LHS = RHS - 1;
1412 RHS = LHS;
1413 }
1414 #pragma acc atomic capture
1415 {
1416 LHS = LHS * 1;
1417 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1418 // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of assignment('LHS') from the first statement}}
1419 RHS = RHS;
1420 }
1421 #pragma acc atomic capture
1422 {
1423 LHS = LHS / 1;
1424 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1425 // expected-note@+1{{expected assignment expression}}
1426 RHS += LHS;
1427 }
1428
1429 // { x = expr binop x; v = x; }
1430 #pragma acc atomic capture
1431 {
1432 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1433 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1434 LHS = 1 ^ LHS;
1435 RHS = LHS;
1436 }
1437
1438 #pragma acc atomic capture
1439 {
1440 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1441 // expected-note@+1{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('1' and 'RHS')}}
1442 LHS = 1 & RHS;
1443 RHS = LHS;
1444 }
1445 #pragma acc atomic capture
1446 {
1447 LHS = LHS | 1;
1448 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1449 // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of assignment('LHS') from the first statement}}
1450 RHS = RHS;
1451 }
1452 #pragma acc atomic capture
1453 {
1454 LHS = LHS << 1;
1455 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1456 // expected-note@+1{{expected assignment expression}}
1457 RHS += LHS;
1458 }
1459
1460 // { v = x; x binop = expr; }
1461 #pragma acc atomic capture
1462 {
1463 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1464 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1465 LHS = RHS;
1466 RHS += 1;
1467 }
1468
1469 // { v = x; x = x binop expr; }
1470 #pragma acc atomic capture
1471 {
1472 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1473 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1474 LHS = RHS;
1475 RHS = RHS / 1;
1476 }
1477 #pragma acc atomic capture
1478 {
1479 LHS = RHS;
1480 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1481 // expected-note@+1{{left hand side of assignment operation('RHS') must match one side of the sub-operation on the right hand side('LHS' and '1')}}
1482 RHS = LHS ^ 1;
1483 }
1484 #pragma acc atomic capture
1485 {
1486 LHS = RHS;
1487 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1488 // expected-note@+1{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('RHS' and '1')}}
1489 LHS = RHS << 1;
1490 }
1491 // { v = x; x = expr binop x; }
1492 #pragma acc atomic capture
1493 {
1494 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1495 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1496 LHS = RHS;
1497 RHS = 1 / RHS;
1498 }
1499 #pragma acc atomic capture
1500 {
1501 LHS = RHS;
1502 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1503 // expected-note@+1{{left hand side of assignment operation('RHS') must match one side of the sub-operation on the right hand side('1' and 'LHS')}}
1504 RHS = 1 ^ LHS;
1505 }
1506 #pragma acc atomic capture
1507 {
1508 LHS = RHS;
1509 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1510 // expected-note@+1{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('1' and 'RHS')}}
1511 LHS = 1 << RHS;
1512 }
1513
1514 // { v = x; x = expr; }
1515 #pragma acc atomic capture
1516 {
1517 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1518 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1519 LHS = RHS;
1520 RHS = 1;
1521 }
1522 #pragma acc atomic capture
1523 {
1524 LHS = RHS;
1525 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1526 // expected-note@+1{{sub-expression on left hand side of assignment('LHS') must match sub-expression used on right hand side of assignment('RHS') from the first statement}}
1527 LHS = 1;
1528 }
1529
1530 // { v = x; x++; }
1531 // { v = x; ++x; }
1532 // { v = x; x--; }
1533 // { v = x; --x; }
1534 #pragma acc atomic capture
1535 {
1536 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1537 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1538 LHS = RHS;
1539 RHS++;
1540 }
1541 #pragma acc atomic capture
1542 {
1543 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1544 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1545 LHS = RHS;
1546 RHS--;
1547 }
1548 #pragma acc atomic capture
1549 {
1550 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1551 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1552 LHS = RHS;
1553 ++RHS;
1554 }
1555 #pragma acc atomic capture
1556 {
1557 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1558 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1559 LHS = RHS;
1560 --RHS;
1561 }
1562 #pragma acc atomic capture
1563 {
1564 LHS = RHS;
1565 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1566 // expected-note@+1{{unary operator not supported, only increment and decrement operations permitted}}
1567 -RHS;
1568 }
1569 #pragma acc atomic capture
1570 {
1571 LHS = RHS;
1572 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1573 // expected-note@+1{{sub-expression in unary expression('LHS') must match sub-expression used on right hand side of assignment('RHS') from the first statement}}
1574 LHS++;
1575 }
1576 }
1577 void AtomicCaptureCompound(int LHS, int RHS) {
1578 AtomicCaptureTemplateCompound(1, 2);
1579 AtomicCaptureTemplateCompound2(S1, S2); //expected-note{{in instantiation of function template specialization}}
1580
1581 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1582 // expected-note@+2{{expected assignment, compound assignment, increment, or decrement expression}}
1583 #pragma acc atomic capture
1584 {
1585 }
1586
1587 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1588 // expected-note@+4{{expected assignment, compound assignment, increment, or decrement expression}}
1589 #pragma acc atomic capture
1590 {
1591 LHS = RHS;
1592 }
1593
1594 // expected-error@+2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1595 // expected-note@+3{{'atomic capture' with a compound statement only supports two statements}}
1596 #pragma acc atomic capture
1597 {
1598 LHS = RHS; RHS += 1; LHS=RHS;
1599 }
1600
1601
1602 #pragma acc atomic capture
1603 {
1604 LHS++;
1605 RHS = LHS;
1606 }
1607 #pragma acc atomic capture
1608 {
1609 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1610 // expected-note@+1{{operand to increment expression must be of scalar type (was 'Struct')}}
1611 S1++;
1612 S2= S1;
1613 }
1614
1615 #pragma acc atomic capture
1616 {
1617 ++LHS;
1618 RHS = LHS;
1619 }
1620
1621 #pragma acc atomic capture
1622 {
1623 --LHS;
1624 RHS = LHS;
1625 }
1626
1627
1628 #pragma acc atomic capture
1629 {
1630 LHS--;
1631 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1632 // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used in unary expression('LHS') from the first statement}}
1633 LHS = RHS;
1634 }
1635
1636 #pragma acc atomic capture
1637 {
1638 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1639 // expected-note@+1{{unary operator not supported, only increment and decrement operations permitted}}
1640 -LHS;
1641 RHS = LHS;
1642 }
1643
1644 #pragma acc atomic capture
1645 {
1646 --LHS;
1647 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1648 // expected-note@+1{{expected assignment expression}}
1649 RHS += LHS;
1650 }
1651
1652 // { x binop = expr; v = x; }
1653 #pragma acc atomic capture
1654 {
1655 LHS += 1;
1656 RHS = LHS;
1657 }
1658 #pragma acc atomic capture
1659 {
1660 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1661 // expected-note@+1{{left operand to compound assignment expression must be of scalar type (was 'Struct')}}
1662 S1 += 1;
1663 S2= S1;
1664 }
1665 #pragma acc atomic capture
1666 {
1667 LHS *= 1;
1668 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1669 // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of compound assignment('LHS') from the first statement}}
1670 LHS = RHS;
1671 }
1672 #pragma acc atomic capture
1673 {
1674 LHS /= 1;
1675 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1676 // expected-note@+1{{expected assignment expression}}
1677 RHS += LHS;
1678 }
1679
1680 // { x = x binop expr; v = x; }
1681 #pragma acc atomic capture
1682 {
1683 LHS = LHS + 1;
1684 RHS = LHS;
1685 }
1686 #pragma acc atomic capture
1687 {
1688 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1689 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1690 S1 = S1 + 1;
1691 S2= S1;
1692 }
1693
1694 #pragma acc atomic capture
1695 {
1696 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1697 // expected-note@+1{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('RHS' and '1')}}
1698 LHS = RHS - 1;
1699 RHS = LHS;
1700 }
1701 #pragma acc atomic capture
1702 {
1703 LHS = LHS * 1;
1704 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1705 // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of assignment('LHS') from the first statement}}
1706 RHS = RHS;
1707 }
1708 #pragma acc atomic capture
1709 {
1710 LHS = LHS / 1;
1711 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1712 // expected-note@+1{{expected assignment expression}}
1713 RHS += LHS;
1714 }
1715
1716 // { x = expr binop x; v = x; }
1717 #pragma acc atomic capture
1718 {
1719 LHS = 1 ^ LHS;
1720 RHS = LHS;
1721 }
1722 #pragma acc atomic capture
1723 {
1724 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1725 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1726 S1 = 1 ^ S1;
1727 S2 = S1;
1728 }
1729
1730 #pragma acc atomic capture
1731 {
1732 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1733 // expected-note@+1{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('1' and 'RHS')}}
1734 LHS = 1 & RHS;
1735 RHS = LHS;
1736 }
1737 #pragma acc atomic capture
1738 {
1739 LHS = LHS | 1;
1740 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1741 // expected-note@+1{{sub-expression on right hand side of assignment('RHS') must match sub-expression used on left hand side of assignment('LHS') from the first statement}}
1742 RHS = RHS;
1743 }
1744 #pragma acc atomic capture
1745 {
1746 LHS = LHS << 1;
1747 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1748 // expected-note@+1{{expected assignment expression}}
1749 RHS += LHS;
1750 }
1751
1752 // { v = x; x binop = expr; }
1753 #pragma acc atomic capture
1754 {
1755 LHS = RHS;
1756 RHS += 1;
1757 }
1758
1759 #pragma acc atomic capture
1760 {
1761 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1762 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1763 S1 = S2;
1764 S2 += 1;
1765 }
1766
1767 // { v = x; x = x binop expr; }
1768 #pragma acc atomic capture
1769 {
1770 LHS = RHS;
1771 RHS = RHS / 1;
1772 }
1773 #pragma acc atomic capture
1774 {
1775 LHS = RHS;
1776 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1777 // expected-note@+1{{left hand side of assignment operation('RHS') must match one side of the sub-operation on the right hand side('LHS' and '1')}}
1778 RHS = LHS ^ 1;
1779 }
1780 #pragma acc atomic capture
1781 {
1782 LHS = RHS;
1783 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1784 // expected-note@+1{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('RHS' and '1')}}
1785 LHS = RHS << 1;
1786 }
1787 // { v = x; x = expr binop x; }
1788 #pragma acc atomic capture
1789 {
1790 LHS = RHS;
1791 RHS = 1 / RHS;
1792 }
1793 #pragma acc atomic capture
1794 {
1795 LHS = RHS;
1796 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1797 // expected-note@+1{{left hand side of assignment operation('RHS') must match one side of the sub-operation on the right hand side('1' and 'LHS')}}
1798 RHS = 1 ^ LHS;
1799 }
1800 #pragma acc atomic capture
1801 {
1802 LHS = RHS;
1803 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1804 // expected-note@+1{{left hand side of assignment operation('LHS') must match one side of the sub-operation on the right hand side('1' and 'RHS')}}
1805 LHS = 1 << RHS;
1806 }
1807
1808 // { v = x; x = expr; }
1809 #pragma acc atomic capture
1810 {
1811 LHS = RHS;
1812 RHS = 1;
1813 }
1814 #pragma acc atomic capture
1815 {
1816 LHS = RHS;
1817 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1818 // expected-note@+1{{sub-expression on left hand side of assignment('LHS') must match sub-expression used on right hand side of assignment('RHS') from the first statement}}
1819 LHS = 1;
1820 }
1821
1822 // { v = x; x++; }
1823 // { v = x; ++x; }
1824 // { v = x; x--; }
1825 // { v = x; --x; }
1826 #pragma acc atomic capture
1827 {
1828 LHS = RHS;
1829 RHS++;
1830 }
1831 #pragma acc atomic capture
1832 {
1833 LHS = RHS;
1834 RHS--;
1835 }
1836 #pragma acc atomic capture
1837 {
1838 LHS = RHS;
1839 ++RHS;
1840 }
1841 #pragma acc atomic capture
1842 {
1843 LHS = RHS;
1844 --RHS;
1845 }
1846 #pragma acc atomic capture
1847 {
1848 // expected-error@-2{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1849 // expected-note@+1{{left operand to assignment expression must be of scalar type (was 'Struct')}}
1850 S1= S2;
1851 --S2;
1852 }
1853 #pragma acc atomic capture
1854 {
1855 LHS = RHS;
1856 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1857 // expected-note@+1{{unary operator not supported, only increment and decrement operations permitted}}
1858 -RHS;
1859 }
1860 #pragma acc atomic capture
1861 {
1862 LHS = RHS;
1863 // expected-error@-3{{statement associated with OpenACC 'atomic capture' directive is invalid}}
1864 // expected-note@+1{{sub-expression in unary expression('LHS') must match sub-expression used on right hand side of assignment('RHS') from the first statement}}
1865 LHS++;
1866 }
1867
1868 // Example from UDel test suite, which wasn't working because of irrelevant
1869 // parens, make sure we work with these. This should not diagnose.
1870 typedef double real_t;
1871 int * distribution;
1872 real_t *a;
1873 real_t *b;
1874 int *c;
1875 for (int x = 0; x < 5; ++x) {
1876 #pragma acc atomic capture
1877 {
1878 c[x] = distribution[(int) (a[x]*b[x]/10)];
1879 (distribution[(int)(a[x]*b[x]/10)])--;
1880 }
1881 }
1882
1883 }