Alexey Bataev | 0162e45 | 2014-07-22 10:10:35 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s |
| 2 | |
| 3 | int foo() { |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 4 | L1: |
| 5 | foo(); |
| 6 | #pragma omp atomic |
Alexey Bataev | 1d160b1 | 2015-03-13 12:27:31 +0000 | [diff] [blame^] | 7 | // 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 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | 0162e45 | 2014-07-22 10:10:35 +0000 | [diff] [blame] | 9 | { |
| 10 | foo(); |
| 11 | goto L1; // expected-error {{use of undeclared label 'L1'}} |
| 12 | } |
| 13 | goto L2; // expected-error {{use of undeclared label 'L2'}} |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 14 | #pragma omp atomic |
Alexey Bataev | 1d160b1 | 2015-03-13 12:27:31 +0000 | [diff] [blame^] | 15 | // 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 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | 0162e45 | 2014-07-22 10:10:35 +0000 | [diff] [blame] | 17 | { |
| 18 | foo(); |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 19 | L2: |
Alexey Bataev | 0162e45 | 2014-07-22 10:10:35 +0000 | [diff] [blame] | 20 | foo(); |
| 21 | } |
| 22 | |
| 23 | return 0; |
| 24 | } |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 25 | |
Alexey Bataev | 62cec44 | 2014-11-18 10:14:22 +0000 | [diff] [blame] | 26 | struct S { |
| 27 | int a; |
| 28 | S &operator=(int v) { |
| 29 | a = v; |
| 30 | return *this; |
| 31 | } |
| 32 | S &operator+=(const S &s) { |
| 33 | a += s.a; |
| 34 | return *this; |
| 35 | } |
| 36 | }; |
| 37 | |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 38 | template <class T> |
| 39 | T read() { |
Alexey Bataev | 62cec44 | 2014-11-18 10:14:22 +0000 | [diff] [blame] | 40 | T a = T(), b = T(); |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 41 | // Test for atomic read |
| 42 | #pragma omp atomic read |
Alexey Bataev | 62cec44 | 2014-11-18 10:14:22 +0000 | [diff] [blame] | 43 | // 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 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 45 | ; |
Alexey Bataev | 62cec44 | 2014-11-18 10:14:22 +0000 | [diff] [blame] | 46 | #pragma omp atomic read |
| 47 | // 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 | // expected-note@+1 {{expected built-in assignment operator}} |
| 49 | foo(); |
| 50 | #pragma omp atomic read |
| 51 | // 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}} |
| 52 | // expected-note@+1 {{expected built-in assignment operator}} |
| 53 | a += b; |
| 54 | #pragma omp atomic read |
| 55 | // 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 | // expected-note@+1 {{expected lvalue expression}} |
| 57 | a = 0; |
| 58 | #pragma omp atomic read |
| 59 | // 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 | // expected-note@+1 {{expected built-in assignment operator}} |
| 61 | a = b; |
| 62 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}} |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 63 | #pragma omp atomic read read |
Alexey Bataev | 62cec44 | 2014-11-18 10:14:22 +0000 | [diff] [blame] | 64 | // 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 | // expected-note@+1 {{expected built-in assignment operator}} |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 66 | a = b; |
| 67 | |
Alexey Bataev | 62cec44 | 2014-11-18 10:14:22 +0000 | [diff] [blame] | 68 | return a; |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | int read() { |
Alexey Bataev | 62cec44 | 2014-11-18 10:14:22 +0000 | [diff] [blame] | 72 | int a = 0, b = 0; |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 73 | // Test for atomic read |
| 74 | #pragma omp atomic read |
Alexey Bataev | 62cec44 | 2014-11-18 10:14:22 +0000 | [diff] [blame] | 75 | // 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 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 77 | ; |
Alexey Bataev | 62cec44 | 2014-11-18 10:14:22 +0000 | [diff] [blame] | 78 | #pragma omp atomic read |
| 79 | // 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 | // expected-note@+1 {{expected built-in assignment operator}} |
| 81 | foo(); |
| 82 | #pragma omp atomic read |
| 83 | // 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 | // expected-note@+1 {{expected built-in assignment operator}} |
| 85 | a += b; |
| 86 | #pragma omp atomic read |
| 87 | // 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 | // expected-note@+1 {{expected lvalue expression}} |
| 89 | a = 0; |
| 90 | #pragma omp atomic read |
| 91 | a = b; |
| 92 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'read' clause}} |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 93 | #pragma omp atomic read read |
| 94 | a = b; |
| 95 | |
Alexey Bataev | 62cec44 | 2014-11-18 10:14:22 +0000 | [diff] [blame] | 96 | // expected-note@+1 {{in instantiation of function template specialization 'read<S>' requested here}} |
| 97 | return read<int>() + read<S>().a; |
Alexey Bataev | f98b00c | 2014-07-23 02:27:21 +0000 | [diff] [blame] | 98 | } |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 99 | |
| 100 | template <class T> |
| 101 | T write() { |
| 102 | T a, b = 0; |
| 103 | // Test for atomic write |
| 104 | #pragma omp atomic write |
Alexey Bataev | f33eba6 | 2014-11-28 07:21:40 +0000 | [diff] [blame] | 105 | // 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}} |
| 106 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 107 | ; |
| 108 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}} |
| 109 | #pragma omp atomic write write |
| 110 | a = b; |
Alexey Bataev | f33eba6 | 2014-11-28 07:21:40 +0000 | [diff] [blame] | 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 built-in assignment operator}} |
| 114 | foo(); |
| 115 | #pragma omp atomic write |
| 116 | // 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}} |
| 117 | // expected-note@+1 {{expected built-in assignment operator}} |
| 118 | a += b; |
| 119 | #pragma omp atomic write |
| 120 | a = 0; |
| 121 | #pragma omp atomic write |
| 122 | a = b; |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 123 | |
| 124 | return T(); |
| 125 | } |
| 126 | |
| 127 | int write() { |
| 128 | int a, b = 0; |
| 129 | // Test for atomic write |
| 130 | #pragma omp atomic write |
Alexey Bataev | f33eba6 | 2014-11-28 07:21:40 +0000 | [diff] [blame] | 131 | // 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}} |
| 132 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 133 | ; |
| 134 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'write' clause}} |
| 135 | #pragma omp atomic write write |
| 136 | a = b; |
Alexey Bataev | f33eba6 | 2014-11-28 07:21:40 +0000 | [diff] [blame] | 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 built-in assignment operator}} |
| 140 | foo(); |
| 141 | #pragma omp atomic write |
| 142 | // 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}} |
| 143 | // expected-note@+1 {{expected built-in assignment operator}} |
| 144 | a += b; |
| 145 | #pragma omp atomic write |
| 146 | a = 0; |
| 147 | #pragma omp atomic write |
| 148 | a = foo(); |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 149 | |
| 150 | return write<int>(); |
| 151 | } |
| 152 | |
| 153 | template <class T> |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 154 | T update() { |
| 155 | T a, b = 0; |
| 156 | // Test for atomic update |
| 157 | #pragma omp atomic update |
Alexey Bataev | 1d160b1 | 2015-03-13 12:27:31 +0000 | [diff] [blame^] | 158 | // 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}} |
| 159 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 160 | ; |
| 161 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}} |
| 162 | #pragma omp atomic update update |
| 163 | a += b; |
Alexey Bataev | 1d160b1 | 2015-03-13 12:27:31 +0000 | [diff] [blame^] | 164 | #pragma omp atomic |
| 165 | // 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}} |
| 166 | // expected-note@+1 {{expected built-in binary operator}} |
| 167 | a = b; |
| 168 | #pragma omp atomic update |
| 169 | // 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}} |
| 170 | // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}} |
| 171 | a = b || a; |
| 172 | #pragma omp atomic update |
| 173 | // 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}} |
| 174 | // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}} |
| 175 | a = 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 l-value expression with scalar type}} |
| 178 | // expected-note@+1 {{expected in right hand side of expression}} |
| 179 | a = float(a) + b; |
| 180 | #pragma omp atomic |
| 181 | // 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}} |
| 182 | // expected-note@+1 {{expected in right hand side of expression}} |
| 183 | a = 2 * b; |
| 184 | #pragma omp atomic |
| 185 | // 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}} |
| 186 | // expected-note@+1 {{expected in right hand side of expression}} |
| 187 | a = b + *&a; |
| 188 | #pragma omp atomic |
| 189 | *&a = b * *&a; |
| 190 | #pragma omp atomic update |
| 191 | a++; |
| 192 | #pragma omp atomic |
| 193 | ++a; |
| 194 | #pragma omp atomic update |
| 195 | a--; |
| 196 | #pragma omp atomic |
| 197 | --a; |
| 198 | #pragma omp atomic update |
| 199 | a += b; |
| 200 | #pragma omp atomic |
| 201 | a %= b; |
| 202 | #pragma omp atomic update |
| 203 | a *= b; |
| 204 | #pragma omp atomic |
| 205 | a -= b; |
| 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 + a; |
| 220 | #pragma omp atomic |
| 221 | a = a * b; |
| 222 | #pragma omp atomic update |
| 223 | a = b - a; |
| 224 | #pragma omp atomic |
| 225 | a = 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 |
| 235 | a = b >> a; |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 236 | |
| 237 | #pragma omp atomic |
Alexey Bataev | 1d160b1 | 2015-03-13 12:27:31 +0000 | [diff] [blame^] | 238 | // 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}} |
| 239 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 240 | ; |
| 241 | |
| 242 | return T(); |
| 243 | } |
| 244 | |
| 245 | int update() { |
| 246 | int a, b = 0; |
| 247 | // Test for atomic update |
| 248 | #pragma omp atomic update |
Alexey Bataev | 1d160b1 | 2015-03-13 12:27:31 +0000 | [diff] [blame^] | 249 | // 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}} |
| 250 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 251 | ; |
| 252 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'update' clause}} |
| 253 | #pragma omp atomic update update |
| 254 | a += b; |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 255 | #pragma omp atomic |
Alexey Bataev | 1d160b1 | 2015-03-13 12:27:31 +0000 | [diff] [blame^] | 256 | // 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}} |
| 257 | // expected-note@+1 {{expected built-in binary operator}} |
| 258 | a = b; |
| 259 | #pragma omp atomic update |
| 260 | // 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}} |
| 261 | // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}} |
| 262 | a = b || a; |
| 263 | #pragma omp atomic update |
| 264 | // 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}} |
| 265 | // expected-note@+1 {{expected one of '+', '*', '-', '/', '&', '^', '|', '<<', or '>>' built-in operations}} |
| 266 | a = 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 l-value expression with scalar type}} |
| 269 | // expected-note@+1 {{expected in right hand side of expression}} |
| 270 | a = float(a) + b; |
| 271 | #pragma omp atomic |
| 272 | // 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}} |
| 273 | // expected-note@+1 {{expected in right hand side of expression}} |
| 274 | a = 2 * b; |
| 275 | #pragma omp atomic |
| 276 | // 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}} |
| 277 | // expected-note@+1 {{expected in right hand side of expression}} |
| 278 | a = b + *&a; |
| 279 | #pragma omp atomic update |
| 280 | a++; |
| 281 | #pragma omp atomic |
| 282 | ++a; |
| 283 | #pragma omp atomic update |
| 284 | a--; |
| 285 | #pragma omp atomic |
| 286 | --a; |
| 287 | #pragma omp atomic update |
| 288 | a += b; |
| 289 | #pragma omp atomic |
| 290 | a %= b; |
| 291 | #pragma omp atomic update |
| 292 | a *= b; |
| 293 | #pragma omp atomic |
| 294 | a -= b; |
| 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 + a; |
| 309 | #pragma omp atomic |
| 310 | a = a * b; |
| 311 | #pragma omp atomic update |
| 312 | a = b - a; |
| 313 | #pragma omp atomic |
| 314 | a = 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 |
| 324 | a = b >> a; |
| 325 | #pragma omp atomic |
| 326 | // 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}} |
| 327 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 328 | ; |
| 329 | |
| 330 | return update<int>(); |
| 331 | } |
| 332 | |
| 333 | template <class T> |
Alexey Bataev | 459dec0 | 2014-07-24 06:46:57 +0000 | [diff] [blame] | 334 | T capture() { |
| 335 | T a, b = 0; |
| 336 | // Test for atomic capture |
| 337 | #pragma omp atomic capture |
| 338 | // expected-error@+1 {{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}} |
| 339 | ++a; |
| 340 | #pragma omp atomic capture |
| 341 | // expected-error@+1 {{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}} |
| 342 | ; |
| 343 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}} |
| 344 | #pragma omp atomic capture capture |
| 345 | a = ++b; |
| 346 | |
| 347 | return T(); |
| 348 | } |
| 349 | |
| 350 | int capture() { |
| 351 | int a, b = 0; |
| 352 | // Test for atomic capture |
| 353 | #pragma omp atomic capture |
| 354 | // expected-error@+1 {{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}} |
| 355 | ++a; |
| 356 | #pragma omp atomic capture |
| 357 | // expected-error@+1 {{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}} |
| 358 | ; |
| 359 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}} |
| 360 | #pragma omp atomic capture capture |
| 361 | a = ++b; |
| 362 | |
| 363 | return capture<int>(); |
| 364 | } |
| 365 | |
| 366 | template <class T> |
Alexey Bataev | 82bad8b | 2014-07-24 08:55:34 +0000 | [diff] [blame] | 367 | T seq_cst() { |
| 368 | T a, b = 0; |
| 369 | // Test for atomic seq_cst |
| 370 | #pragma omp atomic seq_cst |
Alexey Bataev | 1d160b1 | 2015-03-13 12:27:31 +0000 | [diff] [blame^] | 371 | // 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}} |
| 372 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | 82bad8b | 2014-07-24 08:55:34 +0000 | [diff] [blame] | 373 | ; |
| 374 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst' clause}} |
| 375 | #pragma omp atomic seq_cst seq_cst |
| 376 | a += b; |
| 377 | |
| 378 | #pragma omp atomic update seq_cst |
Alexey Bataev | 1d160b1 | 2015-03-13 12:27:31 +0000 | [diff] [blame^] | 379 | // 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}} |
| 380 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | 82bad8b | 2014-07-24 08:55:34 +0000 | [diff] [blame] | 381 | ; |
| 382 | |
| 383 | return T(); |
| 384 | } |
| 385 | |
| 386 | int seq_cst() { |
| 387 | int a, b = 0; |
| 388 | // Test for atomic seq_cst |
| 389 | #pragma omp atomic seq_cst |
Alexey Bataev | 1d160b1 | 2015-03-13 12:27:31 +0000 | [diff] [blame^] | 390 | // 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}} |
| 391 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | 82bad8b | 2014-07-24 08:55:34 +0000 | [diff] [blame] | 392 | ; |
| 393 | // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'seq_cst' clause}} |
| 394 | #pragma omp atomic seq_cst seq_cst |
| 395 | a += b; |
| 396 | |
| 397 | #pragma omp atomic update seq_cst |
Alexey Bataev | 1d160b1 | 2015-03-13 12:27:31 +0000 | [diff] [blame^] | 398 | // 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}} |
| 399 | // expected-note@+1 {{expected an expression statement}} |
Alexey Bataev | 82bad8b | 2014-07-24 08:55:34 +0000 | [diff] [blame] | 400 | ; |
| 401 | |
| 402 | return seq_cst<int>(); |
| 403 | } |
| 404 | |
| 405 | template <class T> |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 406 | T mixed() { |
| 407 | T a, b = T(); |
| 408 | // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 409 | // expected-note@+1 2 {{'read' clause used here}} |
| 410 | #pragma omp atomic read write |
| 411 | a = b; |
| 412 | // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 413 | // expected-note@+1 2 {{'write' clause used here}} |
| 414 | #pragma omp atomic write read |
| 415 | a = b; |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 416 | // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 417 | // expected-note@+1 2 {{'update' clause used here}} |
| 418 | #pragma omp atomic update read |
| 419 | a += b; |
Alexey Bataev | 459dec0 | 2014-07-24 06:46:57 +0000 | [diff] [blame] | 420 | // expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 421 | // expected-note@+1 2 {{'capture' clause used here}} |
| 422 | #pragma omp atomic capture read |
| 423 | a = ++b; |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 424 | return T(); |
| 425 | } |
| 426 | |
| 427 | int mixed() { |
| 428 | int a, b = 0; |
| 429 | // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 430 | // expected-note@+1 {{'read' clause used here}} |
| 431 | #pragma omp atomic read write |
| 432 | a = b; |
| 433 | // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 434 | // expected-note@+1 {{'write' clause used here}} |
| 435 | #pragma omp atomic write read |
| 436 | a = b; |
Alexey Bataev | 67a4f22 | 2014-07-23 10:25:33 +0000 | [diff] [blame] | 437 | // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 438 | // expected-note@+1 {{'write' clause used here}} |
| 439 | #pragma omp atomic write update |
| 440 | a = b; |
Alexey Bataev | 459dec0 | 2014-07-24 06:46:57 +0000 | [diff] [blame] | 441 | // expected-error@+2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}} |
| 442 | // expected-note@+1 {{'write' clause used here}} |
| 443 | #pragma omp atomic write capture |
| 444 | a = b; |
| 445 | // expected-note@+1 {{in instantiation of function template specialization 'mixed<int>' requested here}} |
Alexey Bataev | dea4761 | 2014-07-23 07:46:59 +0000 | [diff] [blame] | 446 | return mixed<int>(); |
| 447 | } |
| 448 | |