xref: /llvm-project/clang/test/OpenMP/atomic_messages.cpp (revision a74e9ce5dc5cc746bd625b0ef20524a90a073375)
1 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 150 %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -ferror-limit 150 %s -Wuninitialized
3 // RUN: %clang_cc1 -DOMP51 -verify=expected,omp50,omp51 -fopenmp -ferror-limit 150 %s -Wuninitialized
4 
5 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 150 %s -Wuninitialized
6 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 150 %s -Wuninitialized
7 // RUN: %clang_cc1 -DOMP51 -verify=expected,omp50,omp51 -fopenmp-simd -ferror-limit 150 %s -Wuninitialized
8 
foo()9 int foo() {
10 L1:
11   foo();
12 #pragma omp atomic
13   // 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 lvalue expression with scalar type}}
14   // expected-note@+1 {{expected an expression statement}}
15   {
16     foo();
17     goto L1;
18   }
19   goto L2;
20 #pragma omp atomic
21   // 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 lvalue expression with scalar type}}
22   // expected-note@+1 {{expected an expression statement}}
23   {
24     foo();
25   L2:
26     foo();
27   }
28 
29   return 0;
30 }
31 
32 struct S {
33   int a;
operator =S34   S &operator=(int v) {
35     a = v;
36     return *this;
37   }
operator +=S38   S &operator+=(const S &s) {
39     a += s.a;
40     return *this;
41   }
42 };
43 
44 template <class T>
read()45 T read() {
46   T a = T(), b = T();
47 // Test for atomic read
48 #pragma omp atomic read
49   // 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}}
50   // expected-note@+1 {{expected an expression statement}}
51   ;
52 #pragma omp atomic read
53   // 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}}
54   // expected-note@+1 {{expected built-in assignment operator}}
55   foo();
56 #pragma omp atomic read
57   // 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}}
58   // expected-note@+1 2 {{expected built-in assignment operator}}
59   a += b;
60 #pragma omp atomic read
61   // 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}}
62   // expected-note@+1 {{expected lvalue expression}}
63   a = 0;
64 #pragma omp atomic read
65   // 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}}
66   // expected-note@+1 {{expected built-in assignment operator}}
67   a = b;
68   // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}}
69 #pragma omp atomic read read
70   // 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}}
71   // expected-note@+1 {{expected built-in assignment operator}}
72   a = b;
73 
74   return a;
75 }
76 
read()77 int read() {
78   int a = 0, b = 0;
79 // Test for atomic read
80 #pragma omp atomic read
81   // 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}}
82   // expected-note@+1 {{expected an expression statement}}
83   ;
84 #pragma omp atomic read
85   // 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}}
86   // expected-note@+1 {{expected built-in assignment operator}}
87   foo();
88 #pragma omp atomic read
89   // 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}}
90   // expected-note@+1 {{expected built-in assignment operator}}
91   a += b;
92 #pragma omp atomic read
93   // 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}}
94   // expected-note@+1 {{expected lvalue expression}}
95   a = 0;
96 #pragma omp atomic read
97   a = b;
98   // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}}
99 #pragma omp atomic read read
100   a = b;
101 
102   // expected-note@+2 {{in instantiation of function template specialization 'read<S>' requested here}}
103   // expected-note@+1 {{in instantiation of function template specialization 'read<int>' requested here}}
104   return read<int>() + read<S>().a;
105 }
106 
107 template <class T>
write()108 T write() {
109   T a, b = 0;
110 // Test for atomic write
111 #pragma omp atomic write
112   // 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}}
113   // expected-note@+1 {{expected an expression statement}}
114   ;
115 // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}}
116 #pragma omp atomic write write
117   a = b;
118 #pragma omp atomic write
119   // 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}}
120   // expected-note@+1 {{expected built-in assignment operator}}
121   foo();
122 #pragma omp atomic write
123   // 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}}
124   // expected-note@+1 {{expected built-in assignment operator}}
125   a += b;
126 #pragma omp atomic write
127   a = 0;
128 #pragma omp atomic write
129   a = b;
130 
131   return T();
132 }
133 
write()134 int write() {
135   int a, b = 0;
136 // Test for atomic write
137 #pragma omp atomic write
138   // 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}}
139   // expected-note@+1 {{expected an expression statement}}
140   ;
141 // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}}
142 #pragma omp atomic write write
143   a = b;
144 #pragma omp atomic write
145   // 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}}
146   // expected-note@+1 {{expected built-in assignment operator}}
147   foo();
148 #pragma omp atomic write
149   // 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}}
150   // expected-note@+1 {{expected built-in assignment operator}}
151   a += b;
152 #pragma omp atomic write
153   a = 0;
154 #pragma omp atomic write
155   a = foo();
156 
157   // expected-note@+1 {{in instantiation of function template specialization 'write<int>' requested here}}
158   return write<int>();
159 }
160 
161 template <class T>
update()162 T update() {
163   T a = 0, b = 0, c = 0;
164 // Test for atomic update
165 #pragma omp atomic update
166   // 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 lvalue expression with scalar type}}
167   // expected-note@+1 {{expected an expression statement}}
168   ;
169 // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}}
170 #pragma omp atomic update update
171   a += b;
172 #pragma omp atomic
173   // 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 lvalue expression with scalar type}}
174   // expected-note@+1 {{expected built-in binary operator}}
175   a = b;
176 #pragma omp atomic update
177   // 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 lvalue expression with scalar type}}
178   // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}}
179   a = b || a;
180 #pragma omp atomic update
181   // 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 lvalue expression with scalar type}}
182   // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}}
183   a = a && b;
184 #pragma omp atomic update
185   // 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 lvalue expression with scalar type}}
186   // expected-note@+1 {{expected in right hand side of expression}}
187   a = float(a) + b;
188 #pragma omp atomic
189   // 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 lvalue expression with scalar type}}
190   // expected-note@+1 {{expected in right hand side of expression}}
191   a = 2 * b;
192 #pragma omp atomic
193   // 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 lvalue expression with scalar type}}
194   // expected-note@+1 {{expected in right hand side of expression}}
195   a = b + *&a;
196 #pragma omp atomic
197   *&a = b * *&a;
198 #pragma omp atomic update
199   a++;
200 #pragma omp atomic
201   ++a;
202 #pragma omp atomic update
203   a--;
204 #pragma omp atomic
205   --a;
206 #pragma omp atomic update
207   a += b;
208 #pragma omp atomic
209   a %= b;
210 #pragma omp atomic update
211   a *= b;
212 #pragma omp atomic
213   a -= b;
214 #pragma omp atomic update
215   a /= b;
216 #pragma omp atomic
217   a &= b;
218 #pragma omp atomic update
219   a ^= b;
220 #pragma omp atomic
221   a |= b;
222 #pragma omp atomic update
223   a <<= b;
224 #pragma omp atomic
225   a >>= b;
226 #pragma omp atomic update
227   a = b + a;
228 #pragma omp atomic
229   a = a * b;
230 #pragma omp atomic update
231   a = b - a;
232 #pragma omp atomic
233   a = a / b;
234 #pragma omp atomic update
235   a = b & a;
236 #pragma omp atomic
237   a = a ^ b;
238 #pragma omp atomic update
239   a = b | a;
240 #pragma omp atomic
241   a = a << b;
242 #pragma omp atomic
243   a = b >> a;
244 
245 #pragma omp atomic
246   // 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 lvalue expression with scalar type}}
247   // expected-note@+1 {{expected an expression statement}}
248   ;
249 
250   return T();
251 }
252 
update()253 int update() {
254   int a, b = 0;
255 // Test for atomic update
256 #pragma omp atomic update
257   // 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 lvalue expression with scalar type}}
258   // expected-note@+1 {{expected an expression statement}}
259   ;
260 // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}}
261 #pragma omp atomic update update
262   a += b;
263 #pragma omp atomic
264   // 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 lvalue expression with scalar type}}
265   // expected-note@+1 {{expected built-in binary operator}}
266   a = b;
267 #pragma omp atomic update
268   // 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 lvalue expression with scalar type}}
269   // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}}
270   a = b || a;
271 #pragma omp atomic update
272   // 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 lvalue expression with scalar type}}
273   // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}}
274   a = a && b;
275 #pragma omp atomic update
276   // 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 lvalue expression with scalar type}}
277   // expected-note@+1 {{expected in right hand side of expression}}
278   a = float(a) + b;
279 #pragma omp atomic
280   // 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 lvalue expression with scalar type}}
281   // expected-note@+1 {{expected in right hand side of expression}}
282   a = 2 * b;
283 #pragma omp atomic
284   // 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 lvalue expression with scalar type}}
285   // expected-note@+1 {{expected in right hand side of expression}}
286   a = b + *&a;
287 #pragma omp atomic update
288   a++;
289 #pragma omp atomic
290   ++a;
291 #pragma omp atomic update
292   a--;
293 #pragma omp atomic
294   --a;
295 #pragma omp atomic update
296   a += b;
297 #pragma omp atomic
298   a %= b;
299 #pragma omp atomic update
300   a *= b;
301 #pragma omp atomic
302   a -= b;
303 #pragma omp atomic update
304   a /= b;
305 #pragma omp atomic
306   a &= b;
307 #pragma omp atomic update
308   a ^= b;
309 #pragma omp atomic
310   a |= b;
311 #pragma omp atomic update
312   a <<= b;
313 #pragma omp atomic
314   a >>= b;
315 #pragma omp atomic update
316   a = b + a;
317 #pragma omp atomic
318   a = a * b;
319 #pragma omp atomic update
320   a = b - a;
321 #pragma omp atomic
322   a = a / b;
323 #pragma omp atomic update
324   a = b & a;
325 #pragma omp atomic
326   a = a ^ b;
327 #pragma omp atomic update
328   a = b | a;
329 #pragma omp atomic
330   a = a << b;
331 #pragma omp atomic
332   a = b >> a;
333 #pragma omp atomic
334   // 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 lvalue expression with scalar type}}
335   // expected-note@+1 {{expected an expression statement}}
336   ;
337 
338   return update<int>();
339 }
340 
341 template <class T>
capture()342 T capture() {
343   T a = 0, b = 0, c = 0;
344 // Test for atomic capture
345 #pragma omp atomic capture
346   // 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 lvalue expression with scalar type}}
347   // expected-note@+1 {{expected compound statement}}
348   ;
349 #pragma omp atomic capture
350   // 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 lvalue expressions with scalar type}}
351   // expected-note@+1 {{expected assignment expression}}
352   foo();
353 #pragma omp atomic capture
354   // 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 lvalue expressions with scalar type}}
355   // expected-note@+1 {{expected built-in binary or unary operator}}
356   a = b;
357 #pragma omp atomic capture
358   // 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 lvalue expressions with scalar type}}
359   // expected-note@+1 {{expected assignment expression}}
360   a = b || a;
361 #pragma omp atomic capture
362   // 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 lvalue expressions with scalar type}}
363   // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}}
364   b = a = a && b;
365 #pragma omp atomic capture
366   // 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 lvalue expressions with scalar type}}
367   // expected-note@+1 {{expected assignment expression}}
368   a = (float)a + b;
369 #pragma omp atomic capture
370   // 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 lvalue expressions with scalar type}}
371   // expected-note@+1 {{expected assignment expression}}
372   a = 2 * b;
373 #pragma omp atomic capture
374   // 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 lvalue expressions with scalar type}}
375   // expected-note@+1 {{expected assignment expression}}
376   a = b + *&a;
377 #pragma omp atomic capture
378   // 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 lvalue expression with scalar type}}
379   // expected-note@+1 {{expected exactly two expression statements}}
380   { a = b; }
381 #pragma omp atomic capture
382   // 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 lvalue expression with scalar type}}
383   // expected-note@+1 {{expected exactly two expression statements}}
384   {}
385 #pragma omp atomic capture
386   // 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 lvalue expression with scalar type}}
387   // expected-note@+1 {{expected in right hand side of the first expression}}
388   {a = b;a = b;}
389 #pragma omp atomic capture
390   // 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 lvalue expression with scalar type}}
391   // expected-note@+1 {{expected in right hand side of the first expression}}
392   {a = b; a = b || a;}
393 #pragma omp atomic capture
394   {b = a; a = a && b;}
395 #pragma omp atomic capture
396   // 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 lvalue expressions with scalar type}}
397   // expected-note@+1 {{expected in right hand side of expression}}
398   b = a = (float)a + b;
399 #pragma omp atomic capture
400   // 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 lvalue expressions with scalar type}}
401   // expected-note@+1 {{expected in right hand side of expression}}
402   b = a = 2 * b;
403 #pragma omp atomic capture
404   // 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 lvalue expressions with scalar type}}
405   // expected-note@+1 {{expected in right hand side of expression}}
406   b = a = b + *&a;
407 #pragma omp atomic capture
408   c = *&a = *&a +  2;
409 #pragma omp atomic capture
410   c = a++;
411 #pragma omp atomic capture
412   c = ++a;
413 #pragma omp atomic capture
414   c = a--;
415 #pragma omp atomic capture
416   c = --a;
417 #pragma omp atomic capture
418   c = a += b;
419 #pragma omp atomic capture
420   c = a %= b;
421 #pragma omp atomic capture
422   c = a *= b;
423 #pragma omp atomic capture
424   c = a -= b;
425 #pragma omp atomic capture
426   c = a /= b;
427 #pragma omp atomic capture
428   c = a &= b;
429 #pragma omp atomic capture
430   c = a ^= b;
431 #pragma omp atomic capture
432   c = a |= b;
433 #pragma omp atomic capture
434   c = a <<= b;
435 #pragma omp atomic capture
436   c = a >>= b;
437 #pragma omp atomic capture
438   c = a = b + a;
439 #pragma omp atomic capture
440   c = a = a * b;
441 #pragma omp atomic capture
442   c = a = b - a;
443 #pragma omp atomic capture
444   c = a = a / b;
445 #pragma omp atomic capture
446   c = a = b & a;
447 #pragma omp atomic capture
448   c = a = a ^ b;
449 #pragma omp atomic capture
450   c = a = b | a;
451 #pragma omp atomic capture
452   c = a = a << b;
453 #pragma omp atomic capture
454   c = a = b >> a;
455 #pragma omp atomic capture
456   { c = *&a; *&a = *&a +  2;}
457 #pragma omp atomic capture
458   { *&a = *&a +  2; c = *&a;}
459 #pragma omp atomic capture
460   {c = a; a++;}
461 #pragma omp atomic capture
462   {c = a; (a)++;}
463 #pragma omp atomic capture
464   {++a;c = a;}
465 #pragma omp atomic capture
466   {c = a;a--;}
467 #pragma omp atomic capture
468   {--a;c = a;}
469 #pragma omp atomic capture
470   {c = a; a += b;}
471 #pragma omp atomic capture
472   {c = a; (a) += b;}
473 #pragma omp atomic capture
474   {a %= b; c = a;}
475 #pragma omp atomic capture
476   {c = a; a *= b;}
477 #pragma omp atomic capture
478   {a -= b;c = a;}
479 #pragma omp atomic capture
480   {c = a; a /= b;}
481 #pragma omp atomic capture
482   {a &= b; c = a;}
483 #pragma omp atomic capture
484   {c = a; a ^= b;}
485 #pragma omp atomic capture
486   {a |= b; c = a;}
487 #pragma omp atomic capture
488   {c = a; a <<= b;}
489 #pragma omp atomic capture
490   {a >>= b; c = a;}
491 #pragma omp atomic capture
492   {c = a; a = b + a;}
493 #pragma omp atomic capture
494   {a = a * b; c = a;}
495 #pragma omp atomic capture
496   {c = a; a = b - a;}
497 #pragma omp atomic capture
498   {a = a / b; c = a;}
499 #pragma omp atomic capture
500   {c = a; a = b & a;}
501 #pragma omp atomic capture
502   {a = a ^ b; c = a;}
503 #pragma omp atomic capture
504   {c = a; a = b | a;}
505 #pragma omp atomic capture
506   {a = a << b; c = a;}
507 #pragma omp atomic capture
508   {c = a; a = b >> a;}
509 #pragma omp atomic capture
510   {c = a; a = foo();}
511   // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}}
512 #pragma omp atomic capture capture
513   b = a /= b;
514 
515   return T();
516 }
517 
capture()518 int capture() {
519   int a = 0, b = 0, c = 0;
520 // Test for atomic capture
521 #pragma omp atomic capture
522   // 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 lvalue expression with scalar type}}
523   // expected-note@+1 {{expected compound statement}}
524   ;
525 #pragma omp atomic capture
526   // 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 lvalue expressions with scalar type}}
527   // expected-note@+1 {{expected assignment expression}}
528   foo();
529 #pragma omp atomic capture
530   // 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 lvalue expressions with scalar type}}
531   // expected-note@+1 {{expected built-in binary or unary operator}}
532   a = b;
533 #pragma omp atomic capture
534   // 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 lvalue expressions with scalar type}}
535   // expected-note@+1 {{expected assignment expression}}
536   a = b || a;
537 #pragma omp atomic capture
538   // 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 lvalue expressions with scalar type}}
539   // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}}
540   b = a = a && b;
541 #pragma omp atomic capture
542   // 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 lvalue expressions with scalar type}}
543   // expected-note@+1 {{expected assignment expression}}
544   a = (float)a + b;
545 #pragma omp atomic capture
546   // 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 lvalue expressions with scalar type}}
547   // expected-note@+1 {{expected assignment expression}}
548   a = 2 * b;
549 #pragma omp atomic capture
550   // 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 lvalue expressions with scalar type}}
551   // expected-note@+1 {{expected assignment expression}}
552   a = b + *&a;
553 #pragma omp atomic capture
554   // 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 lvalue expression with scalar type}}
555   // expected-note@+1 {{expected exactly two expression statements}}
556   { a = b; }
557 #pragma omp atomic capture
558   // 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 lvalue expression with scalar type}}
559   // expected-note@+1 {{expected exactly two expression statements}}
560   {}
561 #pragma omp atomic capture
562   // 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 lvalue expression with scalar type}}
563   // expected-note@+1 {{expected in right hand side of the first expression}}
564   {a = b;a = b;}
565 #pragma omp atomic capture
566   // 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 lvalue expression with scalar type}}
567   // expected-note@+1 {{expected in right hand side of the first expression}}
568   {a = b; a = b || a;}
569 #pragma omp atomic capture
570   {b = a; a = a && b;}
571 #pragma omp atomic capture
572   // 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 lvalue expressions with scalar type}}
573   // expected-note@+1 {{expected in right hand side of expression}}
574   b = a = (float)a + b;
575 #pragma omp atomic capture
576   // 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 lvalue expressions with scalar type}}
577   // expected-note@+1 {{expected in right hand side of expression}}
578   b = a = 2 * b;
579 #pragma omp atomic capture
580   // 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 lvalue expressions with scalar type}}
581   // expected-note@+1 {{expected in right hand side of expression}}
582   b = a = b + *&a;
583 #pragma omp atomic capture
584   c = *&a = *&a +  2;
585 #pragma omp atomic capture
586   c = a++;
587 #pragma omp atomic capture
588   c = ++a;
589 #pragma omp atomic capture
590   c = a--;
591 #pragma omp atomic capture
592   c = --a;
593 #pragma omp atomic capture
594   c = a += b;
595 #pragma omp atomic capture
596   c = a %= b;
597 #pragma omp atomic capture
598   c = a *= b;
599 #pragma omp atomic capture
600   c = a -= b;
601 #pragma omp atomic capture
602   c = a /= b;
603 #pragma omp atomic capture
604   c = a &= b;
605 #pragma omp atomic capture
606   c = a ^= b;
607 #pragma omp atomic capture
608   c = a |= b;
609 #pragma omp atomic capture
610   c = a <<= b;
611 #pragma omp atomic capture
612   c = a >>= b;
613 #pragma omp atomic capture
614   c = a = b + a;
615 #pragma omp atomic capture
616   c = a = a * b;
617 #pragma omp atomic capture
618   c = a = b - a;
619 #pragma omp atomic capture
620   c = a = a / b;
621 #pragma omp atomic capture
622   c = a = b & a;
623 #pragma omp atomic capture
624   c = a = a ^ b;
625 #pragma omp atomic capture
626   c = a = b | a;
627 #pragma omp atomic capture
628   c = a = a << b;
629 #pragma omp atomic capture
630   c = a = b >> a;
631 #pragma omp atomic capture
632   { c = *&a; *&a = *&a +  2;}
633 #pragma omp atomic capture
634   { *&a = *&a +  2; c = *&a;}
635 #pragma omp atomic capture
636   {c = a; a++;}
637 #pragma omp atomic capture
638   {++a;c = a;}
639 #pragma omp atomic capture
640   {c = a;a--;}
641 #pragma omp atomic capture
642   {--a;c = a;}
643 #pragma omp atomic capture
644   {c = a; a += b;}
645 #pragma omp atomic capture
646   {a %= b; c = a;}
647 #pragma omp atomic capture
648   {c = a; a *= b;}
649 #pragma omp atomic capture
650   {a -= b;c = a;}
651 #pragma omp atomic capture
652   {c = a; a /= b;}
653 #pragma omp atomic capture
654   {a &= b; c = a;}
655 #pragma omp atomic capture
656   {c = a; a ^= b;}
657 #pragma omp atomic capture
658   {a |= b; c = a;}
659 #pragma omp atomic capture
660   {c = a; a <<= b;}
661 #pragma omp atomic capture
662   {a >>= b; c = a;}
663 #pragma omp atomic capture
664   {c = a; a = b + a;}
665 #pragma omp atomic capture
666   {a = a * b; c = a;}
667 #pragma omp atomic capture
668   {c = a; a = b - a;}
669 #pragma omp atomic capture
670   {a = a / b; c = a;}
671 #pragma omp atomic capture
672   {c = a; a = b & a;}
673 #pragma omp atomic capture
674   {a = a ^ b; c = a;}
675 #pragma omp atomic capture
676   {c = a; a = b | a;}
677 #pragma omp atomic capture
678   {a = a << b; c = a;}
679 #pragma omp atomic capture
680   {c = a; a = b >> a;}
681 #pragma omp atomic capture
682   {c = a; a = foo();}
683   // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}}
684 #pragma omp atomic capture capture
685   b = a /= b;
686 
687   // expected-note@+1 {{in instantiation of function template specialization 'capture<int>' requested here}}
688   return capture<int>();
689 }
690 
691 template <class T>
seq_cst()692 T seq_cst() {
693   T a, b = 0;
694 // Test for atomic seq_cst
695 #pragma omp atomic seq_cst
696   // 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 lvalue expression with scalar type}}
697   // expected-note@+1 {{expected an expression statement}}
698   ;
699 // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst' clause}}
700 #pragma omp atomic seq_cst seq_cst
701   a += b;
702 
703 #pragma omp atomic update seq_cst
704   // 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 lvalue expression with scalar type}}
705   // expected-note@+1 {{expected an expression statement}}
706   ;
707 
708   return T();
709 }
710 
seq_cst()711 int seq_cst() {
712   int a, b = 0;
713 // Test for atomic seq_cst
714 #pragma omp atomic seq_cst
715   // 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 lvalue expression with scalar type}}
716   // expected-note@+1 {{expected an expression statement}}
717   ;
718 // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst' clause}}
719 #pragma omp atomic seq_cst seq_cst
720   a += b;
721 
722 #pragma omp atomic update seq_cst
723   // 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 lvalue expression with scalar type}}
724   // expected-note@+1 {{expected an expression statement}}
725   ;
726 
727  return seq_cst<int>();
728 }
729 
730 template <class T>
acq_rel()731 T acq_rel() {
732   T a = 0, b = 0;
733 // omp45-error@+1 {{unexpected OpenMP clause 'acq_rel' in directive '#pragma omp atomic'}} omp50-error@+1 {{directive '#pragma omp atomic' cannot be used with 'acq_rel' clause}} omp50-note@+1 {{'acq_rel' clause used here}}
734 #pragma omp atomic acq_rel
735   // 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 lvalue expression with scalar type}}
736   // expected-note@+1 {{expected an expression statement}}
737   ;
738 // omp50-error@+1 2 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst', 'relaxed', 'acq_rel', 'acquire' or 'release' clause}} omp50-note@+1 2 {{'acq_rel' clause used here}} omp45-error@+1 {{unexpected OpenMP clause 'acq_rel' in directive '#pragma omp atomic'}} omp50-error@+1 2 {{directive '#pragma omp atomic read' cannot be used with 'acq_rel' clause}} omp50-note@+1 2 {{'acq_rel' clause used here}}
739 #pragma omp atomic read acq_rel seq_cst
740   a = b;
741 
742 // omp45-error@+1 {{unexpected OpenMP clause 'acq_rel' in directive '#pragma omp atomic'}} omp50-error@+1 {{directive '#pragma omp atomic update' cannot be used with 'acq_rel' clause}} omp50-note@+1 {{'acq_rel' clause used here}}
743 #pragma omp atomic update acq_rel
744   // 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 lvalue expression with scalar type}}
745   // expected-note@+1 {{expected an expression statement}}
746   ;
747 
748   return T();
749 }
750 
acq_rel()751 int acq_rel() {
752   int a = 0, b = 0;
753 // Test for atomic acq_rel
754 // omp45-error@+1 {{unexpected OpenMP clause 'acq_rel' in directive '#pragma omp atomic'}} omp50-error@+1 {{directive '#pragma omp atomic write' cannot be used with 'acq_rel' clause}} omp50-note@+1 {{'acq_rel' clause used here}}
755 #pragma omp atomic acq_rel write
756   // 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}}
757   // expected-note@+1 {{expected an expression statement}}
758   ;
759 // omp50-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst', 'relaxed', 'acq_rel', 'acquire' or 'release' clause}} omp50-note@+1 {{'seq_cst' clause used here}} omp45-error@+1 {{unexpected OpenMP clause 'acq_rel' in directive '#pragma omp atomic'}}
760 #pragma omp atomic seq_cst acq_rel
761   a += b;
762 
763 // omp45-error@+1 {{unexpected OpenMP clause 'acq_rel' in directive '#pragma omp atomic'}} omp50-error@+1 {{directive '#pragma omp atomic update' cannot be used with 'acq_rel' clause}} omp50-note@+1 {{'acq_rel' clause used here}}
764 #pragma omp atomic update acq_rel
765   // 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 lvalue expression with scalar type}}
766   // expected-note@+1 {{expected an expression statement}}
767   ;
768 
769  return acq_rel<int>(); // omp50-note {{in instantiation of function template specialization 'acq_rel<int>' requested here}}
770 }
771 
772 template <class T>
acquire()773 T acquire() {
774   T a = 0, b = 0;
775 // omp45-error@+1 {{unexpected OpenMP clause 'acquire' in directive '#pragma omp atomic'}} omp50-error@+1 {{directive '#pragma omp atomic' cannot be used with 'acquire' clause}} omp50-note@+1 {{'acquire' clause used here}}
776 #pragma omp atomic acquire
777   // 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 lvalue expression with scalar type}}
778   // expected-note@+1 {{expected an expression statement}}
779   ;
780 // omp50-error@+1 2 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst', 'relaxed', 'acq_rel', 'acquire' or 'release' clause}} omp50-note@+1 2 {{'acquire' clause used here}} omp45-error@+1 {{unexpected OpenMP clause 'acquire' in directive '#pragma omp atomic'}} omp50-error@+1 2 {{directive '#pragma omp atomic' cannot be used with 'acquire' clause}} omp50-note@+1 2 {{'acquire' clause used here}}
781 #pragma omp atomic acquire seq_cst
782   a += b;
783 
784 // omp45-error@+1 {{unexpected OpenMP clause 'acquire' in directive '#pragma omp atomic'}} omp50-error@+1 {{directive '#pragma omp atomic update' cannot be used with 'acquire' clause}} omp50-note@+1 {{'acquire' clause used here}}
785 #pragma omp atomic update acquire
786   // 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 lvalue expression with scalar type}}
787   // expected-note@+1 {{expected an expression statement}}
788   ;
789 
790   return T();
791 }
792 
acquire()793 int acquire() {
794   int a = 0, b = 0;
795 // Test for atomic acquire
796 // omp45-error@+1 {{unexpected OpenMP clause 'acquire' in directive '#pragma omp atomic'}} omp50-error@+1 {{directive '#pragma omp atomic write' cannot be used with 'acquire' clause}} omp50-note@+1 {{'acquire' clause used here}}
797 #pragma omp atomic write acquire
798   // 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}}
799   // expected-note@+1 {{expected an expression statement}}
800   ;
801 // omp50-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst', 'relaxed', 'acq_rel', 'acquire' or 'release' clause}} omp50-note@+1 {{'seq_cst' clause used here}} omp45-error@+1 {{unexpected OpenMP clause 'acquire' in directive '#pragma omp atomic'}}
802 #pragma omp atomic seq_cst acquire
803   a += b;
804 
805 // omp45-error@+1 {{unexpected OpenMP clause 'acquire' in directive '#pragma omp atomic'}} omp50-error@+1 {{directive '#pragma omp atomic update' cannot be used with 'acquire' clause}} omp50-note@+1 {{'acquire' clause used here}}
806 #pragma omp atomic update acquire
807   // 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 lvalue expression with scalar type}}
808   // expected-note@+1 {{expected an expression statement}}
809   ;
810 
811  return acquire<int>(); // omp50-note {{in instantiation of function template specialization 'acquire<int>' requested here}}
812 }
813 
814 template <class T>
release()815 T release() {
816   T a = 0, b = 0;
817 // omp45-error@+1 {{unexpected OpenMP clause 'release' in directive '#pragma omp atomic'}}
818 #pragma omp atomic release
819   // 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 lvalue expression with scalar type}}
820   // expected-note@+1 {{expected an expression statement}}
821   ;
822 // omp50-error@+1 2 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst', 'relaxed', 'acq_rel', 'acquire' or 'release' clause}} omp50-note@+1 2 {{'release' clause used here}} omp45-error@+1 {{unexpected OpenMP clause 'release' in directive '#pragma omp atomic'}}
823 #pragma omp atomic release seq_cst
824   a += b;
825 
826 // omp45-error@+1 {{unexpected OpenMP clause 'release' in directive '#pragma omp atomic'}}
827 #pragma omp atomic update release
828   // 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 lvalue expression with scalar type}}
829   // expected-note@+1 {{expected an expression statement}}
830   ;
831 
832   return T();
833 }
834 
release()835 int release() {
836   int a = 0, b = 0;
837 // Test for atomic release
838 // omp45-error@+1 {{unexpected OpenMP clause 'release' in directive '#pragma omp atomic'}} omp50-error@+1 {{directive '#pragma omp atomic read' cannot be used with 'release' clause}} omp50-note@+1 {{'release' clause used here}}
839 #pragma omp atomic read release
840   // 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}}
841   // expected-note@+1 {{expected an expression statement}}
842   ;
843 // omp50-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst', 'relaxed', 'acq_rel', 'acquire' or 'release' clause}} omp50-note@+1 {{'seq_cst' clause used here}} omp45-error@+1 {{unexpected OpenMP clause 'release' in directive '#pragma omp atomic'}}
844 #pragma omp atomic seq_cst release
845   a += b;
846 
847 // omp45-error@+1 {{unexpected OpenMP clause 'release' in directive '#pragma omp atomic'}}
848 #pragma omp atomic update release
849   // 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 lvalue expression with scalar type}}
850   // expected-note@+1 {{expected an expression statement}}
851   ;
852 
853  return release<int>(); // omp50-note {{in instantiation of function template specialization 'release<int>' requested here}}
854 }
855 
856 template <class T>
relaxed()857 T relaxed() {
858   T a = 0, b = 0;
859 // omp45-error@+1 {{unexpected OpenMP clause 'relaxed' in directive '#pragma omp atomic'}}
860 #pragma omp atomic relaxed
861   // 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 lvalue expression with scalar type}}
862   // expected-note@+1 {{expected an expression statement}}
863   ;
864 // omp50-error@+1 2 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst', 'relaxed', 'acq_rel', 'acquire' or 'release' clause}} omp50-note@+1 2 {{'relaxed' clause used here}} omp45-error@+1 {{unexpected OpenMP clause 'relaxed' in directive '#pragma omp atomic'}}
865 #pragma omp atomic relaxed seq_cst
866   a += b;
867 
868 // omp45-error@+1 {{unexpected OpenMP clause 'relaxed' in directive '#pragma omp atomic'}}
869 #pragma omp atomic update relaxed
870   // 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 lvalue expression with scalar type}}
871   // expected-note@+1 {{expected an expression statement}}
872   ;
873 
874   return T();
875 }
876 
relaxed()877 int relaxed() {
878   int a = 0, b = 0;
879 // Test for atomic relaxed
880 // omp45-error@+1 {{unexpected OpenMP clause 'relaxed' in directive '#pragma omp atomic'}}
881 #pragma omp atomic read relaxed
882   // 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}}
883   // expected-note@+1 {{expected an expression statement}}
884   ;
885 // omp50-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst', 'relaxed', 'acq_rel', 'acquire' or 'release' clause}} omp50-note@+1 {{'seq_cst' clause used here}} omp45-error@+1 {{unexpected OpenMP clause 'relaxed' in directive '#pragma omp atomic'}}
886 #pragma omp atomic seq_cst relaxed
887   a += b;
888 
889 // omp45-error@+1 {{unexpected OpenMP clause 'relaxed' in directive '#pragma omp atomic'}}
890 #pragma omp atomic update relaxed
891   // 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 lvalue expression with scalar type}}
892   // expected-note@+1 {{expected an expression statement}}
893   ;
894 
895  return relaxed<int>(); // omp50-note {{in instantiation of function template specialization 'relaxed<int>' requested here}}
896 }
897 
898 template <class T>
mixed()899 T mixed() {
900   T a, b = T();
901 // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
902 // expected-note@+1 2 {{'read' clause used here}}
903 #pragma omp atomic read write
904   a = b;
905 // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
906 // expected-note@+1 2 {{'write' clause used here}}
907 #pragma omp atomic write read
908   a = b;
909 // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
910 // expected-note@+1 2 {{'update' clause used here}}
911 #pragma omp atomic update read
912   a += b;
913 // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
914 // expected-note@+1 2 {{'capture' clause used here}}
915 #pragma omp atomic capture read
916   a = ++b;
917 #ifdef OMP51
918 // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
919 // expected-note@+1 2 {{'write' clause used here}}
920 #pragma omp atomic write compare
921   a = b;
922 // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
923 // expected-note@+1 2 {{'read' clause used here}}
924 #pragma omp atomic read compare
925   a = b;
926 #endif
927   return T();
928 }
929 
mixed()930 int mixed() {
931   int a, v, b = 0;
932 // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
933 // expected-note@+1 {{'read' clause used here}}
934 #pragma omp atomic read write
935   a = b;
936 // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
937 // expected-note@+1 {{'write' clause used here}}
938 #pragma omp atomic write read
939   a = b;
940 // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
941 // expected-note@+1 {{'write' clause used here}}
942 #pragma omp atomic write update
943   a = b;
944 // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
945 // expected-note@+1 {{'write' clause used here}}
946 #pragma omp atomic write capture
947   a = b;
948 #ifdef OMP51
949 // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
950 // expected-note@+1 {{'write' clause used here}}
951 #pragma omp atomic write compare
952   a = b;
953 // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
954 // expected-note@+1 {{'read' clause used here}}
955 #pragma omp atomic read compare
956   a = b;
957 // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'compare' clause}}
958 // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}}
959 #pragma omp atomic compare compare capture capture
960   { v = a; if (a > b) a = b; }
961 // expected-error@+1 {{expected 'compare' clause with the 'fail' modifier}}
962 #pragma omp atomic fail(seq_cst)
963   if(v == a) { v = a; }
964 // expected-error@+1 {{expected '(' after 'fail'}}
965 #pragma omp atomic compare fail
966   if(v < a) { v = a; }
967 // expected-error@+1 {{expected a memory order clause}}
968 #pragma omp atomic compare fail(capture)
969   if(v < a) { v = a; }
970  // expected-error@+2 {{expected ')'}}
971  // expected-note@+1 {{to match this '('}}
972 #pragma omp atomic compare fail(seq_cst | acquire)
973   if(v < a) { v = a; }
974 // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'fail' clause}}
975 #pragma omp atomic compare fail(relaxed) fail(seq_cst)
976   if(v < a) { v = a; }
977 #pragma omp atomic compare seq_cst weak
978   if(v == a) { v = a; }
979 // expected-error@+1 {{expected 'compare' clause with the 'weak' modifier}}
980 #pragma omp atomic weak
981   if(v < a) { v = a; }
982 #pragma omp atomic compare release weak
983 // expected-error@+1 {{expected '==' operator for 'weak' clause}}
984   if(v < a) { v = a; }
985 // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'weak' clause}}
986 #pragma omp atomic compare release weak fail(seq_cst) weak
987   if(v == a) { v = a; }
988 
989 
990 #endif
991   // expected-note@+1 {{in instantiation of function template specialization 'mixed<int>' requested here}}
992   return mixed<int>();
993 }
994