1*67e74705SXin Li // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
2*67e74705SXin Li
foo()3*67e74705SXin Li int foo() {
4*67e74705SXin Li L1:
5*67e74705SXin Li foo();
6*67e74705SXin Li #pragma omp atomic
7*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
8*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
9*67e74705SXin Li {
10*67e74705SXin Li foo();
11*67e74705SXin Li goto L1; // expected-error {{use of undeclared label 'L1'}}
12*67e74705SXin Li }
13*67e74705SXin Li goto L2; // expected-error {{use of undeclared label 'L2'}}
14*67e74705SXin Li #pragma omp atomic
15*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
16*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
17*67e74705SXin Li {
18*67e74705SXin Li foo();
19*67e74705SXin Li L2:
20*67e74705SXin Li foo();
21*67e74705SXin Li }
22*67e74705SXin Li
23*67e74705SXin Li return 0;
24*67e74705SXin Li }
25*67e74705SXin Li
26*67e74705SXin Li struct S {
27*67e74705SXin Li int a;
operator =S28*67e74705SXin Li S &operator=(int v) {
29*67e74705SXin Li a = v;
30*67e74705SXin Li return *this;
31*67e74705SXin Li }
operator +=S32*67e74705SXin Li S &operator+=(const S &s) {
33*67e74705SXin Li a += s.a;
34*67e74705SXin Li return *this;
35*67e74705SXin Li }
36*67e74705SXin Li };
37*67e74705SXin Li
38*67e74705SXin Li template <class T>
read()39*67e74705SXin Li T read() {
40*67e74705SXin Li T a = T(), b = T();
41*67e74705SXin Li // Test for atomic read
42*67e74705SXin Li #pragma omp atomic read
43*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
44*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
45*67e74705SXin Li ;
46*67e74705SXin Li #pragma omp atomic read
47*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
48*67e74705SXin Li // expected-note@+1 {{expected built-in assignment operator}}
49*67e74705SXin Li foo();
50*67e74705SXin Li #pragma omp atomic read
51*67e74705SXin Li // expected-error@+2 2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
52*67e74705SXin Li // expected-note@+1 2 {{expected built-in assignment operator}}
53*67e74705SXin Li a += b;
54*67e74705SXin Li #pragma omp atomic read
55*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
56*67e74705SXin Li // expected-note@+1 {{expected lvalue expression}}
57*67e74705SXin Li a = 0;
58*67e74705SXin Li #pragma omp atomic read
59*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
60*67e74705SXin Li // expected-note@+1 {{expected built-in assignment operator}}
61*67e74705SXin Li a = b;
62*67e74705SXin Li // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}}
63*67e74705SXin Li #pragma omp atomic read read
64*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
65*67e74705SXin Li // expected-note@+1 {{expected built-in assignment operator}}
66*67e74705SXin Li a = b;
67*67e74705SXin Li
68*67e74705SXin Li return a;
69*67e74705SXin Li }
70*67e74705SXin Li
read()71*67e74705SXin Li int read() {
72*67e74705SXin Li int a = 0, b = 0;
73*67e74705SXin Li // Test for atomic read
74*67e74705SXin Li #pragma omp atomic read
75*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
76*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
77*67e74705SXin Li ;
78*67e74705SXin Li #pragma omp atomic read
79*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
80*67e74705SXin Li // expected-note@+1 {{expected built-in assignment operator}}
81*67e74705SXin Li foo();
82*67e74705SXin Li #pragma omp atomic read
83*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
84*67e74705SXin Li // expected-note@+1 {{expected built-in assignment operator}}
85*67e74705SXin Li a += b;
86*67e74705SXin Li #pragma omp atomic read
87*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic read' must be an expression statement of form 'v = x;', where v and x are both lvalue expressions with scalar type}}
88*67e74705SXin Li // expected-note@+1 {{expected lvalue expression}}
89*67e74705SXin Li a = 0;
90*67e74705SXin Li #pragma omp atomic read
91*67e74705SXin Li a = b;
92*67e74705SXin Li // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}}
93*67e74705SXin Li #pragma omp atomic read read
94*67e74705SXin Li a = b;
95*67e74705SXin Li
96*67e74705SXin Li // expected-note@+2 {{in instantiation of function template specialization 'read<S>' requested here}}
97*67e74705SXin Li // expected-note@+1 {{in instantiation of function template specialization 'read<int>' requested here}}
98*67e74705SXin Li return read<int>() + read<S>().a;
99*67e74705SXin Li }
100*67e74705SXin Li
101*67e74705SXin Li template <class T>
write()102*67e74705SXin Li T write() {
103*67e74705SXin Li T a, b = 0;
104*67e74705SXin Li // Test for atomic write
105*67e74705SXin Li #pragma omp atomic write
106*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is a lvalue expression with scalar type}}
107*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
108*67e74705SXin Li ;
109*67e74705SXin Li // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}}
110*67e74705SXin Li #pragma omp atomic write write
111*67e74705SXin Li a = b;
112*67e74705SXin Li #pragma omp atomic write
113*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is a lvalue expression with scalar type}}
114*67e74705SXin Li // expected-note@+1 {{expected built-in assignment operator}}
115*67e74705SXin Li foo();
116*67e74705SXin Li #pragma omp atomic write
117*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is a lvalue expression with scalar type}}
118*67e74705SXin Li // expected-note@+1 {{expected built-in assignment operator}}
119*67e74705SXin Li a += b;
120*67e74705SXin Li #pragma omp atomic write
121*67e74705SXin Li a = 0;
122*67e74705SXin Li #pragma omp atomic write
123*67e74705SXin Li a = b;
124*67e74705SXin Li
125*67e74705SXin Li return T();
126*67e74705SXin Li }
127*67e74705SXin Li
write()128*67e74705SXin Li int write() {
129*67e74705SXin Li int a, b = 0;
130*67e74705SXin Li // Test for atomic write
131*67e74705SXin Li #pragma omp atomic write
132*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is a lvalue expression with scalar type}}
133*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
134*67e74705SXin Li ;
135*67e74705SXin Li // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}}
136*67e74705SXin Li #pragma omp atomic write write
137*67e74705SXin Li a = b;
138*67e74705SXin Li #pragma omp atomic write
139*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is a lvalue expression with scalar type}}
140*67e74705SXin Li // expected-note@+1 {{expected built-in assignment operator}}
141*67e74705SXin Li foo();
142*67e74705SXin Li #pragma omp atomic write
143*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic write' must be an expression statement of form 'x = expr;', where x is a lvalue expression with scalar type}}
144*67e74705SXin Li // expected-note@+1 {{expected built-in assignment operator}}
145*67e74705SXin Li a += b;
146*67e74705SXin Li #pragma omp atomic write
147*67e74705SXin Li a = 0;
148*67e74705SXin Li #pragma omp atomic write
149*67e74705SXin Li a = foo();
150*67e74705SXin Li
151*67e74705SXin Li // expected-note@+1 {{in instantiation of function template specialization 'write<int>' requested here}}
152*67e74705SXin Li return write<int>();
153*67e74705SXin Li }
154*67e74705SXin Li
155*67e74705SXin Li template <class T>
update()156*67e74705SXin Li T update() {
157*67e74705SXin Li T a = 0, b = 0, c = 0;
158*67e74705SXin Li // Test for atomic update
159*67e74705SXin Li #pragma omp atomic update
160*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
161*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
162*67e74705SXin Li ;
163*67e74705SXin Li // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}}
164*67e74705SXin Li #pragma omp atomic update update
165*67e74705SXin Li a += b;
166*67e74705SXin Li #pragma omp atomic
167*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
168*67e74705SXin Li // expected-note@+1 {{expected built-in binary operator}}
169*67e74705SXin Li a = b;
170*67e74705SXin Li #pragma omp atomic update
171*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
172*67e74705SXin Li // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}}
173*67e74705SXin Li a = b || a;
174*67e74705SXin Li #pragma omp atomic update
175*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
176*67e74705SXin Li // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}}
177*67e74705SXin Li a = a && b;
178*67e74705SXin Li #pragma omp atomic update
179*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
180*67e74705SXin Li // expected-note@+1 {{expected in right hand side of expression}}
181*67e74705SXin Li a = float(a) + b;
182*67e74705SXin Li #pragma omp atomic
183*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
184*67e74705SXin Li // expected-note@+1 {{expected in right hand side of expression}}
185*67e74705SXin Li a = 2 * b;
186*67e74705SXin Li #pragma omp atomic
187*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
188*67e74705SXin Li // expected-note@+1 {{expected in right hand side of expression}}
189*67e74705SXin Li a = b + *&a;
190*67e74705SXin Li #pragma omp atomic
191*67e74705SXin Li *&a = b * *&a;
192*67e74705SXin Li #pragma omp atomic update
193*67e74705SXin Li a++;
194*67e74705SXin Li #pragma omp atomic
195*67e74705SXin Li ++a;
196*67e74705SXin Li #pragma omp atomic update
197*67e74705SXin Li a--;
198*67e74705SXin Li #pragma omp atomic
199*67e74705SXin Li --a;
200*67e74705SXin Li #pragma omp atomic update
201*67e74705SXin Li a += b;
202*67e74705SXin Li #pragma omp atomic
203*67e74705SXin Li a %= b;
204*67e74705SXin Li #pragma omp atomic update
205*67e74705SXin Li a *= b;
206*67e74705SXin Li #pragma omp atomic
207*67e74705SXin Li a -= b;
208*67e74705SXin Li #pragma omp atomic update
209*67e74705SXin Li a /= b;
210*67e74705SXin Li #pragma omp atomic
211*67e74705SXin Li a &= b;
212*67e74705SXin Li #pragma omp atomic update
213*67e74705SXin Li a ^= b;
214*67e74705SXin Li #pragma omp atomic
215*67e74705SXin Li a |= b;
216*67e74705SXin Li #pragma omp atomic update
217*67e74705SXin Li a <<= b;
218*67e74705SXin Li #pragma omp atomic
219*67e74705SXin Li a >>= b;
220*67e74705SXin Li #pragma omp atomic update
221*67e74705SXin Li a = b + a;
222*67e74705SXin Li #pragma omp atomic
223*67e74705SXin Li a = a * b;
224*67e74705SXin Li #pragma omp atomic update
225*67e74705SXin Li a = b - a;
226*67e74705SXin Li #pragma omp atomic
227*67e74705SXin Li a = a / b;
228*67e74705SXin Li #pragma omp atomic update
229*67e74705SXin Li a = b & a;
230*67e74705SXin Li #pragma omp atomic
231*67e74705SXin Li a = a ^ b;
232*67e74705SXin Li #pragma omp atomic update
233*67e74705SXin Li a = b | a;
234*67e74705SXin Li #pragma omp atomic
235*67e74705SXin Li a = a << b;
236*67e74705SXin Li #pragma omp atomic
237*67e74705SXin Li a = b >> a;
238*67e74705SXin Li
239*67e74705SXin Li #pragma omp atomic
240*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
241*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
242*67e74705SXin Li ;
243*67e74705SXin Li
244*67e74705SXin Li return T();
245*67e74705SXin Li }
246*67e74705SXin Li
update()247*67e74705SXin Li int update() {
248*67e74705SXin Li int a, b = 0;
249*67e74705SXin Li // Test for atomic update
250*67e74705SXin Li #pragma omp atomic update
251*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
252*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
253*67e74705SXin Li ;
254*67e74705SXin Li // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}}
255*67e74705SXin Li #pragma omp atomic update update
256*67e74705SXin Li a += b;
257*67e74705SXin Li #pragma omp atomic
258*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
259*67e74705SXin Li // expected-note@+1 {{expected built-in binary operator}}
260*67e74705SXin Li a = b;
261*67e74705SXin Li #pragma omp atomic update
262*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
263*67e74705SXin Li // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}}
264*67e74705SXin Li a = b || a;
265*67e74705SXin Li #pragma omp atomic update
266*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
267*67e74705SXin Li // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}}
268*67e74705SXin Li a = a && b;
269*67e74705SXin Li #pragma omp atomic update
270*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
271*67e74705SXin Li // expected-note@+1 {{expected in right hand side of expression}}
272*67e74705SXin Li a = float(a) + b;
273*67e74705SXin Li #pragma omp atomic
274*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
275*67e74705SXin Li // expected-note@+1 {{expected in right hand side of expression}}
276*67e74705SXin Li a = 2 * b;
277*67e74705SXin Li #pragma omp atomic
278*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
279*67e74705SXin Li // expected-note@+1 {{expected in right hand side of expression}}
280*67e74705SXin Li a = b + *&a;
281*67e74705SXin Li #pragma omp atomic update
282*67e74705SXin Li a++;
283*67e74705SXin Li #pragma omp atomic
284*67e74705SXin Li ++a;
285*67e74705SXin Li #pragma omp atomic update
286*67e74705SXin Li a--;
287*67e74705SXin Li #pragma omp atomic
288*67e74705SXin Li --a;
289*67e74705SXin Li #pragma omp atomic update
290*67e74705SXin Li a += b;
291*67e74705SXin Li #pragma omp atomic
292*67e74705SXin Li a %= b;
293*67e74705SXin Li #pragma omp atomic update
294*67e74705SXin Li a *= b;
295*67e74705SXin Li #pragma omp atomic
296*67e74705SXin Li a -= b;
297*67e74705SXin Li #pragma omp atomic update
298*67e74705SXin Li a /= b;
299*67e74705SXin Li #pragma omp atomic
300*67e74705SXin Li a &= b;
301*67e74705SXin Li #pragma omp atomic update
302*67e74705SXin Li a ^= b;
303*67e74705SXin Li #pragma omp atomic
304*67e74705SXin Li a |= b;
305*67e74705SXin Li #pragma omp atomic update
306*67e74705SXin Li a <<= b;
307*67e74705SXin Li #pragma omp atomic
308*67e74705SXin Li a >>= b;
309*67e74705SXin Li #pragma omp atomic update
310*67e74705SXin Li a = b + a;
311*67e74705SXin Li #pragma omp atomic
312*67e74705SXin Li a = a * b;
313*67e74705SXin Li #pragma omp atomic update
314*67e74705SXin Li a = b - a;
315*67e74705SXin Li #pragma omp atomic
316*67e74705SXin Li a = a / b;
317*67e74705SXin Li #pragma omp atomic update
318*67e74705SXin Li a = b & a;
319*67e74705SXin Li #pragma omp atomic
320*67e74705SXin Li a = a ^ b;
321*67e74705SXin Li #pragma omp atomic update
322*67e74705SXin Li a = b | a;
323*67e74705SXin Li #pragma omp atomic
324*67e74705SXin Li a = a << b;
325*67e74705SXin Li #pragma omp atomic
326*67e74705SXin Li a = b >> a;
327*67e74705SXin Li #pragma omp atomic
328*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
329*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
330*67e74705SXin Li ;
331*67e74705SXin Li
332*67e74705SXin Li return update<int>();
333*67e74705SXin Li }
334*67e74705SXin Li
335*67e74705SXin Li template <class T>
capture()336*67e74705SXin Li T capture() {
337*67e74705SXin Li T a = 0, b = 0, c = 0;
338*67e74705SXin Li // Test for atomic capture
339*67e74705SXin Li #pragma omp atomic capture
340*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}
341*67e74705SXin Li // expected-note@+1 {{expected compound statement}}
342*67e74705SXin Li ;
343*67e74705SXin Li #pragma omp atomic capture
344*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
345*67e74705SXin Li // expected-note@+1 {{expected assignment expression}}
346*67e74705SXin Li foo();
347*67e74705SXin Li #pragma omp atomic capture
348*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
349*67e74705SXin Li // expected-note@+1 {{expected built-in binary or unary operator}}
350*67e74705SXin Li a = b;
351*67e74705SXin Li #pragma omp atomic capture
352*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
353*67e74705SXin Li // expected-note@+1 {{expected assignment expression}}
354*67e74705SXin Li a = b || a;
355*67e74705SXin Li #pragma omp atomic capture
356*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
357*67e74705SXin Li // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}}
358*67e74705SXin Li b = a = a && b;
359*67e74705SXin Li #pragma omp atomic capture
360*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
361*67e74705SXin Li // expected-note@+1 {{expected assignment expression}}
362*67e74705SXin Li a = (float)a + b;
363*67e74705SXin Li #pragma omp atomic capture
364*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
365*67e74705SXin Li // expected-note@+1 {{expected assignment expression}}
366*67e74705SXin Li a = 2 * b;
367*67e74705SXin Li #pragma omp atomic capture
368*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
369*67e74705SXin Li // expected-note@+1 {{expected assignment expression}}
370*67e74705SXin Li a = b + *&a;
371*67e74705SXin Li #pragma omp atomic capture
372*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}
373*67e74705SXin Li // expected-note@+1 {{expected exactly two expression statements}}
374*67e74705SXin Li { a = b; }
375*67e74705SXin Li #pragma omp atomic capture
376*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}
377*67e74705SXin Li // expected-note@+1 {{expected exactly two expression statements}}
378*67e74705SXin Li {}
379*67e74705SXin Li #pragma omp atomic capture
380*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}
381*67e74705SXin Li // expected-note@+1 {{expected in right hand side of the first expression}}
382*67e74705SXin Li {a = b;a = b;}
383*67e74705SXin Li #pragma omp atomic capture
384*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}
385*67e74705SXin Li // expected-note@+1 {{expected in right hand side of the first expression}}
386*67e74705SXin Li {a = b; a = b || a;}
387*67e74705SXin Li #pragma omp atomic capture
388*67e74705SXin Li {b = a; a = a && b;}
389*67e74705SXin Li #pragma omp atomic capture
390*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
391*67e74705SXin Li // expected-note@+1 {{expected in right hand side of expression}}
392*67e74705SXin Li b = a = (float)a + b;
393*67e74705SXin Li #pragma omp atomic capture
394*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
395*67e74705SXin Li // expected-note@+1 {{expected in right hand side of expression}}
396*67e74705SXin Li b = a = 2 * b;
397*67e74705SXin Li #pragma omp atomic capture
398*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
399*67e74705SXin Li // expected-note@+1 {{expected in right hand side of expression}}
400*67e74705SXin Li b = a = b + *&a;
401*67e74705SXin Li #pragma omp atomic capture
402*67e74705SXin Li c = *&a = *&a + 2;
403*67e74705SXin Li #pragma omp atomic capture
404*67e74705SXin Li c = a++;
405*67e74705SXin Li #pragma omp atomic capture
406*67e74705SXin Li c = ++a;
407*67e74705SXin Li #pragma omp atomic capture
408*67e74705SXin Li c = a--;
409*67e74705SXin Li #pragma omp atomic capture
410*67e74705SXin Li c = --a;
411*67e74705SXin Li #pragma omp atomic capture
412*67e74705SXin Li c = a += b;
413*67e74705SXin Li #pragma omp atomic capture
414*67e74705SXin Li c = a %= b;
415*67e74705SXin Li #pragma omp atomic capture
416*67e74705SXin Li c = a *= b;
417*67e74705SXin Li #pragma omp atomic capture
418*67e74705SXin Li c = a -= b;
419*67e74705SXin Li #pragma omp atomic capture
420*67e74705SXin Li c = a /= b;
421*67e74705SXin Li #pragma omp atomic capture
422*67e74705SXin Li c = a &= b;
423*67e74705SXin Li #pragma omp atomic capture
424*67e74705SXin Li c = a ^= b;
425*67e74705SXin Li #pragma omp atomic capture
426*67e74705SXin Li c = a |= b;
427*67e74705SXin Li #pragma omp atomic capture
428*67e74705SXin Li c = a <<= b;
429*67e74705SXin Li #pragma omp atomic capture
430*67e74705SXin Li c = a >>= b;
431*67e74705SXin Li #pragma omp atomic capture
432*67e74705SXin Li c = a = b + a;
433*67e74705SXin Li #pragma omp atomic capture
434*67e74705SXin Li c = a = a * b;
435*67e74705SXin Li #pragma omp atomic capture
436*67e74705SXin Li c = a = b - a;
437*67e74705SXin Li #pragma omp atomic capture
438*67e74705SXin Li c = a = a / b;
439*67e74705SXin Li #pragma omp atomic capture
440*67e74705SXin Li c = a = b & a;
441*67e74705SXin Li #pragma omp atomic capture
442*67e74705SXin Li c = a = a ^ b;
443*67e74705SXin Li #pragma omp atomic capture
444*67e74705SXin Li c = a = b | a;
445*67e74705SXin Li #pragma omp atomic capture
446*67e74705SXin Li c = a = a << b;
447*67e74705SXin Li #pragma omp atomic capture
448*67e74705SXin Li c = a = b >> a;
449*67e74705SXin Li #pragma omp atomic capture
450*67e74705SXin Li { c = *&a; *&a = *&a + 2;}
451*67e74705SXin Li #pragma omp atomic capture
452*67e74705SXin Li { *&a = *&a + 2; c = *&a;}
453*67e74705SXin Li #pragma omp atomic capture
454*67e74705SXin Li {c = a; a++;}
455*67e74705SXin Li #pragma omp atomic capture
456*67e74705SXin Li {++a;c = a;}
457*67e74705SXin Li #pragma omp atomic capture
458*67e74705SXin Li {c = a;a--;}
459*67e74705SXin Li #pragma omp atomic capture
460*67e74705SXin Li {--a;c = a;}
461*67e74705SXin Li #pragma omp atomic capture
462*67e74705SXin Li {c = a; a += b;}
463*67e74705SXin Li #pragma omp atomic capture
464*67e74705SXin Li {a %= b; c = a;}
465*67e74705SXin Li #pragma omp atomic capture
466*67e74705SXin Li {c = a; a *= b;}
467*67e74705SXin Li #pragma omp atomic capture
468*67e74705SXin Li {a -= b;c = a;}
469*67e74705SXin Li #pragma omp atomic capture
470*67e74705SXin Li {c = a; a /= b;}
471*67e74705SXin Li #pragma omp atomic capture
472*67e74705SXin Li {a &= b; c = a;}
473*67e74705SXin Li #pragma omp atomic capture
474*67e74705SXin Li {c = a; a ^= b;}
475*67e74705SXin Li #pragma omp atomic capture
476*67e74705SXin Li {a |= b; c = a;}
477*67e74705SXin Li #pragma omp atomic capture
478*67e74705SXin Li {c = a; a <<= b;}
479*67e74705SXin Li #pragma omp atomic capture
480*67e74705SXin Li {a >>= b; c = a;}
481*67e74705SXin Li #pragma omp atomic capture
482*67e74705SXin Li {c = a; a = b + a;}
483*67e74705SXin Li #pragma omp atomic capture
484*67e74705SXin Li {a = a * b; c = a;}
485*67e74705SXin Li #pragma omp atomic capture
486*67e74705SXin Li {c = a; a = b - a;}
487*67e74705SXin Li #pragma omp atomic capture
488*67e74705SXin Li {a = a / b; c = a;}
489*67e74705SXin Li #pragma omp atomic capture
490*67e74705SXin Li {c = a; a = b & a;}
491*67e74705SXin Li #pragma omp atomic capture
492*67e74705SXin Li {a = a ^ b; c = a;}
493*67e74705SXin Li #pragma omp atomic capture
494*67e74705SXin Li {c = a; a = b | a;}
495*67e74705SXin Li #pragma omp atomic capture
496*67e74705SXin Li {a = a << b; c = a;}
497*67e74705SXin Li #pragma omp atomic capture
498*67e74705SXin Li {c = a; a = b >> a;}
499*67e74705SXin Li #pragma omp atomic capture
500*67e74705SXin Li {c = a; a = foo();}
501*67e74705SXin Li // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}}
502*67e74705SXin Li #pragma omp atomic capture capture
503*67e74705SXin Li b = a /= b;
504*67e74705SXin Li
505*67e74705SXin Li return T();
506*67e74705SXin Li }
507*67e74705SXin Li
capture()508*67e74705SXin Li int capture() {
509*67e74705SXin Li int a = 0, b = 0, c = 0;
510*67e74705SXin Li // Test for atomic capture
511*67e74705SXin Li #pragma omp atomic capture
512*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}
513*67e74705SXin Li // expected-note@+1 {{expected compound statement}}
514*67e74705SXin Li ;
515*67e74705SXin Li #pragma omp atomic capture
516*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
517*67e74705SXin Li // expected-note@+1 {{expected assignment expression}}
518*67e74705SXin Li foo();
519*67e74705SXin Li #pragma omp atomic capture
520*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
521*67e74705SXin Li // expected-note@+1 {{expected built-in binary or unary operator}}
522*67e74705SXin Li a = b;
523*67e74705SXin Li #pragma omp atomic capture
524*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
525*67e74705SXin Li // expected-note@+1 {{expected assignment expression}}
526*67e74705SXin Li a = b || a;
527*67e74705SXin Li #pragma omp atomic capture
528*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
529*67e74705SXin Li // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}}
530*67e74705SXin Li b = a = a && b;
531*67e74705SXin Li #pragma omp atomic capture
532*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
533*67e74705SXin Li // expected-note@+1 {{expected assignment expression}}
534*67e74705SXin Li a = (float)a + b;
535*67e74705SXin Li #pragma omp atomic capture
536*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
537*67e74705SXin Li // expected-note@+1 {{expected assignment expression}}
538*67e74705SXin Li a = 2 * b;
539*67e74705SXin Li #pragma omp atomic capture
540*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
541*67e74705SXin Li // expected-note@+1 {{expected assignment expression}}
542*67e74705SXin Li a = b + *&a;
543*67e74705SXin Li #pragma omp atomic capture
544*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}
545*67e74705SXin Li // expected-note@+1 {{expected exactly two expression statements}}
546*67e74705SXin Li { a = b; }
547*67e74705SXin Li #pragma omp atomic capture
548*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}
549*67e74705SXin Li // expected-note@+1 {{expected exactly two expression statements}}
550*67e74705SXin Li {}
551*67e74705SXin Li #pragma omp atomic capture
552*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}
553*67e74705SXin Li // expected-note@+1 {{expected in right hand side of the first expression}}
554*67e74705SXin Li {a = b;a = b;}
555*67e74705SXin Li #pragma omp atomic capture
556*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be a compound statement of form '{v = x; x binop= expr;}', '{x binop= expr; v = x;}', '{v = x; x = x binop expr;}', '{v = x; x = expr binop x;}', '{x = x binop expr; v = x;}', '{x = expr binop x; v = x;}' or '{v = x; x = expr;}', '{v = x; x++;}', '{v = x; ++x;}', '{++x; v = x;}', '{x++; v = x;}', '{v = x; x--;}', '{v = x; --x;}', '{--x; v = x;}', '{x--; v = x;}' where x is an l-value expression with scalar type}}
557*67e74705SXin Li // expected-note@+1 {{expected in right hand side of the first expression}}
558*67e74705SXin Li {a = b; a = b || a;}
559*67e74705SXin Li #pragma omp atomic capture
560*67e74705SXin Li {b = a; a = a && b;}
561*67e74705SXin Li #pragma omp atomic capture
562*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
563*67e74705SXin Li // expected-note@+1 {{expected in right hand side of expression}}
564*67e74705SXin Li b = a = (float)a + b;
565*67e74705SXin Li #pragma omp atomic capture
566*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
567*67e74705SXin Li // expected-note@+1 {{expected in right hand side of expression}}
568*67e74705SXin Li b = a = 2 * b;
569*67e74705SXin Li #pragma omp atomic capture
570*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic capture' must be an expression statement of form 'v = ++x;', 'v = --x;', 'v = x++;', 'v = x--;', 'v = x binop= expr;', 'v = x = x binop expr' or 'v = x = expr binop x', where x and v are both l-value expressions with scalar type}}
571*67e74705SXin Li // expected-note@+1 {{expected in right hand side of expression}}
572*67e74705SXin Li b = a = b + *&a;
573*67e74705SXin Li #pragma omp atomic capture
574*67e74705SXin Li c = *&a = *&a + 2;
575*67e74705SXin Li #pragma omp atomic capture
576*67e74705SXin Li c = a++;
577*67e74705SXin Li #pragma omp atomic capture
578*67e74705SXin Li c = ++a;
579*67e74705SXin Li #pragma omp atomic capture
580*67e74705SXin Li c = a--;
581*67e74705SXin Li #pragma omp atomic capture
582*67e74705SXin Li c = --a;
583*67e74705SXin Li #pragma omp atomic capture
584*67e74705SXin Li c = a += b;
585*67e74705SXin Li #pragma omp atomic capture
586*67e74705SXin Li c = a %= b;
587*67e74705SXin Li #pragma omp atomic capture
588*67e74705SXin Li c = a *= b;
589*67e74705SXin Li #pragma omp atomic capture
590*67e74705SXin Li c = a -= b;
591*67e74705SXin Li #pragma omp atomic capture
592*67e74705SXin Li c = a /= b;
593*67e74705SXin Li #pragma omp atomic capture
594*67e74705SXin Li c = a &= b;
595*67e74705SXin Li #pragma omp atomic capture
596*67e74705SXin Li c = a ^= b;
597*67e74705SXin Li #pragma omp atomic capture
598*67e74705SXin Li c = a |= b;
599*67e74705SXin Li #pragma omp atomic capture
600*67e74705SXin Li c = a <<= b;
601*67e74705SXin Li #pragma omp atomic capture
602*67e74705SXin Li c = a >>= b;
603*67e74705SXin Li #pragma omp atomic capture
604*67e74705SXin Li c = a = b + a;
605*67e74705SXin Li #pragma omp atomic capture
606*67e74705SXin Li c = a = a * b;
607*67e74705SXin Li #pragma omp atomic capture
608*67e74705SXin Li c = a = b - a;
609*67e74705SXin Li #pragma omp atomic capture
610*67e74705SXin Li c = a = a / b;
611*67e74705SXin Li #pragma omp atomic capture
612*67e74705SXin Li c = a = b & a;
613*67e74705SXin Li #pragma omp atomic capture
614*67e74705SXin Li c = a = a ^ b;
615*67e74705SXin Li #pragma omp atomic capture
616*67e74705SXin Li c = a = b | a;
617*67e74705SXin Li #pragma omp atomic capture
618*67e74705SXin Li c = a = a << b;
619*67e74705SXin Li #pragma omp atomic capture
620*67e74705SXin Li c = a = b >> a;
621*67e74705SXin Li #pragma omp atomic capture
622*67e74705SXin Li { c = *&a; *&a = *&a + 2;}
623*67e74705SXin Li #pragma omp atomic capture
624*67e74705SXin Li { *&a = *&a + 2; c = *&a;}
625*67e74705SXin Li #pragma omp atomic capture
626*67e74705SXin Li {c = a; a++;}
627*67e74705SXin Li #pragma omp atomic capture
628*67e74705SXin Li {++a;c = a;}
629*67e74705SXin Li #pragma omp atomic capture
630*67e74705SXin Li {c = a;a--;}
631*67e74705SXin Li #pragma omp atomic capture
632*67e74705SXin Li {--a;c = a;}
633*67e74705SXin Li #pragma omp atomic capture
634*67e74705SXin Li {c = a; a += b;}
635*67e74705SXin Li #pragma omp atomic capture
636*67e74705SXin Li {a %= b; c = a;}
637*67e74705SXin Li #pragma omp atomic capture
638*67e74705SXin Li {c = a; a *= b;}
639*67e74705SXin Li #pragma omp atomic capture
640*67e74705SXin Li {a -= b;c = a;}
641*67e74705SXin Li #pragma omp atomic capture
642*67e74705SXin Li {c = a; a /= b;}
643*67e74705SXin Li #pragma omp atomic capture
644*67e74705SXin Li {a &= b; c = a;}
645*67e74705SXin Li #pragma omp atomic capture
646*67e74705SXin Li {c = a; a ^= b;}
647*67e74705SXin Li #pragma omp atomic capture
648*67e74705SXin Li {a |= b; c = a;}
649*67e74705SXin Li #pragma omp atomic capture
650*67e74705SXin Li {c = a; a <<= b;}
651*67e74705SXin Li #pragma omp atomic capture
652*67e74705SXin Li {a >>= b; c = a;}
653*67e74705SXin Li #pragma omp atomic capture
654*67e74705SXin Li {c = a; a = b + a;}
655*67e74705SXin Li #pragma omp atomic capture
656*67e74705SXin Li {a = a * b; c = a;}
657*67e74705SXin Li #pragma omp atomic capture
658*67e74705SXin Li {c = a; a = b - a;}
659*67e74705SXin Li #pragma omp atomic capture
660*67e74705SXin Li {a = a / b; c = a;}
661*67e74705SXin Li #pragma omp atomic capture
662*67e74705SXin Li {c = a; a = b & a;}
663*67e74705SXin Li #pragma omp atomic capture
664*67e74705SXin Li {a = a ^ b; c = a;}
665*67e74705SXin Li #pragma omp atomic capture
666*67e74705SXin Li {c = a; a = b | a;}
667*67e74705SXin Li #pragma omp atomic capture
668*67e74705SXin Li {a = a << b; c = a;}
669*67e74705SXin Li #pragma omp atomic capture
670*67e74705SXin Li {c = a; a = b >> a;}
671*67e74705SXin Li #pragma omp atomic capture
672*67e74705SXin Li {c = a; a = foo();}
673*67e74705SXin Li // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}}
674*67e74705SXin Li #pragma omp atomic capture capture
675*67e74705SXin Li b = a /= b;
676*67e74705SXin Li
677*67e74705SXin Li // expected-note@+1 {{in instantiation of function template specialization 'capture<int>' requested here}}
678*67e74705SXin Li return capture<int>();
679*67e74705SXin Li }
680*67e74705SXin Li
681*67e74705SXin Li template <class T>
seq_cst()682*67e74705SXin Li T seq_cst() {
683*67e74705SXin Li T a, b = 0;
684*67e74705SXin Li // Test for atomic seq_cst
685*67e74705SXin Li #pragma omp atomic seq_cst
686*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
687*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
688*67e74705SXin Li ;
689*67e74705SXin Li // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst' clause}}
690*67e74705SXin Li #pragma omp atomic seq_cst seq_cst
691*67e74705SXin Li a += b;
692*67e74705SXin Li
693*67e74705SXin Li #pragma omp atomic update seq_cst
694*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
695*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
696*67e74705SXin Li ;
697*67e74705SXin Li
698*67e74705SXin Li return T();
699*67e74705SXin Li }
700*67e74705SXin Li
seq_cst()701*67e74705SXin Li int seq_cst() {
702*67e74705SXin Li int a, b = 0;
703*67e74705SXin Li // Test for atomic seq_cst
704*67e74705SXin Li #pragma omp atomic seq_cst
705*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
706*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
707*67e74705SXin Li ;
708*67e74705SXin Li // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst' clause}}
709*67e74705SXin Li #pragma omp atomic seq_cst seq_cst
710*67e74705SXin Li a += b;
711*67e74705SXin Li
712*67e74705SXin Li #pragma omp atomic update seq_cst
713*67e74705SXin Li // expected-error@+2 {{the statement for 'atomic update' must be an expression statement of form '++x;', '--x;', 'x++;', 'x--;', 'x binop= expr;', 'x = x binop expr' or 'x = expr binop x', where x is an l-value expression with scalar type}}
714*67e74705SXin Li // expected-note@+1 {{expected an expression statement}}
715*67e74705SXin Li ;
716*67e74705SXin Li
717*67e74705SXin Li return seq_cst<int>();
718*67e74705SXin Li }
719*67e74705SXin Li
720*67e74705SXin Li template <class T>
mixed()721*67e74705SXin Li T mixed() {
722*67e74705SXin Li T a, b = T();
723*67e74705SXin Li // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
724*67e74705SXin Li // expected-note@+1 2 {{'read' clause used here}}
725*67e74705SXin Li #pragma omp atomic read write
726*67e74705SXin Li a = b;
727*67e74705SXin Li // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
728*67e74705SXin Li // expected-note@+1 2 {{'write' clause used here}}
729*67e74705SXin Li #pragma omp atomic write read
730*67e74705SXin Li a = b;
731*67e74705SXin Li // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
732*67e74705SXin Li // expected-note@+1 2 {{'update' clause used here}}
733*67e74705SXin Li #pragma omp atomic update read
734*67e74705SXin Li a += b;
735*67e74705SXin Li // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
736*67e74705SXin Li // expected-note@+1 2 {{'capture' clause used here}}
737*67e74705SXin Li #pragma omp atomic capture read
738*67e74705SXin Li a = ++b;
739*67e74705SXin Li return T();
740*67e74705SXin Li }
741*67e74705SXin Li
mixed()742*67e74705SXin Li int mixed() {
743*67e74705SXin Li int a, b = 0;
744*67e74705SXin Li // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
745*67e74705SXin Li // expected-note@+1 {{'read' clause used here}}
746*67e74705SXin Li #pragma omp atomic read write
747*67e74705SXin Li a = b;
748*67e74705SXin Li // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
749*67e74705SXin Li // expected-note@+1 {{'write' clause used here}}
750*67e74705SXin Li #pragma omp atomic write read
751*67e74705SXin Li a = b;
752*67e74705SXin Li // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
753*67e74705SXin Li // expected-note@+1 {{'write' clause used here}}
754*67e74705SXin Li #pragma omp atomic write update
755*67e74705SXin Li a = b;
756*67e74705SXin Li // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
757*67e74705SXin Li // expected-note@+1 {{'write' clause used here}}
758*67e74705SXin Li #pragma omp atomic write capture
759*67e74705SXin Li a = b;
760*67e74705SXin Li // expected-note@+1 {{in instantiation of function template specialization 'mixed<int>' requested here}}
761*67e74705SXin Li return mixed<int>();
762*67e74705SXin Li }
763*67e74705SXin Li
764