1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s 2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s 3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s 4 5 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s 6 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s 7 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s 8 // expected-no-diagnostics 9 10 #ifndef HEADER 11 #define HEADER 12 13 template <class T> foo(T argc)14T foo(T argc) { 15 T b = T(); 16 T a = T(); 17 #pragma omp atomic 18 a++; 19 #pragma omp atomic read 20 a = argc; 21 #pragma omp atomic write 22 a = argc + argc; 23 #pragma omp atomic update 24 a = a + argc; 25 #pragma omp atomic capture 26 a = b++; 27 #pragma omp atomic capture 28 { 29 a = b; 30 b++; 31 } 32 #pragma omp atomic seq_cst 33 a++; 34 #pragma omp atomic read seq_cst 35 a = argc; 36 #pragma omp atomic seq_cst write 37 a = argc + argc; 38 #pragma omp atomic update seq_cst 39 a = a + argc; 40 #pragma omp atomic seq_cst capture 41 a = b++; 42 #pragma omp atomic capture seq_cst 43 { 44 a = b; 45 b++; 46 } 47 #pragma omp atomic 48 a++; 49 #pragma omp atomic read 50 a = argc; 51 #pragma omp atomic write 52 a = argc + argc; 53 #pragma omp atomic update 54 a = a + argc; 55 #pragma omp atomic acq_rel capture 56 a = b++; 57 #pragma omp atomic capture acq_rel 58 { 59 a = b; 60 b++; 61 } 62 #pragma omp atomic 63 a++; 64 #pragma omp atomic read acquire 65 a = argc; 66 #pragma omp atomic write 67 a = argc + argc; 68 #pragma omp atomic update 69 a = a + argc; 70 #pragma omp atomic acquire capture 71 a = b++; 72 #pragma omp atomic capture acquire 73 { 74 a = b; 75 b++; 76 } 77 #pragma omp atomic release 78 a++; 79 #pragma omp atomic read 80 a = argc; 81 #pragma omp atomic release write 82 a = argc + argc; 83 #pragma omp atomic update release 84 a = a + argc; 85 #pragma omp atomic release capture 86 a = b++; 87 #pragma omp atomic capture release 88 { 89 a = b; 90 b++; 91 } 92 #pragma omp atomic relaxed 93 a++; 94 #pragma omp atomic read 95 a = argc; 96 #pragma omp atomic relaxed write 97 a = argc + argc; 98 #pragma omp atomic update relaxed 99 a = a + argc; 100 #pragma omp atomic relaxed capture 101 a = b++; 102 #pragma omp atomic capture relaxed 103 { 104 a = b; 105 b++; 106 } 107 #pragma omp atomic hint(6) 108 a++; 109 #pragma omp atomic read hint(6) 110 a = argc; 111 #pragma omp atomic hint(6) write 112 a = argc + argc; 113 #pragma omp atomic update hint(6) 114 a = a + argc; 115 #pragma omp atomic hint(6) capture 116 a = b++; 117 #pragma omp atomic capture hint(6) 118 { 119 a = b; 120 b++; 121 } 122 return T(); 123 } 124 125 // CHECK: T a = T(); 126 // CHECK-NEXT: #pragma omp atomic{{$}} 127 // CHECK-NEXT: a++; 128 // CHECK-NEXT: #pragma omp atomic read 129 // CHECK-NEXT: a = argc; 130 // CHECK-NEXT: #pragma omp atomic write 131 // CHECK-NEXT: a = argc + argc; 132 // CHECK-NEXT: #pragma omp atomic update 133 // CHECK-NEXT: a = a + argc; 134 // CHECK-NEXT: #pragma omp atomic capture 135 // CHECK-NEXT: a = b++; 136 // CHECK-NEXT: #pragma omp atomic capture 137 // CHECK-NEXT: { 138 // CHECK-NEXT: a = b; 139 // CHECK-NEXT: b++; 140 // CHECK-NEXT: } 141 // CHECK-NEXT: #pragma omp atomic seq_cst 142 // CHECK-NEXT: a++; 143 // CHECK-NEXT: #pragma omp atomic read seq_cst 144 // CHECK-NEXT: a = argc; 145 // CHECK-NEXT: #pragma omp atomic seq_cst write 146 // CHECK-NEXT: a = argc + argc; 147 // CHECK-NEXT: #pragma omp atomic update seq_cst 148 // CHECK-NEXT: a = a + argc; 149 // CHECK-NEXT: #pragma omp atomic seq_cst capture 150 // CHECK-NEXT: a = b++; 151 // CHECK-NEXT: #pragma omp atomic capture seq_cst 152 // CHECK-NEXT: { 153 // CHECK-NEXT: a = b; 154 // CHECK-NEXT: b++; 155 // CHECK-NEXT: } 156 // CHECK-NEXT: #pragma omp atomic 157 // CHECK-NEXT: a++; 158 // CHECK-NEXT: #pragma omp atomic read 159 // CHECK-NEXT: a = argc; 160 // CHECK-NEXT: #pragma omp atomic write 161 // CHECK-NEXT: a = argc + argc; 162 // CHECK-NEXT: #pragma omp atomic update 163 // CHECK-NEXT: a = a + argc; 164 // CHECK-NEXT: #pragma omp atomic acq_rel capture 165 // CHECK-NEXT: a = b++; 166 // CHECK-NEXT: #pragma omp atomic capture acq_rel 167 // CHECK-NEXT: { 168 // CHECK-NEXT: a = b; 169 // CHECK-NEXT: b++; 170 // CHECK-NEXT: } 171 // CHECK-NEXT: #pragma omp atomic 172 // CHECK-NEXT: a++; 173 // CHECK-NEXT: #pragma omp atomic read acquire 174 // CHECK-NEXT: a = argc; 175 // CHECK-NEXT: #pragma omp atomic write 176 // CHECK-NEXT: a = argc + argc; 177 // CHECK-NEXT: #pragma omp atomic update 178 // CHECK-NEXT: a = a + argc; 179 // CHECK-NEXT: #pragma omp atomic acquire capture 180 // CHECK-NEXT: a = b++; 181 // CHECK-NEXT: #pragma omp atomic capture acquire 182 // CHECK-NEXT: { 183 // CHECK-NEXT: a = b; 184 // CHECK-NEXT: b++; 185 // CHECK-NEXT: } 186 // CHECK-NEXT: #pragma omp atomic release 187 // CHECK-NEXT: a++; 188 // CHECK-NEXT: #pragma omp atomic read 189 // CHECK-NEXT: a = argc; 190 // CHECK-NEXT: #pragma omp atomic release write 191 // CHECK-NEXT: a = argc + argc; 192 // CHECK-NEXT: #pragma omp atomic update release 193 // CHECK-NEXT: a = a + argc; 194 // CHECK-NEXT: #pragma omp atomic release capture 195 // CHECK-NEXT: a = b++; 196 // CHECK-NEXT: #pragma omp atomic capture release 197 // CHECK-NEXT: { 198 // CHECK-NEXT: a = b; 199 // CHECK-NEXT: b++; 200 // CHECK-NEXT: } 201 // CHECK-NEXT: #pragma omp atomic relaxed 202 // CHECK-NEXT: a++; 203 // CHECK-NEXT: #pragma omp atomic read 204 // CHECK-NEXT: a = argc; 205 // CHECK-NEXT: #pragma omp atomic relaxed write 206 // CHECK-NEXT: a = argc + argc; 207 // CHECK-NEXT: #pragma omp atomic update relaxed 208 // CHECK-NEXT: a = a + argc; 209 // CHECK-NEXT: #pragma omp atomic relaxed capture 210 // CHECK-NEXT: a = b++; 211 // CHECK-NEXT: #pragma omp atomic capture relaxed 212 // CHECK-NEXT: { 213 // CHECK-NEXT: a = b; 214 // CHECK-NEXT: b++; 215 // CHECK-NEXT: } 216 // CHECK-NEXT: #pragma omp atomic hint(6) 217 // CHECK-NEXT: a++; 218 // CHECK-NEXT: #pragma omp atomic read hint(6) 219 // CHECK-NEXT: a = argc; 220 // CHECK-NEXT: #pragma omp atomic hint(6) write 221 // CHECK-NEXT: a = argc + argc; 222 // CHECK-NEXT: #pragma omp atomic update hint(6) 223 // CHECK-NEXT: a = a + argc; 224 // CHECK-NEXT: #pragma omp atomic hint(6) capture 225 // CHECK-NEXT: a = b++; 226 // CHECK-NEXT: #pragma omp atomic capture hint(6) 227 // CHECK-NEXT: { 228 // CHECK-NEXT: a = b; 229 // CHECK-NEXT: b++; 230 // CHECK-NEXT: } 231 // CHECK: int a = int(); 232 // CHECK-NEXT: #pragma omp atomic 233 // CHECK-NEXT: a++; 234 // CHECK-NEXT: #pragma omp atomic read 235 // CHECK-NEXT: a = argc; 236 // CHECK-NEXT: #pragma omp atomic write 237 // CHECK-NEXT: a = argc + argc; 238 // CHECK-NEXT: #pragma omp atomic update 239 // CHECK-NEXT: a = a + argc; 240 // CHECK-NEXT: #pragma omp atomic capture 241 // CHECK-NEXT: a = b++; 242 // CHECK-NEXT: #pragma omp atomic capture 243 // CHECK-NEXT: { 244 // CHECK-NEXT: a = b; 245 // CHECK-NEXT: b++; 246 // CHECK-NEXT: } 247 // CHECK-NEXT: #pragma omp atomic seq_cst 248 // CHECK-NEXT: a++; 249 // CHECK-NEXT: #pragma omp atomic read seq_cst 250 // CHECK-NEXT: a = argc; 251 // CHECK-NEXT: #pragma omp atomic seq_cst write 252 // CHECK-NEXT: a = argc + argc; 253 // CHECK-NEXT: #pragma omp atomic update seq_cst 254 // CHECK-NEXT: a = a + argc; 255 // CHECK-NEXT: #pragma omp atomic seq_cst capture 256 // CHECK-NEXT: a = b++; 257 // CHECK-NEXT: #pragma omp atomic capture seq_cst 258 // CHECK-NEXT: { 259 // CHECK-NEXT: a = b; 260 // CHECK-NEXT: b++; 261 // CHECK-NEXT: } 262 // CHECK-NEXT: #pragma omp atomic 263 // CHECK-NEXT: a++; 264 // CHECK-NEXT: #pragma omp atomic read 265 // CHECK-NEXT: a = argc; 266 // CHECK-NEXT: #pragma omp atomic write 267 // CHECK-NEXT: a = argc + argc; 268 // CHECK-NEXT: #pragma omp atomic update 269 // CHECK-NEXT: a = a + argc; 270 // CHECK-NEXT: #pragma omp atomic acq_rel capture 271 // CHECK-NEXT: a = b++; 272 // CHECK-NEXT: #pragma omp atomic capture acq_rel 273 // CHECK-NEXT: { 274 // CHECK-NEXT: a = b; 275 // CHECK-NEXT: b++; 276 // CHECK-NEXT: } 277 // CHECK-NEXT: #pragma omp atomic 278 // CHECK-NEXT: a++; 279 // CHECK-NEXT: #pragma omp atomic read acquire 280 // CHECK-NEXT: a = argc; 281 // CHECK-NEXT: #pragma omp atomic write 282 // CHECK-NEXT: a = argc + argc; 283 // CHECK-NEXT: #pragma omp atomic update 284 // CHECK-NEXT: a = a + argc; 285 // CHECK-NEXT: #pragma omp atomic acquire capture 286 // CHECK-NEXT: a = b++; 287 // CHECK-NEXT: #pragma omp atomic capture acquire 288 // CHECK-NEXT: { 289 // CHECK-NEXT: a = b; 290 // CHECK-NEXT: b++; 291 // CHECK-NEXT: } 292 // CHECK-NEXT: #pragma omp atomic release 293 // CHECK-NEXT: a++; 294 // CHECK-NEXT: #pragma omp atomic read 295 // CHECK-NEXT: a = argc; 296 // CHECK-NEXT: #pragma omp atomic release write 297 // CHECK-NEXT: a = argc + argc; 298 // CHECK-NEXT: #pragma omp atomic update release 299 // CHECK-NEXT: a = a + argc; 300 // CHECK-NEXT: #pragma omp atomic release capture 301 // CHECK-NEXT: a = b++; 302 // CHECK-NEXT: #pragma omp atomic capture release 303 // CHECK-NEXT: { 304 // CHECK-NEXT: a = b; 305 // CHECK-NEXT: b++; 306 // CHECK-NEXT: } 307 // CHECK-NEXT: #pragma omp atomic relaxed 308 // CHECK-NEXT: a++; 309 // CHECK-NEXT: #pragma omp atomic read 310 // CHECK-NEXT: a = argc; 311 // CHECK-NEXT: #pragma omp atomic relaxed write 312 // CHECK-NEXT: a = argc + argc; 313 // CHECK-NEXT: #pragma omp atomic update relaxed 314 // CHECK-NEXT: a = a + argc; 315 // CHECK-NEXT: #pragma omp atomic relaxed capture 316 // CHECK-NEXT: a = b++; 317 // CHECK-NEXT: #pragma omp atomic capture relaxed 318 // CHECK-NEXT: { 319 // CHECK-NEXT: a = b; 320 // CHECK-NEXT: b++; 321 // CHECK-NEXT: } 322 // CHECK-NEXT: #pragma omp atomic hint(6) 323 // CHECK-NEXT: a++; 324 // CHECK-NEXT: #pragma omp atomic read hint(6) 325 // CHECK-NEXT: a = argc; 326 // CHECK-NEXT: #pragma omp atomic hint(6) write 327 // CHECK-NEXT: a = argc + argc; 328 // CHECK-NEXT: #pragma omp atomic update hint(6) 329 // CHECK-NEXT: a = a + argc; 330 // CHECK-NEXT: #pragma omp atomic hint(6) capture 331 // CHECK-NEXT: a = b++; 332 // CHECK-NEXT: #pragma omp atomic capture hint(6) 333 // CHECK-NEXT: { 334 // CHECK-NEXT: a = b; 335 // CHECK-NEXT: b++; 336 // CHECK-NEXT: } 337 main(int argc,char ** argv)338int main(int argc, char **argv) { 339 int b = 0; 340 int a = 0; 341 // CHECK: int a = 0; 342 #pragma omp atomic 343 a++; 344 #pragma omp atomic read 345 a = argc; 346 #pragma omp atomic write 347 a = argc + argc; 348 #pragma omp atomic update 349 a = a + argc; 350 #pragma omp atomic capture 351 a = b++; 352 #pragma omp atomic capture 353 { 354 a = b; 355 b++; 356 } 357 #pragma omp atomic seq_cst 358 a++; 359 #pragma omp atomic read seq_cst 360 a = argc; 361 #pragma omp atomic seq_cst write 362 a = argc + argc; 363 #pragma omp atomic update seq_cst 364 a = a + argc; 365 #pragma omp atomic seq_cst capture 366 a = b++; 367 #pragma omp atomic capture seq_cst 368 { 369 a = b; 370 b++; 371 } 372 #pragma omp atomic 373 a++; 374 #pragma omp atomic read 375 a = argc; 376 #pragma omp atomic write 377 a = argc + argc; 378 #pragma omp atomic update 379 a = a + argc; 380 #pragma omp atomic acq_rel capture 381 a = b++; 382 #pragma omp atomic capture acq_rel 383 { 384 a = b; 385 b++; 386 } 387 #pragma omp atomic 388 a++; 389 #pragma omp atomic read acquire 390 a = argc; 391 #pragma omp atomic write 392 a = argc + argc; 393 #pragma omp atomic update 394 a = a + argc; 395 #pragma omp atomic acquire capture 396 a = b++; 397 #pragma omp atomic capture acquire 398 { 399 a = b; 400 b++; 401 } 402 #pragma omp atomic release 403 a++; 404 #pragma omp atomic read 405 a = argc; 406 #pragma omp atomic release write 407 a = argc + argc; 408 #pragma omp atomic update release 409 a = a + argc; 410 #pragma omp atomic release capture 411 a = b++; 412 #pragma omp atomic capture release 413 { 414 a = b; 415 b++; 416 } 417 #pragma omp atomic relaxed 418 a++; 419 #pragma omp atomic read 420 a = argc; 421 #pragma omp atomic relaxed write 422 a = argc + argc; 423 #pragma omp atomic update relaxed 424 a = a + argc; 425 #pragma omp atomic relaxed capture 426 a = b++; 427 #pragma omp atomic capture relaxed 428 { 429 a = b; 430 b++; 431 } 432 #pragma omp atomic hint(6) 433 a++; 434 #pragma omp atomic read hint(6) 435 a = argc; 436 #pragma omp atomic hint(6) write 437 a = argc + argc; 438 #pragma omp atomic update hint(6) 439 a = a + argc; 440 #pragma omp atomic hint(6) capture 441 a = b++; 442 #pragma omp atomic capture hint(6) 443 { 444 a = b; 445 b++; 446 } 447 // CHECK-NEXT: #pragma omp atomic 448 // CHECK-NEXT: a++; 449 // CHECK-NEXT: #pragma omp atomic read 450 // CHECK-NEXT: a = argc; 451 // CHECK-NEXT: #pragma omp atomic write 452 // CHECK-NEXT: a = argc + argc; 453 // CHECK-NEXT: #pragma omp atomic update 454 // CHECK-NEXT: a = a + argc; 455 // CHECK-NEXT: #pragma omp atomic capture 456 // CHECK-NEXT: a = b++; 457 // CHECK-NEXT: #pragma omp atomic capture 458 // CHECK-NEXT: { 459 // CHECK-NEXT: a = b; 460 // CHECK-NEXT: b++; 461 // CHECK-NEXT: } 462 // CHECK-NEXT: #pragma omp atomic seq_cst 463 // CHECK-NEXT: a++; 464 // CHECK-NEXT: #pragma omp atomic read seq_cst 465 // CHECK-NEXT: a = argc; 466 // CHECK-NEXT: #pragma omp atomic seq_cst write 467 // CHECK-NEXT: a = argc + argc; 468 // CHECK-NEXT: #pragma omp atomic update seq_cst 469 // CHECK-NEXT: a = a + argc; 470 // CHECK-NEXT: #pragma omp atomic seq_cst capture 471 // CHECK-NEXT: a = b++; 472 // CHECK-NEXT: #pragma omp atomic capture seq_cst 473 // CHECK-NEXT: { 474 // CHECK-NEXT: a = b; 475 // CHECK-NEXT: b++; 476 // CHECK-NEXT: } 477 // CHECK-NEXT: #pragma omp atomic 478 // CHECK-NEXT: a++; 479 // CHECK-NEXT: #pragma omp atomic read 480 // CHECK-NEXT: a = argc; 481 // CHECK-NEXT: #pragma omp atomic write 482 // CHECK-NEXT: a = argc + argc; 483 // CHECK-NEXT: #pragma omp atomic update 484 // CHECK-NEXT: a = a + argc; 485 // CHECK-NEXT: #pragma omp atomic acq_rel capture 486 // CHECK-NEXT: a = b++; 487 // CHECK-NEXT: #pragma omp atomic capture acq_rel 488 // CHECK-NEXT: { 489 // CHECK-NEXT: a = b; 490 // CHECK-NEXT: b++; 491 // CHECK-NEXT: } 492 // CHECK-NEXT: #pragma omp atomic 493 // CHECK-NEXT: a++; 494 // CHECK-NEXT: #pragma omp atomic read acquire 495 // CHECK-NEXT: a = argc; 496 // CHECK-NEXT: #pragma omp atomic write 497 // CHECK-NEXT: a = argc + argc; 498 // CHECK-NEXT: #pragma omp atomic update 499 // CHECK-NEXT: a = a + argc; 500 // CHECK-NEXT: #pragma omp atomic acquire capture 501 // CHECK-NEXT: a = b++; 502 // CHECK-NEXT: #pragma omp atomic capture acquire 503 // CHECK-NEXT: { 504 // CHECK-NEXT: a = b; 505 // CHECK-NEXT: b++; 506 // CHECK-NEXT: } 507 // CHECK-NEXT: #pragma omp atomic release 508 // CHECK-NEXT: a++; 509 // CHECK-NEXT: #pragma omp atomic read 510 // CHECK-NEXT: a = argc; 511 // CHECK-NEXT: #pragma omp atomic release write 512 // CHECK-NEXT: a = argc + argc; 513 // CHECK-NEXT: #pragma omp atomic update release 514 // CHECK-NEXT: a = a + argc; 515 // CHECK-NEXT: #pragma omp atomic release capture 516 // CHECK-NEXT: a = b++; 517 // CHECK-NEXT: #pragma omp atomic capture release 518 // CHECK-NEXT: { 519 // CHECK-NEXT: a = b; 520 // CHECK-NEXT: b++; 521 // CHECK-NEXT: } 522 // CHECK-NEXT: #pragma omp atomic relaxed 523 // CHECK-NEXT: a++; 524 // CHECK-NEXT: #pragma omp atomic read 525 // CHECK-NEXT: a = argc; 526 // CHECK-NEXT: #pragma omp atomic relaxed write 527 // CHECK-NEXT: a = argc + argc; 528 // CHECK-NEXT: #pragma omp atomic update relaxed 529 // CHECK-NEXT: a = a + argc; 530 // CHECK-NEXT: #pragma omp atomic relaxed capture 531 // CHECK-NEXT: a = b++; 532 // CHECK-NEXT: #pragma omp atomic capture relaxed 533 // CHECK-NEXT: { 534 // CHECK-NEXT: a = b; 535 // CHECK-NEXT: b++; 536 // CHECK-NEXT: } 537 // CHECK-NEXT: #pragma omp atomic hint(6) 538 // CHECK-NEXT: a++; 539 // CHECK-NEXT: #pragma omp atomic read hint(6) 540 // CHECK-NEXT: a = argc; 541 // CHECK-NEXT: #pragma omp atomic hint(6) write 542 // CHECK-NEXT: a = argc + argc; 543 // CHECK-NEXT: #pragma omp atomic update hint(6) 544 // CHECK-NEXT: a = a + argc; 545 // CHECK-NEXT: #pragma omp atomic hint(6) capture 546 // CHECK-NEXT: a = b++; 547 // CHECK-NEXT: #pragma omp atomic capture hint(6) 548 // CHECK-NEXT: { 549 // CHECK-NEXT: a = b; 550 // CHECK-NEXT: b++; 551 // CHECK-NEXT: } 552 return foo(a); 553 } 554 555 #endif 556