1 // RUN: %clang_cc1 -fsyntax-only -fopenmp -verify %s 2 3 void bar(); 4 5 template <class T> 6 void foo() { 7 T a = T(); 8 // PARALLEL DIRECTIVE 9 #pragma omp parallel 10 #pragma omp for 11 for (int i = 0; i < 10; ++i) 12 ; 13 #pragma omp parallel 14 #pragma omp simd 15 for (int i = 0; i < 10; ++i) 16 ; 17 #pragma omp parallel 18 #pragma omp for simd 19 for (int i = 0; i < 10; ++i) 20 ; 21 #pragma omp parallel 22 #pragma omp sections 23 { 24 bar(); 25 } 26 #pragma omp parallel 27 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a parallel region}} 28 { 29 bar(); 30 } 31 #pragma omp parallel 32 #pragma omp single 33 bar(); 34 35 #pragma omp parallel 36 #pragma omp master 37 { 38 bar(); 39 } 40 #pragma omp parallel 41 #pragma omp critical 42 { 43 bar(); 44 } 45 #pragma omp parallel 46 #pragma omp parallel for 47 for (int i = 0; i < 10; ++i) 48 ; 49 #pragma omp parallel 50 #pragma omp parallel for simd 51 for (int i = 0; i < 10; ++i) 52 ; 53 #pragma omp parallel 54 #pragma omp parallel sections 55 { 56 bar(); 57 } 58 #pragma omp parallel 59 #pragma omp task 60 { 61 bar(); 62 } 63 #pragma omp parallel 64 { 65 #pragma omp taskyield 66 bar(); 67 } 68 #pragma omp parallel 69 { 70 #pragma omp barrier 71 bar(); 72 } 73 #pragma omp parallel 74 { 75 #pragma omp taskwait 76 bar(); 77 } 78 #pragma omp parallel 79 { 80 #pragma omp flush 81 bar(); 82 } 83 #pragma omp parallel 84 { 85 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 86 bar(); 87 } 88 #pragma omp parallel 89 { 90 #pragma omp atomic 91 ++a; 92 } 93 #pragma omp parallel 94 { 95 #pragma omp target 96 ++a; 97 } 98 #pragma omp parallel 99 { 100 #pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 101 ++a; 102 } 103 #pragma omp parallel 104 { 105 #pragma omp taskloop 106 for (int i = 0; i < 10; ++i) 107 ++a; 108 } 109 #pragma omp parallel 110 { 111 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 112 for (int i = 0; i < 10; ++i) 113 ; 114 } 115 116 // SIMD DIRECTIVE 117 #pragma omp simd 118 for (int i = 0; i < 10; ++i) { 119 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} 120 for (int i = 0; i < 10; ++i) 121 ; 122 } 123 #pragma omp simd 124 for (int i = 0; i < 10; ++i) { 125 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 126 for (int i = 0; i < 10; ++i) 127 ; 128 } 129 #pragma omp simd 130 for (int i = 0; i < 10; ++i) { 131 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 132 for (int i = 0; i < 10; ++i) 133 ; 134 } 135 #pragma omp simd 136 for (int i = 0; i < 10; ++i) { 137 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} 138 for (int i = 0; i < 10; ++i) 139 ; 140 } 141 #pragma omp simd 142 for (int i = 0; i < 10; ++i) { 143 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} 144 { 145 bar(); 146 } 147 } 148 #pragma omp simd 149 for (int i = 0; i < 10; ++i) { 150 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}} 151 { 152 bar(); 153 } 154 } 155 #pragma omp simd 156 for (int i = 0; i < 10; ++i) { 157 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} 158 { 159 bar(); 160 } 161 } 162 #pragma omp simd 163 for (int i = 0; i < 10; ++i) { 164 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}} 165 { 166 bar(); 167 } 168 } 169 #pragma omp simd 170 for (int i = 0; i < 10; ++i) { 171 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}} 172 { 173 bar(); 174 } 175 } 176 #pragma omp simd 177 for (int i = 0; i < 10; ++i) { 178 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} 179 for (int i = 0; i < 10; ++i) 180 ; 181 } 182 #pragma omp simd 183 for (int i = 0; i < 10; ++i) { 184 #pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 185 for (int i = 0; i < 10; ++i) 186 ; 187 } 188 #pragma omp simd 189 for (int i = 0; i < 10; ++i) { 190 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} 191 { 192 bar(); 193 } 194 } 195 #pragma omp simd 196 for (int i = 0; i < 10; ++i) { 197 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}} 198 { 199 bar(); 200 } 201 } 202 #pragma omp simd 203 for (int i = 0; i < 10; ++i) { 204 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}} 205 bar(); 206 } 207 #pragma omp simd 208 for (int i = 0; i < 10; ++i) { 209 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}} 210 bar(); 211 } 212 #pragma omp simd 213 for (int i = 0; i < 10; ++i) { 214 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}} 215 bar(); 216 } 217 #pragma omp simd 218 for (int i = 0; i < 10; ++i) { 219 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}} 220 bar(); 221 } 222 #pragma omp simd 223 for (int i = 0; i < 10; ++i) { 224 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} 225 bar(); 226 } 227 #pragma omp simd 228 for (int i = 0; i < 10; ++i) { 229 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}} 230 ++a; 231 } 232 #pragma omp simd 233 for (int i = 0; i < 10; ++i) { 234 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}} 235 ++a; 236 } 237 #pragma omp simd 238 for (int i = 0; i < 10; ++i) { 239 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} 240 ++a; 241 } 242 #pragma omp simd 243 for (int i = 0; i < 10; ++i) { 244 #pragma omp taskloop // expected-error {{OpenMP constructs may not be nested inside a simd region}} 245 for (int i = 0; i < 10; ++i) 246 ++a; 247 } 248 #pragma omp simd 249 for (int i = 0; i < 10; ++i) { 250 #pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} 251 for (int j = 0; j < 10; ++j) 252 ; 253 } 254 255 // FOR DIRECTIVE 256 #pragma omp for 257 for (int i = 0; i < 10; ++i) { 258 #pragma omp for // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 259 for (int i = 0; i < 10; ++i) 260 ; 261 } 262 #pragma omp for 263 for (int i = 0; i < 10; ++i) { 264 #pragma omp simd 265 for (int i = 0; i < 10; ++i) 266 ; 267 } 268 #pragma omp for 269 for (int i = 0; i < 10; ++i) { 270 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 271 for (int i = 0; i < 10; ++i) 272 ; 273 } 274 #pragma omp for 275 for (int i = 0; i < 10; ++i) { 276 #pragma omp parallel 277 for (int i = 0; i < 10; ++i) 278 ; 279 } 280 #pragma omp for 281 for (int i = 0; i < 10; ++i) { 282 #pragma omp sections // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 283 { 284 bar(); 285 } 286 } 287 #pragma omp for 288 for (int i = 0; i < 10; ++i) { 289 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a for region}} 290 { 291 bar(); 292 } 293 } 294 #pragma omp for 295 for (int i = 0; i < 10; ++i) { 296 #pragma omp single // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 297 { 298 bar(); 299 } 300 } 301 302 #pragma omp for 303 for (int i = 0; i < 10; ++i) { 304 #pragma omp master // expected-error {{region cannot be closely nested inside 'for' region}} 305 { 306 bar(); 307 } 308 } 309 #pragma omp for 310 for (int i = 0; i < 10; ++i) { 311 #pragma omp critical 312 { 313 bar(); 314 } 315 } 316 #pragma omp for 317 for (int i = 0; i < 10; ++i) { 318 #pragma omp parallel 319 { 320 #pragma omp single // OK 321 { 322 bar(); 323 } 324 #pragma omp for // OK 325 for (int i = 0; i < 10; ++i) 326 ; 327 #pragma omp sections // OK 328 { 329 bar(); 330 } 331 } 332 } 333 #pragma omp for 334 for (int i = 0; i < 10; ++i) { 335 #pragma omp parallel for 336 for (int i = 0; i < 10; ++i) 337 ; 338 } 339 #pragma omp for 340 for (int i = 0; i < 10; ++i) { 341 #pragma omp parallel for simd 342 for (int i = 0; i < 10; ++i) 343 ; 344 } 345 #pragma omp for 346 for (int i = 0; i < 10; ++i) { 347 #pragma omp parallel sections 348 { 349 bar(); 350 } 351 } 352 #pragma omp for 353 for (int i = 0; i < 10; ++i) { 354 #pragma omp task 355 { 356 bar(); 357 } 358 } 359 #pragma omp for 360 for (int i = 0; i < 10; ++i) { 361 #pragma omp taskyield 362 bar(); 363 } 364 #pragma omp for 365 for (int i = 0; i < 10; ++i) { 366 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'for' region}} 367 bar(); 368 } 369 #pragma omp for 370 for (int i = 0; i < 10; ++i) { 371 #pragma omp taskwait 372 bar(); 373 } 374 #pragma omp for 375 for (int i = 0; i < 10; ++i) { 376 #pragma omp flush 377 bar(); 378 } 379 #pragma omp for 380 for (int i = 0; i < 10; ++i) { 381 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 382 bar(); 383 } 384 #pragma omp for ordered 385 for (int i = 0; i < 10; ++i) { 386 #pragma omp ordered // OK 387 bar(); 388 } 389 #pragma omp for 390 for (int i = 0; i < 10; ++i) { 391 #pragma omp atomic 392 ++a; 393 } 394 #pragma omp for 395 for (int i = 0; i < 10; ++i) { 396 #pragma omp target 397 ++a; 398 } 399 #pragma omp for 400 for (int i = 0; i < 10; ++i) { 401 #pragma omp teams // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 402 ++a; 403 } 404 #pragma omp for 405 for (int i = 0; i < 10; ++i) { 406 #pragma omp taskloop 407 for (int i = 0; i < 10; ++i) 408 ++a; 409 } 410 #pragma omp for 411 for (int i = 0; i < 10; ++i) { 412 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 413 for (int j = 0; j < 10; ++j) 414 ; 415 } 416 417 // FOR SIMD DIRECTIVE 418 #pragma omp for simd 419 for (int i = 0; i < 10; ++i) { 420 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} 421 for (int i = 0; i < 10; ++i) 422 ; 423 } 424 #pragma omp for simd 425 for (int i = 0; i < 10; ++i) { 426 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 427 for (int i = 0; i < 10; ++i) 428 ; 429 } 430 #pragma omp for simd 431 for (int i = 0; i < 10; ++i) { 432 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 433 for (int i = 0; i < 10; ++i) 434 ; 435 } 436 #pragma omp for simd 437 for (int i = 0; i < 10; ++i) { 438 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} 439 for (int i = 0; i < 10; ++i) 440 ; 441 } 442 #pragma omp for simd 443 for (int i = 0; i < 10; ++i) { 444 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} 445 { 446 bar(); 447 } 448 } 449 #pragma omp for simd 450 for (int i = 0; i < 10; ++i) { 451 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}} 452 { 453 bar(); 454 } 455 } 456 #pragma omp for simd 457 for (int i = 0; i < 10; ++i) { 458 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} 459 { 460 bar(); 461 } 462 } 463 #pragma omp for simd 464 for (int i = 0; i < 10; ++i) { 465 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}} 466 { 467 bar(); 468 } 469 } 470 #pragma omp for simd 471 for (int i = 0; i < 10; ++i) { 472 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}} 473 { 474 bar(); 475 } 476 } 477 #pragma omp for simd 478 for (int i = 0; i < 10; ++i) { 479 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} 480 for (int i = 0; i < 10; ++i) 481 ; 482 } 483 #pragma omp for simd 484 for (int i = 0; i < 10; ++i) { 485 #pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 486 for (int i = 0; i < 10; ++i) 487 ; 488 } 489 #pragma omp for simd 490 for (int i = 0; i < 10; ++i) { 491 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} 492 { 493 bar(); 494 } 495 } 496 #pragma omp for simd 497 for (int i = 0; i < 10; ++i) { 498 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}} 499 { 500 bar(); 501 } 502 } 503 #pragma omp for simd 504 for (int i = 0; i < 10; ++i) { 505 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}} 506 bar(); 507 } 508 #pragma omp for simd 509 for (int i = 0; i < 10; ++i) { 510 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}} 511 bar(); 512 } 513 #pragma omp for simd 514 for (int i = 0; i < 10; ++i) { 515 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}} 516 bar(); 517 } 518 #pragma omp for simd 519 for (int i = 0; i < 10; ++i) { 520 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}} 521 bar(); 522 } 523 #pragma omp for simd 524 for (int i = 0; i < 10; ++i) { 525 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} 526 bar(); 527 } 528 #pragma omp for simd 529 for (int i = 0; i < 10; ++i) { 530 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}} 531 ++a; 532 } 533 #pragma omp for simd 534 for (int i = 0; i < 10; ++i) { 535 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}} 536 ++a; 537 } 538 #pragma omp for simd 539 for (int i = 0; i < 10; ++i) { 540 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} 541 ++a; 542 } 543 #pragma omp for simd 544 for (int i = 0; i < 10; ++i) { 545 #pragma omp taskloop // expected-error {{OpenMP constructs may not be nested inside a simd region}} 546 for (int i = 0; i < 10; ++i) 547 ++a; 548 } 549 #pragma omp for simd 550 for (int i = 0; i < 10; ++i) { 551 #pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} 552 for (int j = 0; j < 10; ++j) 553 ; 554 } 555 556 // SECTIONS DIRECTIVE 557 #pragma omp sections 558 { 559 #pragma omp for // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 560 for (int i = 0; i < 10; ++i) 561 ; 562 } 563 #pragma omp sections 564 { 565 #pragma omp simd 566 for (int i = 0; i < 10; ++i) 567 ; 568 } 569 #pragma omp sections 570 { 571 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 572 for (int i = 0; i < 10; ++i) 573 ; 574 } 575 #pragma omp sections 576 { 577 #pragma omp parallel 578 for (int i = 0; i < 10; ++i) 579 ; 580 } 581 #pragma omp sections 582 { 583 #pragma omp sections // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 584 { 585 bar(); 586 } 587 } 588 #pragma omp sections 589 { 590 #pragma omp section 591 { 592 bar(); 593 } 594 } 595 #pragma omp sections 596 { 597 #pragma omp parallel 598 { 599 #pragma omp single // OK 600 { 601 bar(); 602 } 603 #pragma omp for // OK 604 for (int i = 0; i < 10; ++i) 605 ; 606 #pragma omp sections // OK 607 { 608 bar(); 609 } 610 } 611 } 612 #pragma omp sections 613 { 614 #pragma omp parallel 615 { 616 #pragma omp master // OK 617 { 618 bar(); 619 } 620 #pragma omp for // OK 621 for (int i = 0; i < 10; ++i) 622 ; 623 #pragma omp master // OK 624 { 625 bar(); 626 } 627 } 628 #pragma omp master // expected-error {{region cannot be closely nested inside 'sections' region}} 629 bar(); 630 } 631 #pragma omp sections 632 { 633 #pragma omp parallel 634 { 635 #pragma omp critical(A) // OK 636 { 637 bar(); 638 } 639 #pragma omp for // OK 640 for (int i = 0; i < 10; ++i) 641 ; 642 #pragma omp critical // OK 643 { 644 bar(); 645 } 646 } 647 #pragma omp critical(A) // expected-error {{statement in 'omp sections' directive must be enclosed into a section region}} 648 bar(); 649 } 650 #pragma omp sections 651 { 652 #pragma omp parallel for 653 for (int i = 0; i < 10; ++i) 654 ; 655 } 656 #pragma omp sections 657 { 658 #pragma omp parallel for simd 659 for (int i = 0; i < 10; ++i) 660 ; 661 } 662 #pragma omp sections 663 { 664 #pragma omp parallel sections 665 { 666 bar(); 667 } 668 } 669 #pragma omp sections 670 { 671 #pragma omp task 672 { 673 bar(); 674 } 675 } 676 #pragma omp sections 677 { 678 #pragma omp taskyield 679 } 680 #pragma omp sections 681 { 682 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'sections' region}} 683 } 684 #pragma omp sections 685 { 686 #pragma omp taskwait 687 } 688 #pragma omp sections 689 { 690 #pragma omp flush 691 } 692 #pragma omp sections 693 { 694 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 695 bar(); 696 } 697 #pragma omp sections 698 { 699 #pragma omp atomic 700 ++a; 701 } 702 #pragma omp sections 703 { 704 #pragma omp target 705 ++a; 706 } 707 #pragma omp sections 708 { 709 #pragma omp teams // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 710 ++a; 711 } 712 #pragma omp sections 713 { 714 #pragma omp taskloop 715 for (int i = 0; i < 10; ++i) 716 ++a; 717 } 718 #pragma omp sections 719 { 720 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 721 for (int i = 0; i < 10; ++i) 722 ; 723 } 724 725 // SECTION DIRECTIVE 726 #pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}} 727 { 728 bar(); 729 } 730 #pragma omp sections 731 { 732 #pragma omp section 733 { 734 #pragma omp for // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 735 for (int i = 0; i < 10; ++i) 736 ; 737 } 738 } 739 #pragma omp sections 740 { 741 #pragma omp section 742 { 743 #pragma omp simd 744 for (int i = 0; i < 10; ++i) 745 ; 746 } 747 } 748 #pragma omp sections 749 { 750 #pragma omp section 751 { 752 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 753 for (int i = 0; i < 10; ++i) 754 ; 755 } 756 } 757 #pragma omp sections 758 { 759 #pragma omp section 760 { 761 #pragma omp parallel 762 for (int i = 0; i < 10; ++i) 763 ; 764 } 765 } 766 #pragma omp sections 767 { 768 #pragma omp section 769 { 770 #pragma omp sections // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 771 { 772 bar(); 773 } 774 } 775 } 776 #pragma omp sections 777 { 778 #pragma omp section 779 { 780 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a section region}} 781 { 782 bar(); 783 } 784 } 785 } 786 #pragma omp sections 787 { 788 #pragma omp section 789 { 790 #pragma omp single // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 791 bar(); 792 #pragma omp master // expected-error {{region cannot be closely nested inside 'section' region}} 793 bar(); 794 #pragma omp critical 795 bar(); 796 } 797 } 798 #pragma omp sections 799 { 800 #pragma omp section 801 { 802 #pragma omp parallel 803 { 804 #pragma omp single // OK 805 { 806 bar(); 807 } 808 #pragma omp for // OK 809 for (int i = 0; i < 10; ++i) 810 ; 811 #pragma omp for simd // OK 812 for (int i = 0; i < 10; ++i) 813 ; 814 #pragma omp sections // OK 815 { 816 bar(); 817 } 818 } 819 } 820 } 821 #pragma omp sections 822 { 823 #pragma omp section 824 { 825 #pragma omp parallel for 826 for (int i = 0; i < 10; ++i) 827 ; 828 } 829 } 830 #pragma omp sections 831 { 832 #pragma omp section 833 { 834 #pragma omp parallel for simd 835 for (int i = 0; i < 10; ++i) 836 ; 837 } 838 } 839 #pragma omp sections 840 { 841 #pragma omp section 842 { 843 #pragma omp parallel sections 844 { 845 bar(); 846 } 847 } 848 } 849 #pragma omp sections 850 { 851 #pragma omp section 852 { 853 #pragma omp task 854 { 855 bar(); 856 } 857 } 858 } 859 #pragma omp sections 860 { 861 #pragma omp section 862 { 863 #pragma omp taskyield 864 bar(); 865 } 866 } 867 #pragma omp sections 868 { 869 #pragma omp section 870 { 871 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'section' region}} 872 bar(); 873 } 874 } 875 #pragma omp sections 876 { 877 #pragma omp section 878 { 879 #pragma omp taskwait 880 bar(); 881 } 882 } 883 #pragma omp sections 884 { 885 #pragma omp section 886 { 887 #pragma omp flush 888 bar(); 889 } 890 } 891 #pragma omp sections 892 { 893 #pragma omp section 894 { 895 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 896 bar(); 897 } 898 } 899 #pragma omp sections 900 { 901 #pragma omp section 902 #pragma omp atomic 903 ++a; 904 } 905 #pragma omp sections 906 { 907 #pragma omp section 908 #pragma omp target 909 ++a; 910 } 911 #pragma omp sections 912 { 913 #pragma omp section 914 #pragma omp teams // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 915 ++a; 916 } 917 #pragma omp sections 918 { 919 #pragma omp section 920 #pragma omp taskloop 921 for (int i = 0; i < 10; ++i) 922 ++a; 923 } 924 #pragma omp sections 925 { 926 #pragma omp section 927 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 928 for (int i = 0; i < 10; ++i) 929 ; 930 } 931 932 // SINGLE DIRECTIVE 933 #pragma omp single 934 { 935 #pragma omp for // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 936 for (int i = 0; i < 10; ++i) 937 ; 938 } 939 #pragma omp single 940 { 941 #pragma omp simd 942 for (int i = 0; i < 10; ++i) 943 ; 944 } 945 #pragma omp single 946 { 947 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 948 for (int i = 0; i < 10; ++i) 949 ; 950 } 951 #pragma omp single 952 { 953 #pragma omp parallel 954 for (int i = 0; i < 10; ++i) 955 ; 956 } 957 #pragma omp single 958 { 959 #pragma omp single // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 960 { 961 bar(); 962 } 963 } 964 #pragma omp single 965 { 966 #pragma omp master // expected-error {{region cannot be closely nested inside 'single' region}} 967 { 968 bar(); 969 } 970 } 971 #pragma omp single 972 { 973 #pragma omp critical 974 { 975 bar(); 976 } 977 } 978 #pragma omp single 979 { 980 #pragma omp sections // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 981 { 982 bar(); 983 } 984 } 985 #pragma omp single 986 { 987 #pragma omp parallel 988 { 989 #pragma omp single // OK 990 { 991 bar(); 992 } 993 #pragma omp for // OK 994 for (int i = 0; i < 10; ++i) 995 ; 996 #pragma omp for simd // OK 997 for (int i = 0; i < 10; ++i) 998 ; 999 #pragma omp sections // OK 1000 { 1001 bar(); 1002 } 1003 } 1004 } 1005 #pragma omp single 1006 { 1007 #pragma omp parallel for 1008 for (int i = 0; i < 10; ++i) 1009 ; 1010 } 1011 #pragma omp single 1012 { 1013 #pragma omp parallel for simd 1014 for (int i = 0; i < 10; ++i) 1015 ; 1016 } 1017 #pragma omp single 1018 { 1019 #pragma omp parallel sections 1020 { 1021 bar(); 1022 } 1023 } 1024 #pragma omp single 1025 { 1026 #pragma omp task 1027 { 1028 bar(); 1029 } 1030 } 1031 #pragma omp single 1032 { 1033 #pragma omp taskyield 1034 bar(); 1035 } 1036 #pragma omp single 1037 { 1038 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'single' region}} 1039 bar(); 1040 } 1041 #pragma omp single 1042 { 1043 #pragma omp taskwait 1044 bar(); 1045 } 1046 #pragma omp single 1047 { 1048 #pragma omp flush 1049 bar(); 1050 } 1051 #pragma omp single 1052 { 1053 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 1054 bar(); 1055 } 1056 #pragma omp single 1057 { 1058 #pragma omp atomic 1059 ++a; 1060 } 1061 #pragma omp single 1062 { 1063 #pragma omp target 1064 ++a; 1065 } 1066 #pragma omp single 1067 { 1068 #pragma omp teams // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 1069 ++a; 1070 } 1071 #pragma omp single 1072 { 1073 #pragma omp taskloop 1074 for (int i = 0; i < 10; ++i) 1075 ++a; 1076 } 1077 #pragma omp single 1078 { 1079 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 1080 for (int i = 0; i < 10; ++i) 1081 ; 1082 } 1083 1084 // MASTER DIRECTIVE 1085 #pragma omp master 1086 { 1087 #pragma omp for // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 1088 for (int i = 0; i < 10; ++i) 1089 ; 1090 } 1091 #pragma omp master 1092 { 1093 #pragma omp simd 1094 for (int i = 0; i < 10; ++i) 1095 ; 1096 } 1097 #pragma omp master 1098 { 1099 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 1100 for (int i = 0; i < 10; ++i) 1101 ; 1102 } 1103 #pragma omp master 1104 { 1105 #pragma omp parallel 1106 for (int i = 0; i < 10; ++i) 1107 ; 1108 } 1109 #pragma omp master 1110 { 1111 #pragma omp single // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 1112 { 1113 bar(); 1114 } 1115 } 1116 #pragma omp master 1117 { 1118 #pragma omp master // OK, though second 'master' is redundant 1119 { 1120 bar(); 1121 } 1122 } 1123 #pragma omp master 1124 { 1125 #pragma omp critical 1126 { 1127 bar(); 1128 } 1129 } 1130 #pragma omp master 1131 { 1132 #pragma omp sections // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 1133 { 1134 bar(); 1135 } 1136 } 1137 #pragma omp master 1138 { 1139 #pragma omp parallel 1140 { 1141 #pragma omp master // OK 1142 { 1143 bar(); 1144 } 1145 #pragma omp for // OK 1146 for (int i = 0; i < 10; ++i) 1147 ; 1148 #pragma omp for simd // OK 1149 for (int i = 0; i < 10; ++i) 1150 ; 1151 #pragma omp sections // OK 1152 { 1153 bar(); 1154 } 1155 } 1156 } 1157 #pragma omp master 1158 { 1159 #pragma omp parallel for 1160 for (int i = 0; i < 10; ++i) 1161 ; 1162 } 1163 #pragma omp master 1164 { 1165 #pragma omp parallel for simd 1166 for (int i = 0; i < 10; ++i) 1167 ; 1168 } 1169 #pragma omp master 1170 { 1171 #pragma omp parallel sections 1172 { 1173 bar(); 1174 } 1175 } 1176 #pragma omp master 1177 { 1178 #pragma omp task 1179 { 1180 bar(); 1181 } 1182 } 1183 #pragma omp master 1184 { 1185 #pragma omp taskyield 1186 bar(); 1187 } 1188 #pragma omp master 1189 { 1190 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'master' region}} 1191 bar(); 1192 } 1193 #pragma omp master 1194 { 1195 #pragma omp taskwait 1196 bar(); 1197 } 1198 #pragma omp master 1199 { 1200 #pragma omp flush 1201 bar(); 1202 } 1203 #pragma omp master 1204 { 1205 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 1206 bar(); 1207 } 1208 #pragma omp master 1209 { 1210 #pragma omp atomic 1211 ++a; 1212 } 1213 #pragma omp master 1214 { 1215 #pragma omp target 1216 ++a; 1217 } 1218 #pragma omp master 1219 { 1220 #pragma omp teams // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 1221 ++a; 1222 } 1223 #pragma omp master 1224 { 1225 #pragma omp taskloop 1226 for (int i = 0; i < 10; ++i) 1227 ++a; 1228 } 1229 #pragma omp master 1230 { 1231 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 1232 for (int i = 0; i < 10; ++i) 1233 ; 1234 } 1235 1236 // CRITICAL DIRECTIVE 1237 #pragma omp critical 1238 { 1239 #pragma omp for // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 1240 for (int i = 0; i < 10; ++i) 1241 ; 1242 } 1243 #pragma omp critical 1244 { 1245 #pragma omp simd 1246 for (int i = 0; i < 10; ++i) 1247 ; 1248 } 1249 #pragma omp critical 1250 { 1251 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 1252 for (int i = 0; i < 10; ++i) 1253 ; 1254 } 1255 #pragma omp critical 1256 { 1257 #pragma omp parallel 1258 for (int i = 0; i < 10; ++i) 1259 ; 1260 } 1261 #pragma omp critical 1262 { 1263 #pragma omp single // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 1264 { 1265 bar(); 1266 } 1267 } 1268 #pragma omp critical 1269 { 1270 #pragma omp master // OK, though second 'master' is redundant 1271 { 1272 bar(); 1273 } 1274 } 1275 #pragma omp critical 1276 { 1277 #pragma omp critical 1278 { 1279 bar(); 1280 } 1281 } 1282 #pragma omp critical 1283 { 1284 #pragma omp sections // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 1285 { 1286 bar(); 1287 } 1288 } 1289 #pragma omp critical 1290 { 1291 #pragma omp parallel 1292 { 1293 #pragma omp master // OK 1294 { 1295 bar(); 1296 } 1297 #pragma omp for // OK 1298 for (int i = 0; i < 10; ++i) 1299 ; 1300 #pragma omp for simd // OK 1301 for (int i = 0; i < 10; ++i) 1302 ; 1303 #pragma omp sections // OK 1304 { 1305 bar(); 1306 } 1307 } 1308 } 1309 #pragma omp critical 1310 { 1311 #pragma omp parallel for 1312 for (int i = 0; i < 10; ++i) 1313 ; 1314 } 1315 #pragma omp critical 1316 { 1317 #pragma omp parallel for simd 1318 for (int i = 0; i < 10; ++i) 1319 ; 1320 } 1321 #pragma omp critical 1322 { 1323 #pragma omp parallel sections 1324 { 1325 bar(); 1326 } 1327 } 1328 #pragma omp critical 1329 { 1330 #pragma omp task 1331 { 1332 bar(); 1333 } 1334 } 1335 #pragma omp critical 1336 { 1337 #pragma omp taskyield 1338 bar(); 1339 } 1340 #pragma omp critical 1341 { 1342 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'critical' region}} 1343 bar(); 1344 } 1345 #pragma omp critical 1346 { 1347 #pragma omp taskwait 1348 bar(); 1349 } 1350 #pragma omp critical(Tuzik) 1351 { 1352 #pragma omp critical(grelka) 1353 bar(); 1354 } 1355 #pragma omp critical(Belka) // expected-note {{previous 'critical' region starts here}} 1356 { 1357 #pragma omp critical(Belka) // expected-error {{cannot nest 'critical' regions having the same name 'Belka'}} 1358 { 1359 #pragma omp critical(Tuzik) 1360 { 1361 #pragma omp parallel 1362 #pragma omp critical(grelka) 1363 { 1364 bar(); 1365 } 1366 } 1367 } 1368 } 1369 #pragma omp critical 1370 { 1371 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 1372 bar(); 1373 } 1374 #pragma omp critical 1375 { 1376 #pragma omp atomic 1377 ++a; 1378 } 1379 #pragma omp critical 1380 { 1381 #pragma omp target 1382 ++a; 1383 } 1384 #pragma omp critical 1385 { 1386 #pragma omp teams // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 1387 ++a; 1388 } 1389 #pragma omp critical 1390 { 1391 #pragma omp taskloop 1392 for (int i = 0; i < 10; ++i) 1393 ++a; 1394 } 1395 #pragma omp critical 1396 { 1397 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 1398 for (int i = 0; i < 10; ++i) 1399 ; 1400 } 1401 1402 // PARALLEL FOR DIRECTIVE 1403 #pragma omp parallel for 1404 for (int i = 0; i < 10; ++i) { 1405 #pragma omp for // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 1406 for (int i = 0; i < 10; ++i) 1407 ; 1408 } 1409 #pragma omp parallel for 1410 for (int i = 0; i < 10; ++i) { 1411 #pragma omp simd 1412 for (int i = 0; i < 10; ++i) 1413 ; 1414 } 1415 #pragma omp parallel for 1416 for (int i = 0; i < 10; ++i) { 1417 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 1418 for (int i = 0; i < 10; ++i) 1419 ; 1420 } 1421 #pragma omp parallel for 1422 for (int i = 0; i < 10; ++i) { 1423 #pragma omp parallel 1424 for (int i = 0; i < 10; ++i) 1425 ; 1426 } 1427 #pragma omp parallel for 1428 for (int i = 0; i < 10; ++i) { 1429 #pragma omp sections // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 1430 { 1431 bar(); 1432 } 1433 } 1434 #pragma omp parallel for 1435 for (int i = 0; i < 10; ++i) { 1436 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a parallel for region}} 1437 { 1438 bar(); 1439 } 1440 } 1441 #pragma omp parallel for 1442 for (int i = 0; i < 10; ++i) { 1443 #pragma omp single // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 1444 { 1445 bar(); 1446 } 1447 } 1448 1449 #pragma omp parallel for 1450 for (int i = 0; i < 10; ++i) { 1451 #pragma omp master // expected-error {{region cannot be closely nested inside 'parallel for' region}} 1452 { 1453 bar(); 1454 } 1455 } 1456 1457 #pragma omp parallel for 1458 for (int i = 0; i < 10; ++i) { 1459 #pragma omp critical 1460 { 1461 bar(); 1462 } 1463 } 1464 1465 #pragma omp parallel for 1466 for (int i = 0; i < 10; ++i) { 1467 #pragma omp parallel 1468 { 1469 #pragma omp single // OK 1470 { 1471 bar(); 1472 } 1473 #pragma omp for // OK 1474 for (int i = 0; i < 10; ++i) 1475 ; 1476 #pragma omp for simd // OK 1477 for (int i = 0; i < 10; ++i) 1478 ; 1479 #pragma omp sections // OK 1480 { 1481 bar(); 1482 } 1483 } 1484 } 1485 #pragma omp parallel for 1486 for (int i = 0; i < 10; ++i) { 1487 #pragma omp parallel for 1488 for (int i = 0; i < 10; ++i) 1489 ; 1490 } 1491 #pragma omp parallel for 1492 for (int i = 0; i < 10; ++i) { 1493 #pragma omp parallel for simd 1494 for (int i = 0; i < 10; ++i) 1495 ; 1496 } 1497 #pragma omp parallel for 1498 for (int i = 0; i < 10; ++i) { 1499 #pragma omp parallel sections 1500 { 1501 bar(); 1502 } 1503 } 1504 #pragma omp parallel for 1505 for (int i = 0; i < 10; ++i) { 1506 #pragma omp task 1507 { 1508 bar(); 1509 } 1510 } 1511 #pragma omp parallel for 1512 for (int i = 0; i < 10; ++i) { 1513 #pragma omp taskyield 1514 bar(); 1515 } 1516 #pragma omp parallel for 1517 for (int i = 0; i < 10; ++i) { 1518 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel for' region}} 1519 bar(); 1520 } 1521 #pragma omp parallel for 1522 for (int i = 0; i < 10; ++i) { 1523 #pragma omp taskwait 1524 bar(); 1525 } 1526 #pragma omp parallel for 1527 for (int i = 0; i < 10; ++i) { 1528 #pragma omp flush 1529 bar(); 1530 } 1531 #pragma omp parallel for 1532 for (int i = 0; i < 10; ++i) { 1533 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 1534 bar(); 1535 } 1536 #pragma omp parallel for ordered 1537 for (int i = 0; i < 10; ++i) { 1538 #pragma omp ordered // OK 1539 bar(); 1540 } 1541 #pragma omp parallel for 1542 for (int i = 0; i < 10; ++i) { 1543 #pragma omp atomic 1544 ++a; 1545 } 1546 #pragma omp parallel for 1547 for (int i = 0; i < 10; ++i) { 1548 #pragma omp target 1549 ++a; 1550 } 1551 #pragma omp parallel for 1552 for (int i = 0; i < 10; ++i) { 1553 #pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 1554 ++a; 1555 } 1556 #pragma omp parallel for 1557 for (int i = 0; i < 10; ++i) { 1558 #pragma omp taskloop 1559 for (int i = 0; i < 10; ++i) 1560 ++a; 1561 } 1562 #pragma omp parallel for 1563 for (int i = 0; i < 10; ++i) { 1564 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 1565 for (int j = 0; j < 10; ++j) 1566 ; 1567 } 1568 1569 // PARALLEL FOR SIMD DIRECTIVE 1570 #pragma omp parallel for simd 1571 for (int i = 0; i < 10; ++i) { 1572 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1573 for (int i = 0; i < 10; ++i) 1574 ; 1575 } 1576 #pragma omp parallel for simd 1577 for (int i = 0; i < 10; ++i) { 1578 #pragma omp simd// expected-error {{OpenMP constructs may not be nested inside a simd region}} 1579 for (int i = 0; i < 10; ++i) 1580 ; 1581 } 1582 #pragma omp parallel for simd 1583 for (int i = 0; i < 10; ++i) { 1584 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1585 for (int i = 0; i < 10; ++i) 1586 ; 1587 } 1588 #pragma omp parallel for simd 1589 for (int i = 0; i < 10; ++i) { 1590 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1591 for (int i = 0; i < 10; ++i) 1592 ; 1593 } 1594 #pragma omp parallel for simd 1595 for (int i = 0; i < 10; ++i) { 1596 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1597 { 1598 bar(); 1599 } 1600 } 1601 #pragma omp parallel for simd 1602 for (int i = 0; i < 10; ++i) { 1603 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1604 { 1605 bar(); 1606 } 1607 } 1608 #pragma omp parallel for simd 1609 for (int i = 0; i < 10; ++i) { 1610 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1611 { 1612 bar(); 1613 } 1614 } 1615 1616 #pragma omp parallel for simd 1617 for (int i = 0; i < 10; ++i) { 1618 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1619 { 1620 bar(); 1621 } 1622 } 1623 1624 #pragma omp parallel for simd 1625 for (int i = 0; i < 10; ++i) { 1626 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1627 { 1628 bar(); 1629 } 1630 } 1631 1632 #pragma omp parallel for simd 1633 for (int i = 0; i < 10; ++i) { 1634 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1635 { 1636 #pragma omp single 1637 { 1638 bar(); 1639 } 1640 #pragma omp for 1641 for (int i = 0; i < 10; ++i) 1642 ; 1643 #pragma omp for simd 1644 for (int i = 0; i < 10; ++i) 1645 ; 1646 #pragma omp sections 1647 { 1648 bar(); 1649 } 1650 } 1651 } 1652 #pragma omp parallel for simd 1653 for (int i = 0; i < 10; ++i) { 1654 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1655 for (int i = 0; i < 10; ++i) 1656 ; 1657 } 1658 #pragma omp parallel for simd 1659 for (int i = 0; i < 10; ++i) { 1660 #pragma omp parallel for simd// expected-error {{OpenMP constructs may not be nested inside a simd region}} 1661 for (int i = 0; i < 10; ++i) 1662 ; 1663 } 1664 #pragma omp parallel for simd 1665 for (int i = 0; i < 10; ++i) { 1666 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1667 { 1668 bar(); 1669 } 1670 } 1671 #pragma omp parallel for simd 1672 for (int i = 0; i < 10; ++i) { 1673 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1674 { 1675 bar(); 1676 } 1677 } 1678 #pragma omp parallel for simd 1679 for (int i = 0; i < 10; ++i) { 1680 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1681 bar(); 1682 } 1683 #pragma omp parallel for simd 1684 for (int i = 0; i < 10; ++i) { 1685 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1686 bar(); 1687 } 1688 #pragma omp parallel for simd 1689 for (int i = 0; i < 10; ++i) { 1690 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1691 bar(); 1692 } 1693 #pragma omp parallel for simd 1694 for (int i = 0; i < 10; ++i) { 1695 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1696 bar(); 1697 } 1698 #pragma omp parallel for simd 1699 for (int i = 0; i < 10; ++i) { 1700 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1701 bar(); 1702 } 1703 #pragma omp parallel for simd 1704 for (int i = 0; i < 10; ++i) { 1705 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1706 bar(); 1707 } 1708 #pragma omp parallel for simd 1709 for (int i = 0; i < 10; ++i) { 1710 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1711 ++a; 1712 } 1713 #pragma omp parallel for simd 1714 for (int i = 0; i < 10; ++i) { 1715 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1716 ++a; 1717 } 1718 #pragma omp parallel for simd 1719 for (int i = 0; i < 10; ++i) { 1720 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1721 ++a; 1722 } 1723 #pragma omp parallel for simd 1724 for (int i = 0; i < 10; ++i) { 1725 #pragma omp taskloop // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1726 for (int i = 0; i < 10; ++i) 1727 ++a; 1728 } 1729 #pragma omp parallel for simd 1730 for (int i = 0; i < 10; ++i) { 1731 #pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} 1732 for (int j = 0; j < 10; ++j) 1733 ; 1734 } 1735 1736 // PARALLEL SECTIONS DIRECTIVE 1737 #pragma omp parallel sections 1738 { 1739 #pragma omp for // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 1740 for (int i = 0; i < 10; ++i) 1741 ; 1742 } 1743 #pragma omp parallel sections 1744 { 1745 #pragma omp simd 1746 for (int i = 0; i < 10; ++i) 1747 ; 1748 } 1749 #pragma omp parallel sections 1750 { 1751 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 1752 for (int i = 0; i < 10; ++i) 1753 ; 1754 } 1755 #pragma omp parallel sections 1756 { 1757 #pragma omp parallel 1758 for (int i = 0; i < 10; ++i) 1759 ; 1760 } 1761 #pragma omp parallel sections 1762 { 1763 #pragma omp sections // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 1764 { 1765 bar(); 1766 } 1767 } 1768 #pragma omp parallel sections 1769 { 1770 #pragma omp section 1771 { 1772 bar(); 1773 } 1774 } 1775 #pragma omp parallel sections 1776 { 1777 #pragma omp section 1778 { 1779 #pragma omp single // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 1780 bar(); 1781 } 1782 } 1783 #pragma omp parallel sections 1784 { 1785 #pragma omp section 1786 { 1787 #pragma omp master // expected-error {{region cannot be closely nested inside 'section' region}} 1788 bar(); 1789 } 1790 } 1791 #pragma omp parallel sections 1792 { 1793 #pragma omp section 1794 { 1795 #pragma omp critical 1796 bar(); 1797 } 1798 } 1799 #pragma omp parallel sections 1800 { 1801 #pragma omp parallel 1802 { 1803 #pragma omp single // OK 1804 { 1805 bar(); 1806 } 1807 #pragma omp for // OK 1808 for (int i = 0; i < 10; ++i) 1809 ; 1810 #pragma omp for simd // OK 1811 for (int i = 0; i < 10; ++i) 1812 ; 1813 #pragma omp sections // OK 1814 { 1815 bar(); 1816 } 1817 } 1818 } 1819 #pragma omp parallel sections 1820 { 1821 #pragma omp parallel for 1822 for (int i = 0; i < 10; ++i) 1823 ; 1824 } 1825 #pragma omp parallel sections 1826 { 1827 #pragma omp parallel for simd 1828 for (int i = 0; i < 10; ++i) 1829 ; 1830 } 1831 #pragma omp parallel sections 1832 { 1833 #pragma omp parallel sections 1834 { 1835 bar(); 1836 } 1837 } 1838 #pragma omp parallel sections 1839 { 1840 #pragma omp task 1841 { 1842 bar(); 1843 } 1844 } 1845 #pragma omp parallel sections 1846 { 1847 #pragma omp taskyield 1848 } 1849 #pragma omp parallel sections 1850 { 1851 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel sections' region}} 1852 } 1853 #pragma omp parallel sections 1854 { 1855 #pragma omp taskwait 1856 } 1857 #pragma omp parallel sections 1858 { 1859 #pragma omp flush 1860 } 1861 #pragma omp parallel sections 1862 { 1863 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 1864 bar(); 1865 } 1866 #pragma omp parallel sections 1867 { 1868 #pragma omp atomic 1869 ++a; 1870 } 1871 #pragma omp parallel sections 1872 { 1873 #pragma omp target 1874 ++a; 1875 } 1876 #pragma omp parallel sections 1877 { 1878 #pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 1879 ++a; 1880 } 1881 #pragma omp parallel sections 1882 { 1883 #pragma omp taskloop 1884 for (int i = 0; i < 10; ++i) 1885 ++a; 1886 } 1887 #pragma omp parallel sections 1888 { 1889 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 1890 for (int i = 0; i < 10; ++i) 1891 ; 1892 } 1893 1894 // TASK DIRECTIVE 1895 #pragma omp task 1896 #pragma omp for // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 1897 for (int i = 0; i < 10; ++i) 1898 ; 1899 #pragma omp task 1900 #pragma omp simd 1901 for (int i = 0; i < 10; ++i) 1902 ; 1903 #pragma omp task 1904 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 1905 for (int i = 0; i < 10; ++i) 1906 ; 1907 #pragma omp task 1908 #pragma omp sections // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 1909 { 1910 bar(); 1911 } 1912 #pragma omp task 1913 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a task region}} 1914 { 1915 bar(); 1916 } 1917 #pragma omp task 1918 #pragma omp single // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 1919 bar(); 1920 #pragma omp task 1921 #pragma omp master // expected-error {{region cannot be closely nested inside 'task' region}} 1922 bar(); 1923 #pragma omp task 1924 #pragma omp critical 1925 bar(); 1926 1927 #pragma omp task 1928 #pragma omp parallel for 1929 for (int i = 0; i < 10; ++i) 1930 ; 1931 #pragma omp task 1932 #pragma omp parallel for simd 1933 for (int i = 0; i < 10; ++i) 1934 ; 1935 #pragma omp task 1936 #pragma omp parallel sections 1937 { 1938 bar(); 1939 } 1940 #pragma omp task 1941 #pragma omp task 1942 { 1943 bar(); 1944 } 1945 #pragma omp task 1946 { 1947 #pragma omp taskyield 1948 bar(); 1949 } 1950 #pragma omp task 1951 { 1952 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'task' region}} 1953 bar(); 1954 } 1955 #pragma omp task 1956 { 1957 #pragma omp taskwait 1958 bar(); 1959 } 1960 #pragma omp task 1961 { 1962 #pragma omp flush 1963 bar(); 1964 } 1965 #pragma omp task 1966 { 1967 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 1968 bar(); 1969 } 1970 #pragma omp task 1971 { 1972 #pragma omp atomic 1973 ++a; 1974 } 1975 #pragma omp task 1976 { 1977 #pragma omp target 1978 ++a; 1979 } 1980 #pragma omp task 1981 { 1982 #pragma omp teams // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 1983 ++a; 1984 } 1985 #pragma omp task 1986 { 1987 #pragma omp taskloop 1988 for (int i = 0; i < 10; ++i) 1989 ++a; 1990 } 1991 #pragma omp task 1992 { 1993 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 1994 for (int i = 0; i < 10; ++i) 1995 ; 1996 } 1997 1998 // ORDERED DIRECTIVE 1999 #pragma omp ordered 2000 { 2001 #pragma omp for // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 2002 for (int i = 0; i < 10; ++i) 2003 ; 2004 } 2005 #pragma omp ordered 2006 { 2007 #pragma omp simd 2008 for (int i = 0; i < 10; ++i) 2009 ; 2010 } 2011 #pragma omp ordered 2012 { 2013 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 2014 for (int i = 0; i < 10; ++i) 2015 ; 2016 } 2017 #pragma omp ordered 2018 { 2019 #pragma omp parallel 2020 for (int i = 0; i < 10; ++i) 2021 ; 2022 } 2023 #pragma omp ordered 2024 { 2025 #pragma omp single // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 2026 { 2027 bar(); 2028 } 2029 } 2030 #pragma omp ordered 2031 { 2032 #pragma omp master // OK, though second 'ordered' is redundant 2033 { 2034 bar(); 2035 } 2036 } 2037 #pragma omp ordered 2038 { 2039 #pragma omp critical 2040 { 2041 bar(); 2042 } 2043 } 2044 #pragma omp ordered 2045 { 2046 #pragma omp sections // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 2047 { 2048 bar(); 2049 } 2050 } 2051 #pragma omp ordered 2052 { 2053 #pragma omp parallel for ordered 2054 for (int j = 0; j < 10; ++j) { 2055 #pragma omp ordered // OK 2056 { 2057 bar(); 2058 } 2059 } 2060 } 2061 #pragma omp ordered 2062 { 2063 #pragma omp parallel for simd ordered //expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp parallel for simd'}} 2064 for (int j = 0; j < 10; ++j) { 2065 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} 2066 { 2067 bar(); 2068 } 2069 } 2070 } 2071 #pragma omp ordered 2072 { 2073 #pragma omp parallel for 2074 for (int i = 0; i < 10; ++i) 2075 ; 2076 } 2077 #pragma omp ordered 2078 { 2079 #pragma omp parallel for simd 2080 for (int i = 0; i < 10; ++i) 2081 ; 2082 } 2083 #pragma omp ordered 2084 { 2085 #pragma omp parallel sections 2086 { 2087 bar(); 2088 } 2089 } 2090 #pragma omp ordered 2091 { 2092 #pragma omp task 2093 { 2094 bar(); 2095 } 2096 } 2097 #pragma omp ordered 2098 { 2099 #pragma omp taskyield 2100 bar(); 2101 } 2102 #pragma omp ordered 2103 { 2104 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'ordered' region}} 2105 bar(); 2106 } 2107 #pragma omp ordered 2108 { 2109 #pragma omp taskwait 2110 bar(); 2111 } 2112 #pragma omp ordered 2113 { 2114 #pragma omp flush 2115 bar(); 2116 } 2117 #pragma omp ordered 2118 { 2119 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 2120 bar(); 2121 } 2122 #pragma omp ordered 2123 { 2124 #pragma omp atomic 2125 ++a; 2126 } 2127 #pragma omp ordered 2128 { 2129 #pragma omp target 2130 ++a; 2131 } 2132 #pragma omp ordered 2133 { 2134 #pragma omp teams // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 2135 ++a; 2136 } 2137 #pragma omp ordered 2138 { 2139 #pragma omp taskloop 2140 for (int i = 0; i < 10; ++i) 2141 ++a; 2142 } 2143 #pragma omp ordered 2144 { 2145 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'ordered' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 2146 for (int i = 0; i < 10; ++i) 2147 ; 2148 } 2149 2150 // ATOMIC DIRECTIVE 2151 #pragma omp atomic 2152 // 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}} 2153 // expected-note@+1 {{expected an expression statement}} 2154 { 2155 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2156 for (int i = 0; i < 10; ++i) 2157 ; 2158 } 2159 #pragma omp atomic 2160 // 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}} 2161 // expected-note@+1 {{expected an expression statement}} 2162 { 2163 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2164 for (int i = 0; i < 10; ++i) 2165 ; 2166 } 2167 #pragma omp atomic 2168 // 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}} 2169 // expected-note@+1 {{expected an expression statement}} 2170 { 2171 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2172 for (int i = 0; i < 10; ++i) 2173 ; 2174 } 2175 #pragma omp atomic 2176 // 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}} 2177 // expected-note@+1 {{expected an expression statement}} 2178 { 2179 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2180 for (int i = 0; i < 10; ++i) 2181 ; 2182 } 2183 #pragma omp atomic 2184 // 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}} 2185 // expected-note@+1 {{expected an expression statement}} 2186 { 2187 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2188 { 2189 bar(); 2190 } 2191 } 2192 #pragma omp atomic 2193 // 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}} 2194 // expected-note@+1 {{expected an expression statement}} 2195 { 2196 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2197 { 2198 bar(); 2199 } 2200 } 2201 #pragma omp atomic 2202 // 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}} 2203 // expected-note@+1 {{expected an expression statement}} 2204 { 2205 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2206 { 2207 bar(); 2208 } 2209 } 2210 #pragma omp atomic 2211 // 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}} 2212 // expected-note@+1 {{expected an expression statement}} 2213 { 2214 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2215 { 2216 bar(); 2217 } 2218 } 2219 #pragma omp atomic 2220 // 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}} 2221 // expected-note@+1 {{expected an expression statement}} 2222 { 2223 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2224 { 2225 bar(); 2226 } 2227 } 2228 #pragma omp atomic 2229 // 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}} 2230 // expected-note@+1 {{expected an expression statement}} 2231 { 2232 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2233 for (int i = 0; i < 10; ++i) 2234 ; 2235 } 2236 #pragma omp atomic 2237 // 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}} 2238 // expected-note@+1 {{expected an expression statement}} 2239 { 2240 #pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2241 for (int i = 0; i < 10; ++i) 2242 ; 2243 } 2244 #pragma omp atomic 2245 // 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}} 2246 // expected-note@+1 {{expected an expression statement}} 2247 { 2248 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2249 { 2250 bar(); 2251 } 2252 } 2253 #pragma omp atomic 2254 // 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}} 2255 // expected-note@+1 {{expected an expression statement}} 2256 { 2257 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2258 { 2259 bar(); 2260 } 2261 } 2262 #pragma omp atomic 2263 // 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}} 2264 // expected-note@+1 {{expected an expression statement}} 2265 { 2266 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2267 bar(); 2268 } 2269 #pragma omp atomic 2270 // 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}} 2271 // expected-note@+1 {{expected an expression statement}} 2272 { 2273 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2274 bar(); 2275 } 2276 #pragma omp atomic 2277 // 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}} 2278 // expected-note@+1 {{expected an expression statement}} 2279 { 2280 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2281 bar(); 2282 } 2283 #pragma omp atomic 2284 // 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}} 2285 // expected-note@+1 {{expected an expression statement}} 2286 { 2287 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2288 bar(); 2289 } 2290 #pragma omp atomic 2291 // 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}} 2292 // expected-note@+1 {{expected an expression statement}} 2293 { 2294 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2295 bar(); 2296 } 2297 #pragma omp atomic 2298 // 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}} 2299 // expected-note@+1 {{expected an expression statement}} 2300 { 2301 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2302 ++a; 2303 } 2304 #pragma omp atomic 2305 // 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}} 2306 // expected-note@+1 {{expected an expression statement}} 2307 { 2308 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2309 ++a; 2310 } 2311 #pragma omp atomic 2312 // 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}} 2313 // expected-note@+1 {{expected an expression statement}} 2314 { 2315 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2316 ++a; 2317 } 2318 #pragma omp atomic 2319 // 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}} 2320 // expected-note@+1 {{expected an expression statement}} 2321 { 2322 #pragma omp taskloop // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2323 for (int i = 0; i < 10; ++i) 2324 ++a; 2325 } 2326 #pragma omp atomic 2327 // 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}} 2328 // expected-note@+1 {{expected an expression statement}} 2329 { 2330 #pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 2331 for (int i = 0; i < 10; ++i) 2332 ; 2333 } 2334 2335 // TARGET DIRECTIVE 2336 #pragma omp target 2337 #pragma omp parallel 2338 bar(); 2339 #pragma omp target 2340 #pragma omp for 2341 for (int i = 0; i < 10; ++i) 2342 ; 2343 #pragma omp target 2344 #pragma omp simd 2345 for (int i = 0; i < 10; ++i) 2346 ; 2347 #pragma omp target 2348 #pragma omp for simd 2349 for (int i = 0; i < 10; ++i) 2350 ; 2351 #pragma omp target 2352 #pragma omp sections 2353 { 2354 bar(); 2355 } 2356 #pragma omp target 2357 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a target region}} 2358 { 2359 bar(); 2360 } 2361 #pragma omp target 2362 #pragma omp single 2363 bar(); 2364 2365 #pragma omp target 2366 #pragma omp master 2367 { 2368 bar(); 2369 } 2370 #pragma omp target 2371 #pragma omp critical 2372 { 2373 bar(); 2374 } 2375 #pragma omp target 2376 #pragma omp parallel for 2377 for (int i = 0; i < 10; ++i) 2378 ; 2379 #pragma omp target 2380 #pragma omp parallel for simd 2381 for (int i = 0; i < 10; ++i) 2382 ; 2383 #pragma omp target 2384 #pragma omp parallel sections 2385 { 2386 bar(); 2387 } 2388 #pragma omp target 2389 #pragma omp task 2390 { 2391 bar(); 2392 } 2393 #pragma omp target 2394 { 2395 #pragma omp taskyield 2396 bar(); 2397 } 2398 #pragma omp target 2399 { 2400 #pragma omp barrier 2401 bar(); 2402 } 2403 #pragma omp target 2404 { 2405 #pragma omp taskwait 2406 bar(); 2407 } 2408 #pragma omp target 2409 { 2410 #pragma omp flush 2411 bar(); 2412 } 2413 #pragma omp target 2414 { 2415 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'target' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 2416 bar(); 2417 } 2418 #pragma omp target 2419 { 2420 #pragma omp atomic 2421 ++a; 2422 } 2423 #pragma omp target 2424 { 2425 #pragma omp target 2426 ++a; 2427 } 2428 #pragma omp target 2429 { 2430 #pragma omp teams 2431 ++a; 2432 } 2433 #pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}} 2434 { 2435 ++a; // expected-note {{statement outside teams construct here}} 2436 #pragma omp teams // expected-note {{nested teams construct here}} 2437 ++a; 2438 } 2439 #pragma omp target 2440 { 2441 #pragma omp taskloop 2442 for (int i = 0; i < 10; ++i) 2443 ++a; 2444 } 2445 #pragma omp target 2446 { 2447 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'target' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 2448 for (int i = 0; i < 10; ++i) 2449 ; 2450 } 2451 2452 // TEAMS DIRECTIVE 2453 #pragma omp target 2454 #pragma omp teams 2455 #pragma omp parallel 2456 bar(); 2457 #pragma omp target 2458 #pragma omp teams 2459 #pragma omp for // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 2460 for (int i = 0; i < 10; ++i) 2461 ; 2462 #pragma omp target 2463 #pragma omp teams 2464 #pragma omp simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp simd' directive into a parallel region?}} 2465 for (int i = 0; i < 10; ++i) 2466 ; 2467 #pragma omp target 2468 #pragma omp teams 2469 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 2470 for (int i = 0; i < 10; ++i) 2471 ; 2472 #pragma omp target 2473 #pragma omp teams 2474 #pragma omp sections // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 2475 { 2476 bar(); 2477 } 2478 #pragma omp target 2479 #pragma omp teams 2480 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a teams region}} 2481 { 2482 bar(); 2483 } 2484 #pragma omp target 2485 #pragma omp teams 2486 #pragma omp single // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 2487 bar(); 2488 2489 #pragma omp target 2490 #pragma omp teams 2491 #pragma omp master // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp master' directive into a parallel region?}} 2492 { 2493 bar(); 2494 } 2495 #pragma omp target 2496 #pragma omp teams 2497 #pragma omp critical // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp critical' directive into a parallel region?}} 2498 { 2499 bar(); 2500 } 2501 #pragma omp target 2502 #pragma omp teams 2503 #pragma omp parallel for 2504 for (int i = 0; i < 10; ++i) 2505 ; 2506 #pragma omp target 2507 #pragma omp teams 2508 #pragma omp parallel for simd 2509 for (int i = 0; i < 10; ++i) 2510 ; 2511 #pragma omp target 2512 #pragma omp teams 2513 #pragma omp parallel sections 2514 { 2515 bar(); 2516 } 2517 #pragma omp target 2518 #pragma omp teams 2519 #pragma omp task // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp task' directive into a parallel region?}} 2520 { 2521 bar(); 2522 } 2523 #pragma omp target 2524 #pragma omp teams 2525 { 2526 #pragma omp taskyield // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskyield' directive into a parallel region?}} 2527 bar(); 2528 } 2529 #pragma omp target 2530 #pragma omp teams 2531 { 2532 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp barrier' directive into a parallel region?}} 2533 bar(); 2534 } 2535 #pragma omp target 2536 #pragma omp teams 2537 { 2538 #pragma omp taskwait // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskwait' directive into a parallel region?}} 2539 bar(); 2540 } 2541 #pragma omp target 2542 #pragma omp teams 2543 { 2544 #pragma omp flush // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp flush' directive into a parallel region?}} 2545 bar(); 2546 } 2547 #pragma omp target 2548 #pragma omp teams 2549 { 2550 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 2551 bar(); 2552 } 2553 #pragma omp target 2554 #pragma omp teams 2555 { 2556 #pragma omp atomic // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp atomic' directive into a parallel region?}} 2557 ++a; 2558 } 2559 #pragma omp target 2560 #pragma omp teams 2561 { 2562 #pragma omp target // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp target' directive into a parallel region?}} 2563 ++a; 2564 } 2565 #pragma omp target 2566 #pragma omp teams 2567 { 2568 #pragma omp teams // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 2569 ++a; 2570 } 2571 #pragma omp target 2572 #pragma omp teams 2573 { 2574 #pragma omp taskloop // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskloop' directive into a parallel region?}} 2575 for (int i = 0; i < 10; ++i) 2576 ++a; 2577 } 2578 #pragma omp target 2579 #pragma omp teams 2580 #pragma omp distribute 2581 for (int i = 0; i < 10; ++i) 2582 ; 2583 #pragma omp target 2584 #pragma omp teams 2585 #pragma omp distribute 2586 for (int i = 0; i < 10; ++i) 2587 ; 2588 #pragma omp distribute 2589 for (int j = 0; j < 10; ++j) 2590 ; 2591 2592 // TASKLOOP DIRECTIVE 2593 #pragma omp taskloop 2594 for (int i = 0; i < 10; ++i) { 2595 #pragma omp for // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 2596 for (int i = 0; i < 10; ++i) 2597 ; 2598 } 2599 #pragma omp taskloop 2600 for (int i = 0; i < 10; ++i) { 2601 #pragma omp simd 2602 for (int i = 0; i < 10; ++i) 2603 ; 2604 } 2605 #pragma omp taskloop 2606 for (int i = 0; i < 10; ++i) { 2607 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 2608 for (int i = 0; i < 10; ++i) 2609 ; 2610 } 2611 #pragma omp taskloop 2612 for (int i = 0; i < 10; ++i) { 2613 #pragma omp parallel 2614 for (int i = 0; i < 10; ++i) 2615 ; 2616 } 2617 #pragma omp taskloop 2618 for (int i = 0; i < 10; ++i) { 2619 #pragma omp sections // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 2620 { 2621 bar(); 2622 } 2623 } 2624 #pragma omp taskloop 2625 for (int i = 0; i < 10; ++i) { 2626 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a taskloop region}} 2627 { 2628 bar(); 2629 } 2630 } 2631 #pragma omp taskloop 2632 for (int i = 0; i < 10; ++i) { 2633 #pragma omp single // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 2634 { 2635 bar(); 2636 } 2637 } 2638 2639 #pragma omp taskloop 2640 for (int i = 0; i < 10; ++i) { 2641 #pragma omp master // expected-error {{region cannot be closely nested inside 'taskloop' region}} 2642 { 2643 bar(); 2644 } 2645 } 2646 #pragma omp taskloop 2647 for (int i = 0; i < 10; ++i) { 2648 #pragma omp critical 2649 { 2650 bar(); 2651 } 2652 } 2653 #pragma omp taskloop 2654 for (int i = 0; i < 10; ++i) { 2655 #pragma omp parallel 2656 { 2657 #pragma omp single // OK 2658 { 2659 bar(); 2660 } 2661 #pragma omp for // OK 2662 for (int i = 0; i < 10; ++i) 2663 ; 2664 #pragma omp sections // OK 2665 { 2666 bar(); 2667 } 2668 } 2669 } 2670 #pragma omp taskloop 2671 for (int i = 0; i < 10; ++i) { 2672 #pragma omp parallel for 2673 for (int i = 0; i < 10; ++i) 2674 ; 2675 } 2676 #pragma omp taskloop 2677 for (int i = 0; i < 10; ++i) { 2678 #pragma omp parallel for simd 2679 for (int i = 0; i < 10; ++i) 2680 ; 2681 } 2682 #pragma omp taskloop 2683 for (int i = 0; i < 10; ++i) { 2684 #pragma omp parallel sections 2685 { 2686 bar(); 2687 } 2688 } 2689 #pragma omp taskloop 2690 for (int i = 0; i < 10; ++i) { 2691 #pragma omp task 2692 { 2693 bar(); 2694 } 2695 } 2696 #pragma omp taskloop 2697 for (int i = 0; i < 10; ++i) { 2698 #pragma omp taskyield 2699 bar(); 2700 } 2701 #pragma omp taskloop 2702 for (int i = 0; i < 10; ++i) { 2703 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'taskloop' region}} 2704 bar(); 2705 } 2706 #pragma omp taskloop 2707 for (int i = 0; i < 10; ++i) { 2708 #pragma omp taskwait 2709 bar(); 2710 } 2711 #pragma omp taskloop 2712 for (int i = 0; i < 10; ++i) { 2713 #pragma omp flush 2714 bar(); 2715 } 2716 #pragma omp taskloop 2717 for (int i = 0; i < 10; ++i) { 2718 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 2719 bar(); 2720 } 2721 #pragma omp taskloop 2722 for (int i = 0; i < 10; ++i) { 2723 #pragma omp atomic 2724 ++a; 2725 } 2726 #pragma omp taskloop 2727 for (int i = 0; i < 10; ++i) { 2728 #pragma omp target 2729 ++a; 2730 } 2731 #pragma omp taskloop 2732 for (int i = 0; i < 10; ++i) { 2733 #pragma omp teams // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 2734 ++a; 2735 } 2736 #pragma omp taskloop 2737 for (int i = 0; i < 10; ++i) { 2738 #pragma omp taskloop 2739 for (int i = 0; i < 10; ++i) 2740 ++a; 2741 } 2742 // DISTRIBUTE DIRECTIVE 2743 #pragma omp target 2744 #pragma omp teams 2745 #pragma omp distribute 2746 for (int i = 0; i < 10; ++i) { 2747 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'distribute' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 2748 for (int i = 0; i < 10; ++i) 2749 ; 2750 } 2751 #pragma omp target 2752 #pragma omp teams 2753 #pragma omp distribute 2754 for (int i = 0; i < 10; ++i) { 2755 #pragma omp for 2756 for (int i = 0; i < 10; ++i) 2757 ; 2758 } 2759 #pragma omp target 2760 #pragma omp teams 2761 #pragma omp distribute 2762 for (int i = 0; i < 10; ++i) { 2763 #pragma omp simd 2764 for (int i = 0; i < 10; ++i) 2765 ; 2766 } 2767 #pragma omp target 2768 #pragma omp teams 2769 #pragma omp distribute 2770 for (int i = 0; i < 10; ++i) { 2771 #pragma omp for simd 2772 for (int i = 0; i < 10; ++i) 2773 ; 2774 } 2775 #pragma omp target 2776 #pragma omp teams 2777 #pragma omp distribute 2778 for (int i = 0; i < 10; ++i) { 2779 #pragma omp parallel 2780 for (int i = 0; i < 10; ++i) 2781 ; 2782 } 2783 #pragma omp target 2784 #pragma omp teams 2785 #pragma omp distribute 2786 for (int i = 0; i < 10; ++i) { 2787 #pragma omp sections 2788 { 2789 bar(); 2790 } 2791 } 2792 #pragma omp target 2793 #pragma omp teams 2794 #pragma omp distribute 2795 for (int i = 0; i < 10; ++i) { 2796 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a distribute region}} 2797 { 2798 bar(); 2799 } 2800 } 2801 #pragma omp target 2802 #pragma omp teams 2803 #pragma omp distribute 2804 for (int i = 0; i < 10; ++i) { 2805 #pragma omp single 2806 { 2807 bar(); 2808 } 2809 } 2810 #pragma omp target 2811 #pragma omp teams 2812 #pragma omp distribute 2813 for (int i = 0; i < 10; ++i) { 2814 #pragma omp master 2815 { 2816 bar(); 2817 } 2818 } 2819 #pragma omp target 2820 #pragma omp teams 2821 #pragma omp distribute 2822 for (int i = 0; i < 10; ++i) { 2823 #pragma omp critical 2824 { 2825 bar(); 2826 } 2827 } 2828 #pragma omp target 2829 #pragma omp teams 2830 #pragma omp distribute 2831 for (int i = 0; i < 10; ++i) { 2832 #pragma omp parallel 2833 { 2834 #pragma omp single 2835 { 2836 bar(); 2837 } 2838 } 2839 } 2840 #pragma omp target 2841 #pragma omp teams 2842 #pragma omp distribute 2843 for (int i = 0; i < 10; ++i) { 2844 #pragma omp parallel for 2845 for (int i = 0; i < 10; ++i) 2846 ; 2847 } 2848 #pragma omp target 2849 #pragma omp teams 2850 #pragma omp distribute 2851 for (int i = 0; i < 10; ++i) { 2852 #pragma omp parallel for simd 2853 for (int i = 0; i < 10; ++i) 2854 ; 2855 } 2856 #pragma omp target 2857 #pragma omp teams 2858 #pragma omp distribute 2859 for (int i = 0; i < 10; ++i) { 2860 #pragma omp parallel sections 2861 { 2862 bar(); 2863 } 2864 } 2865 #pragma omp target 2866 #pragma omp teams 2867 #pragma omp distribute 2868 for (int i = 0; i < 10; ++i) { 2869 #pragma omp task 2870 { 2871 bar(); 2872 } 2873 } 2874 #pragma omp target 2875 #pragma omp teams 2876 #pragma omp distribute 2877 for (int i = 0; i < 10; ++i) { 2878 #pragma omp taskyield 2879 bar(); 2880 } 2881 #pragma omp target 2882 #pragma omp teams 2883 #pragma omp distribute 2884 for (int i = 0; i < 10; ++i) { 2885 #pragma omp barrier 2886 bar(); 2887 } 2888 #pragma omp target 2889 #pragma omp teams 2890 #pragma omp distribute 2891 for (int i = 0; i < 10; ++i) { 2892 #pragma omp taskwait 2893 bar(); 2894 } 2895 #pragma omp target 2896 #pragma omp teams 2897 #pragma omp distribute 2898 for (int i = 0; i < 10; ++i) { 2899 #pragma omp flush 2900 bar(); 2901 } 2902 #pragma omp target 2903 #pragma omp teams 2904 #pragma omp distribute 2905 for (int i = 0; i < 10; ++i) { 2906 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'distribute' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 2907 bar(); 2908 } 2909 #pragma omp target 2910 #pragma omp teams 2911 #pragma omp distribute 2912 for (int i = 0; i < 10; ++i) { 2913 #pragma omp atomic 2914 ++a; 2915 } 2916 #pragma omp target 2917 #pragma omp teams 2918 #pragma omp distribute 2919 for (int i = 0; i < 10; ++i) { 2920 #pragma omp target 2921 ++a; 2922 } 2923 #pragma omp target 2924 #pragma omp teams 2925 #pragma omp distribute 2926 for (int i = 0; i < 10; ++i) { 2927 #pragma omp teams // expected-error {{region cannot be closely nested inside 'distribute' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 2928 ++a; 2929 } 2930 } 2931 2932 void foo() { 2933 int a = 0; 2934 // PARALLEL DIRECTIVE 2935 #pragma omp parallel 2936 #pragma omp for 2937 for (int i = 0; i < 10; ++i) 2938 ; 2939 #pragma omp parallel 2940 #pragma omp simd 2941 for (int i = 0; i < 10; ++i) 2942 ; 2943 #pragma omp parallel 2944 #pragma omp for simd 2945 for (int i = 0; i < 10; ++i) 2946 ; 2947 #pragma omp parallel 2948 #pragma omp sections 2949 { 2950 bar(); 2951 } 2952 #pragma omp parallel 2953 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a parallel region}} 2954 { 2955 bar(); 2956 } 2957 #pragma omp parallel 2958 #pragma omp sections 2959 { 2960 bar(); 2961 } 2962 #pragma omp parallel 2963 #pragma omp single 2964 bar(); 2965 #pragma omp parallel 2966 #pragma omp master 2967 bar(); 2968 #pragma omp parallel 2969 #pragma omp critical 2970 bar(); 2971 #pragma omp parallel 2972 #pragma omp parallel for 2973 for (int i = 0; i < 10; ++i) 2974 ; 2975 #pragma omp parallel 2976 #pragma omp parallel for simd 2977 for (int i = 0; i < 10; ++i) 2978 ; 2979 #pragma omp parallel 2980 #pragma omp parallel sections 2981 { 2982 bar(); 2983 } 2984 #pragma omp parallel 2985 #pragma omp task 2986 { 2987 bar(); 2988 } 2989 #pragma omp parallel 2990 { 2991 #pragma omp taskyield 2992 bar(); 2993 } 2994 #pragma omp parallel 2995 { 2996 #pragma omp barrier 2997 bar(); 2998 } 2999 #pragma omp parallel 3000 { 3001 #pragma omp taskwait 3002 bar(); 3003 } 3004 #pragma omp parallel 3005 { 3006 #pragma omp flush 3007 bar(); 3008 } 3009 #pragma omp parallel 3010 { 3011 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 3012 bar(); 3013 } 3014 #pragma omp parallel 3015 { 3016 #pragma omp atomic 3017 ++a; 3018 } 3019 #pragma omp parallel 3020 { 3021 #pragma omp target 3022 ++a; 3023 } 3024 #pragma omp parallel 3025 { 3026 #pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 3027 ++a; 3028 } 3029 #pragma omp parallel 3030 { 3031 #pragma omp taskloop 3032 for (int i = 0; i < 10; ++i) 3033 ++a; 3034 } 3035 #pragma omp parallel 3036 { 3037 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'parallel' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 3038 for (int i = 0; i < 10; ++i) 3039 ; 3040 } 3041 3042 // SIMD DIRECTIVE 3043 #pragma omp simd 3044 for (int i = 0; i < 10; ++i) { 3045 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3046 for (int i = 0; i < 10; ++i) 3047 ; 3048 } 3049 #pragma omp simd 3050 for (int i = 0; i < 10; ++i) { 3051 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3052 for (int i = 0; i < 10; ++i) 3053 ; 3054 } 3055 #pragma omp simd 3056 for (int i = 0; i < 10; ++i) { 3057 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3058 for (int i = 0; i < 10; ++i) 3059 ; 3060 } 3061 #pragma omp simd 3062 for (int i = 0; i < 10; ++i) { 3063 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3064 for (int i = 0; i < 10; ++i) 3065 ; 3066 } 3067 #pragma omp simd 3068 for (int i = 0; i < 10; ++i) { 3069 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3070 { 3071 bar(); 3072 } 3073 } 3074 #pragma omp simd 3075 for (int i = 0; i < 10; ++i) { 3076 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3077 { 3078 bar(); 3079 } 3080 } 3081 #pragma omp simd 3082 for (int i = 0; i < 10; ++i) { 3083 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3084 bar(); 3085 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3086 bar(); 3087 } 3088 #pragma omp simd 3089 for (int i = 0; i < 10; ++i) { 3090 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3091 bar(); 3092 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3093 bar(); 3094 } 3095 #pragma omp simd 3096 for (int i = 0; i < 10; ++i) { 3097 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3098 for (int i = 0; i < 10; ++i) 3099 ; 3100 } 3101 #pragma omp simd 3102 for (int i = 0; i < 10; ++i) { 3103 #pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3104 for (int i = 0; i < 10; ++i) 3105 ; 3106 } 3107 #pragma omp simd 3108 for (int i = 0; i < 10; ++i) { 3109 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3110 { 3111 bar(); 3112 } 3113 } 3114 #pragma omp simd 3115 for (int i = 0; i < 10; ++i) { 3116 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3117 { 3118 bar(); 3119 } 3120 } 3121 #pragma omp simd 3122 for (int i = 0; i < 10; ++i) { 3123 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3124 bar(); 3125 } 3126 #pragma omp simd 3127 for (int i = 0; i < 10; ++i) { 3128 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3129 bar(); 3130 } 3131 #pragma omp simd 3132 for (int i = 0; i < 10; ++i) { 3133 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3134 bar(); 3135 } 3136 #pragma omp simd 3137 for (int i = 0; i < 10; ++i) { 3138 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3139 bar(); 3140 } 3141 #pragma omp simd 3142 for (int i = 0; i < 10; ++i) { 3143 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3144 bar(); 3145 } 3146 #pragma omp simd 3147 for (int i = 0; i < 10; ++i) { 3148 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3149 ++a; 3150 } 3151 #pragma omp simd 3152 for (int i = 0; i < 10; ++i) { 3153 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3154 ++a; 3155 } 3156 #pragma omp simd 3157 for (int i = 0; i < 10; ++i) { 3158 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3159 ++a; 3160 } 3161 #pragma omp simd 3162 for (int i = 0; i < 10; ++i) { 3163 #pragma omp taskloop // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3164 for (int i = 0; i < 10; ++i) 3165 ++a; 3166 } 3167 #pragma omp simd 3168 for (int i = 0; i < 10; ++i) { 3169 #pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3170 for (int j = 0; j < 10; ++j) 3171 ; 3172 } 3173 3174 // FOR DIRECTIVE 3175 #pragma omp for 3176 for (int i = 0; i < 10; ++i) { 3177 #pragma omp for // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 3178 for (int i = 0; i < 10; ++i) 3179 ; 3180 } 3181 #pragma omp for 3182 for (int i = 0; i < 10; ++i) { 3183 #pragma omp simd 3184 for (int i = 0; i < 10; ++i) 3185 ; 3186 } 3187 #pragma omp for 3188 for (int i = 0; i < 10; ++i) { 3189 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 3190 for (int i = 0; i < 10; ++i) 3191 ; 3192 } 3193 #pragma omp for 3194 for (int i = 0; i < 10; ++i) { 3195 #pragma omp parallel 3196 for (int i = 0; i < 10; ++i) 3197 ; 3198 } 3199 #pragma omp for 3200 for (int i = 0; i < 10; ++i) { 3201 #pragma omp sections // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 3202 { 3203 bar(); 3204 } 3205 } 3206 #pragma omp for 3207 for (int i = 0; i < 10; ++i) { 3208 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a for region}} 3209 { 3210 bar(); 3211 } 3212 } 3213 #pragma omp for 3214 for (int i = 0; i < 10; ++i) { 3215 #pragma omp single // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 3216 bar(); 3217 #pragma omp master // expected-error {{region cannot be closely nested inside 'for' region}} 3218 bar(); 3219 #pragma omp critical 3220 bar(); 3221 } 3222 #pragma omp for 3223 for (int i = 0; i < 10; ++i) { 3224 #pragma omp parallel 3225 { 3226 #pragma omp single // OK 3227 { 3228 bar(); 3229 } 3230 #pragma omp for // OK 3231 for (int i = 0; i < 10; ++i) 3232 ; 3233 #pragma omp for simd // OK 3234 for (int i = 0; i < 10; ++i) 3235 ; 3236 #pragma omp sections // OK 3237 { 3238 bar(); 3239 } 3240 } 3241 } 3242 #pragma omp for 3243 for (int i = 0; i < 10; ++i) { 3244 #pragma omp parallel for 3245 for (int i = 0; i < 10; ++i) 3246 ; 3247 } 3248 #pragma omp for 3249 for (int i = 0; i < 10; ++i) { 3250 #pragma omp parallel for simd 3251 for (int i = 0; i < 10; ++i) 3252 ; 3253 } 3254 #pragma omp for 3255 for (int i = 0; i < 10; ++i) { 3256 #pragma omp parallel sections 3257 { 3258 bar(); 3259 } 3260 } 3261 #pragma omp for 3262 for (int i = 0; i < 10; ++i) { 3263 #pragma omp task 3264 { 3265 bar(); 3266 } 3267 } 3268 #pragma omp for 3269 for (int i = 0; i < 10; ++i) { 3270 #pragma omp taskyield 3271 bar(); 3272 } 3273 #pragma omp for 3274 for (int i = 0; i < 10; ++i) { 3275 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'for' region}} 3276 bar(); 3277 } 3278 #pragma omp for 3279 for (int i = 0; i < 10; ++i) { 3280 #pragma omp taskwait 3281 bar(); 3282 } 3283 #pragma omp for 3284 for (int i = 0; i < 10; ++i) { 3285 #pragma omp flush 3286 bar(); 3287 } 3288 #pragma omp for 3289 for (int i = 0; i < 10; ++i) { 3290 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 3291 bar(); 3292 } 3293 #pragma omp for ordered 3294 for (int i = 0; i < 10; ++i) { 3295 #pragma omp ordered // OK 3296 bar(); 3297 } 3298 #pragma omp for 3299 for (int i = 0; i < 10; ++i) { 3300 #pragma omp atomic 3301 ++a; 3302 } 3303 #pragma omp for 3304 for (int i = 0; i < 10; ++i) { 3305 #pragma omp target 3306 ++a; 3307 } 3308 #pragma omp for 3309 for (int i = 0; i < 10; ++i) { 3310 #pragma omp teams // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 3311 ++a; 3312 } 3313 #pragma omp for 3314 for (int i = 0; i < 10; ++i) { 3315 #pragma omp taskloop 3316 for (int i = 0; i < 10; ++i) 3317 ++a; 3318 } 3319 #pragma omp for 3320 for (int i = 0; i < 10; ++i) { 3321 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'for' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 3322 for (int j = 0; j < 10; ++j) 3323 ; 3324 } 3325 3326 // FOR SIMD DIRECTIVE 3327 #pragma omp for simd 3328 for (int i = 0; i < 10; ++i) { 3329 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3330 for (int i = 0; i < 10; ++i) 3331 ; 3332 } 3333 #pragma omp for simd 3334 for (int i = 0; i < 10; ++i) { 3335 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3336 for (int i = 0; i < 10; ++i) 3337 ; 3338 } 3339 #pragma omp for simd 3340 for (int i = 0; i < 10; ++i) { 3341 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3342 for (int i = 0; i < 10; ++i) 3343 ; 3344 } 3345 #pragma omp for simd 3346 for (int i = 0; i < 10; ++i) { 3347 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3348 for (int i = 0; i < 10; ++i) 3349 ; 3350 } 3351 #pragma omp for simd 3352 for (int i = 0; i < 10; ++i) { 3353 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3354 { 3355 bar(); 3356 } 3357 } 3358 #pragma omp for simd 3359 for (int i = 0; i < 10; ++i) { 3360 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3361 { 3362 bar(); 3363 } 3364 } 3365 #pragma omp for simd 3366 for (int i = 0; i < 10; ++i) { 3367 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3368 bar(); 3369 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3370 bar(); 3371 } 3372 #pragma omp for simd 3373 for (int i = 0; i < 10; ++i) { 3374 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3375 bar(); 3376 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3377 bar(); 3378 } 3379 #pragma omp for simd 3380 for (int i = 0; i < 10; ++i) { 3381 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3382 for (int i = 0; i < 10; ++i) 3383 ; 3384 } 3385 #pragma omp for simd 3386 for (int i = 0; i < 10; ++i) { 3387 #pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3388 for (int i = 0; i < 10; ++i) 3389 ; 3390 } 3391 #pragma omp for simd 3392 for (int i = 0; i < 10; ++i) { 3393 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3394 { 3395 bar(); 3396 } 3397 } 3398 #pragma omp for simd 3399 for (int i = 0; i < 10; ++i) { 3400 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3401 { 3402 bar(); 3403 } 3404 } 3405 #pragma omp for simd 3406 for (int i = 0; i < 10; ++i) { 3407 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3408 bar(); 3409 } 3410 #pragma omp for simd 3411 for (int i = 0; i < 10; ++i) { 3412 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3413 bar(); 3414 } 3415 #pragma omp for simd 3416 for (int i = 0; i < 10; ++i) { 3417 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3418 bar(); 3419 } 3420 #pragma omp for simd 3421 for (int i = 0; i < 10; ++i) { 3422 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3423 bar(); 3424 } 3425 #pragma omp for simd 3426 for (int i = 0; i < 10; ++i) { 3427 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3428 bar(); 3429 } 3430 #pragma omp for simd 3431 for (int i = 0; i < 10; ++i) { 3432 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3433 ++a; 3434 } 3435 #pragma omp for simd 3436 for (int i = 0; i < 10; ++i) { 3437 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3438 ++a; 3439 } 3440 #pragma omp for simd 3441 for (int i = 0; i < 10; ++i) { 3442 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3443 ++a; 3444 } 3445 #pragma omp for simd 3446 for (int i = 0; i < 10; ++i) { 3447 #pragma omp taskloop // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3448 for (int i = 0; i < 10; ++i) 3449 ++a; 3450 } 3451 #pragma omp for simd 3452 for (int i = 0; i < 10; ++i) { 3453 #pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} 3454 for (int j = 0; j < 10; ++j) 3455 ; 3456 } 3457 3458 // SECTIONS DIRECTIVE 3459 #pragma omp sections 3460 { 3461 #pragma omp for // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 3462 for (int i = 0; i < 10; ++i) 3463 ; 3464 } 3465 #pragma omp sections 3466 { 3467 #pragma omp simd 3468 for (int i = 0; i < 10; ++i) 3469 ; 3470 } 3471 #pragma omp sections 3472 { 3473 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 3474 for (int i = 0; i < 10; ++i) 3475 ; 3476 } 3477 #pragma omp sections 3478 { 3479 #pragma omp parallel 3480 for (int i = 0; i < 10; ++i) 3481 ; 3482 } 3483 #pragma omp sections 3484 { 3485 #pragma omp sections // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 3486 { 3487 bar(); 3488 } 3489 } 3490 #pragma omp sections 3491 { 3492 #pragma omp section 3493 { 3494 bar(); 3495 } 3496 } 3497 #pragma omp sections 3498 { 3499 #pragma omp critical 3500 bar(); 3501 #pragma omp single // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 3502 bar(); 3503 #pragma omp master // expected-error {{region cannot be closely nested inside 'sections' region}} 3504 bar(); 3505 } 3506 #pragma omp sections 3507 { 3508 #pragma omp parallel 3509 { 3510 #pragma omp single // OK 3511 { 3512 bar(); 3513 } 3514 #pragma omp for // OK 3515 for (int i = 0; i < 10; ++i) 3516 ; 3517 #pragma omp for simd // OK 3518 for (int i = 0; i < 10; ++i) 3519 ; 3520 #pragma omp sections // OK 3521 { 3522 bar(); 3523 } 3524 } 3525 } 3526 #pragma omp sections 3527 { 3528 #pragma omp parallel for 3529 for (int i = 0; i < 10; ++i) 3530 ; 3531 } 3532 #pragma omp sections 3533 { 3534 #pragma omp parallel for simd 3535 for (int i = 0; i < 10; ++i) 3536 ; 3537 } 3538 #pragma omp sections 3539 { 3540 #pragma omp parallel sections 3541 { 3542 bar(); 3543 } 3544 } 3545 #pragma omp sections 3546 { 3547 #pragma omp task 3548 { 3549 bar(); 3550 } 3551 } 3552 #pragma omp sections 3553 { 3554 #pragma omp taskyield 3555 } 3556 #pragma omp sections 3557 { 3558 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'sections' region}} 3559 bar(); 3560 } 3561 #pragma omp sections 3562 { 3563 #pragma omp taskwait 3564 } 3565 #pragma omp sections 3566 { 3567 #pragma omp flush 3568 } 3569 #pragma omp sections 3570 { 3571 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 3572 bar(); 3573 } 3574 #pragma omp sections 3575 { 3576 #pragma omp atomic 3577 ++a; 3578 } 3579 #pragma omp sections 3580 { 3581 #pragma omp target 3582 ++a; 3583 } 3584 #pragma omp sections 3585 { 3586 #pragma omp teams // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 3587 ++a; 3588 } 3589 #pragma omp sections 3590 { 3591 #pragma omp taskloop 3592 for (int i = 0; i < 10; ++i) 3593 ++a; 3594 } 3595 #pragma omp sections 3596 { 3597 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'sections' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 3598 for (int i = 0; i < 10; ++i) 3599 ; 3600 } 3601 3602 // SECTION DIRECTIVE 3603 #pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}} 3604 { 3605 bar(); 3606 } 3607 #pragma omp sections 3608 { 3609 #pragma omp section 3610 { 3611 #pragma omp for // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 3612 for (int i = 0; i < 10; ++i) 3613 ; 3614 } 3615 } 3616 #pragma omp sections 3617 { 3618 #pragma omp section 3619 { 3620 #pragma omp simd 3621 for (int i = 0; i < 10; ++i) 3622 ; 3623 } 3624 } 3625 #pragma omp sections 3626 { 3627 #pragma omp section 3628 { 3629 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 3630 for (int i = 0; i < 10; ++i) 3631 ; 3632 } 3633 } 3634 #pragma omp sections 3635 { 3636 #pragma omp section 3637 { 3638 #pragma omp parallel 3639 for (int i = 0; i < 10; ++i) 3640 ; 3641 } 3642 } 3643 #pragma omp sections 3644 { 3645 #pragma omp section 3646 { 3647 #pragma omp sections // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 3648 { 3649 bar(); 3650 } 3651 } 3652 } 3653 #pragma omp sections 3654 { 3655 #pragma omp section 3656 { 3657 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a section region}} 3658 { 3659 bar(); 3660 } 3661 } 3662 } 3663 #pragma omp sections 3664 { 3665 #pragma omp section 3666 { 3667 #pragma omp single // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 3668 bar(); 3669 #pragma omp master // expected-error {{region cannot be closely nested inside 'section' region}} 3670 bar(); 3671 #pragma omp critical 3672 bar(); 3673 } 3674 } 3675 #pragma omp sections 3676 { 3677 #pragma omp section 3678 { 3679 #pragma omp parallel 3680 { 3681 #pragma omp single // OK 3682 { 3683 bar(); 3684 } 3685 #pragma omp for // OK 3686 for (int i = 0; i < 10; ++i) 3687 ; 3688 #pragma omp for simd // OK 3689 for (int i = 0; i < 10; ++i) 3690 ; 3691 #pragma omp sections // OK 3692 { 3693 bar(); 3694 } 3695 } 3696 } 3697 } 3698 #pragma omp sections 3699 { 3700 #pragma omp section 3701 { 3702 #pragma omp parallel for 3703 for (int i = 0; i < 10; ++i) 3704 ; 3705 } 3706 } 3707 #pragma omp sections 3708 { 3709 #pragma omp section 3710 { 3711 #pragma omp parallel for simd 3712 for (int i = 0; i < 10; ++i) 3713 ; 3714 } 3715 } 3716 #pragma omp sections 3717 { 3718 #pragma omp section 3719 { 3720 #pragma omp parallel sections 3721 { 3722 bar(); 3723 } 3724 } 3725 } 3726 #pragma omp sections 3727 { 3728 #pragma omp section 3729 { 3730 #pragma omp task 3731 { 3732 bar(); 3733 } 3734 } 3735 } 3736 #pragma omp sections 3737 { 3738 #pragma omp section 3739 { 3740 #pragma omp taskyield 3741 bar(); 3742 } 3743 } 3744 #pragma omp sections 3745 { 3746 #pragma omp section 3747 { 3748 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'section' region}} 3749 bar(); 3750 } 3751 } 3752 #pragma omp sections 3753 { 3754 #pragma omp section 3755 { 3756 #pragma omp taskwait 3757 bar(); 3758 } 3759 } 3760 #pragma omp sections 3761 { 3762 #pragma omp section 3763 { 3764 #pragma omp flush 3765 bar(); 3766 } 3767 } 3768 #pragma omp sections 3769 { 3770 #pragma omp section 3771 { 3772 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 3773 bar(); 3774 } 3775 } 3776 #pragma omp sections 3777 { 3778 #pragma omp section 3779 { 3780 #pragma omp atomic 3781 ++a; 3782 } 3783 } 3784 #pragma omp sections 3785 { 3786 #pragma omp section 3787 { 3788 #pragma omp target 3789 ++a; 3790 } 3791 } 3792 #pragma omp sections 3793 { 3794 #pragma omp section 3795 { 3796 #pragma omp teams // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 3797 ++a; 3798 } 3799 } 3800 #pragma omp sections 3801 { 3802 #pragma omp section 3803 { 3804 #pragma omp taskloop 3805 for (int i = 0; i < 10; ++i) 3806 ++a; 3807 } 3808 } 3809 #pragma omp sections 3810 { 3811 #pragma omp section 3812 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 3813 for (int i = 0; i < 10; ++i) 3814 ; 3815 } 3816 3817 // SINGLE DIRECTIVE 3818 #pragma omp single 3819 { 3820 #pragma omp for // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 3821 for (int i = 0; i < 10; ++i) 3822 ; 3823 } 3824 #pragma omp single 3825 { 3826 #pragma omp simd 3827 for (int i = 0; i < 10; ++i) 3828 ; 3829 } 3830 #pragma omp single 3831 { 3832 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 3833 for (int i = 0; i < 10; ++i) 3834 ; 3835 } 3836 #pragma omp single 3837 { 3838 #pragma omp parallel 3839 for (int i = 0; i < 10; ++i) 3840 ; 3841 } 3842 #pragma omp single 3843 { 3844 #pragma omp single // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 3845 { 3846 bar(); 3847 } 3848 #pragma omp master // expected-error {{region cannot be closely nested inside 'single' region}} 3849 bar(); 3850 #pragma omp critical 3851 bar(); 3852 } 3853 #pragma omp single 3854 { 3855 #pragma omp sections // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 3856 { 3857 bar(); 3858 } 3859 } 3860 #pragma omp single 3861 { 3862 #pragma omp parallel 3863 { 3864 #pragma omp single // OK 3865 { 3866 bar(); 3867 } 3868 #pragma omp for // OK 3869 for (int i = 0; i < 10; ++i) 3870 ; 3871 #pragma omp for simd // OK 3872 for (int i = 0; i < 10; ++i) 3873 ; 3874 #pragma omp sections // OK 3875 { 3876 bar(); 3877 } 3878 } 3879 } 3880 #pragma omp single 3881 { 3882 #pragma omp parallel for 3883 for (int i = 0; i < 10; ++i) 3884 ; 3885 } 3886 #pragma omp single 3887 { 3888 #pragma omp parallel for simd 3889 for (int i = 0; i < 10; ++i) 3890 ; 3891 } 3892 #pragma omp single 3893 { 3894 #pragma omp parallel sections 3895 { 3896 bar(); 3897 } 3898 } 3899 #pragma omp single 3900 { 3901 #pragma omp task 3902 { 3903 bar(); 3904 } 3905 } 3906 #pragma omp single 3907 { 3908 #pragma omp taskyield 3909 bar(); 3910 } 3911 #pragma omp single 3912 { 3913 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'single' region}} 3914 bar(); 3915 } 3916 #pragma omp single 3917 { 3918 #pragma omp taskwait 3919 bar(); 3920 } 3921 #pragma omp single 3922 { 3923 #pragma omp flush 3924 bar(); 3925 } 3926 #pragma omp single 3927 { 3928 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 3929 bar(); 3930 } 3931 #pragma omp single 3932 { 3933 #pragma omp atomic 3934 ++a; 3935 } 3936 #pragma omp single 3937 { 3938 #pragma omp target 3939 ++a; 3940 } 3941 #pragma omp single 3942 { 3943 #pragma omp teams // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 3944 ++a; 3945 } 3946 #pragma omp single 3947 { 3948 #pragma omp taskloop 3949 for (int i = 0; i < 10; ++i) 3950 ++a; 3951 } 3952 #pragma omp single 3953 { 3954 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'single' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 3955 for (int i = 0; i < 10; ++i) 3956 ; 3957 } 3958 3959 // MASTER DIRECTIVE 3960 #pragma omp master 3961 { 3962 #pragma omp for // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 3963 for (int i = 0; i < 10; ++i) 3964 ; 3965 } 3966 #pragma omp master 3967 { 3968 #pragma omp simd 3969 for (int i = 0; i < 10; ++i) 3970 ; 3971 } 3972 #pragma omp master 3973 { 3974 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 3975 for (int i = 0; i < 10; ++i) 3976 ; 3977 } 3978 #pragma omp master 3979 { 3980 #pragma omp parallel 3981 for (int i = 0; i < 10; ++i) 3982 ; 3983 } 3984 #pragma omp master 3985 { 3986 #pragma omp single // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 3987 { 3988 bar(); 3989 } 3990 } 3991 #pragma omp master 3992 { 3993 #pragma omp master // OK, though second 'master' is redundant 3994 { 3995 bar(); 3996 } 3997 } 3998 #pragma omp master 3999 { 4000 #pragma omp critical 4001 { 4002 bar(); 4003 } 4004 } 4005 #pragma omp master 4006 { 4007 #pragma omp sections // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 4008 { 4009 bar(); 4010 } 4011 } 4012 #pragma omp master 4013 { 4014 #pragma omp parallel 4015 { 4016 #pragma omp master // OK 4017 { 4018 bar(); 4019 } 4020 #pragma omp for // OK 4021 for (int i = 0; i < 10; ++i) 4022 ; 4023 #pragma omp for simd // OK 4024 for (int i = 0; i < 10; ++i) 4025 ; 4026 #pragma omp sections // OK 4027 { 4028 bar(); 4029 } 4030 } 4031 } 4032 #pragma omp master 4033 { 4034 #pragma omp parallel for 4035 for (int i = 0; i < 10; ++i) 4036 ; 4037 } 4038 #pragma omp master 4039 { 4040 #pragma omp parallel for simd 4041 for (int i = 0; i < 10; ++i) 4042 ; 4043 } 4044 #pragma omp master 4045 { 4046 #pragma omp parallel sections 4047 { 4048 bar(); 4049 } 4050 } 4051 #pragma omp master 4052 { 4053 #pragma omp task 4054 { 4055 bar(); 4056 } 4057 } 4058 #pragma omp master 4059 { 4060 #pragma omp taskyield 4061 bar(); 4062 } 4063 #pragma omp master 4064 { 4065 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'master' region}} 4066 bar(); 4067 } 4068 #pragma omp master 4069 { 4070 #pragma omp taskwait 4071 bar(); 4072 } 4073 #pragma omp master 4074 { 4075 #pragma omp flush 4076 bar(); 4077 } 4078 #pragma omp master 4079 { 4080 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 4081 bar(); 4082 } 4083 #pragma omp master 4084 { 4085 #pragma omp atomic 4086 ++a; 4087 } 4088 #pragma omp master 4089 { 4090 #pragma omp target 4091 ++a; 4092 } 4093 #pragma omp master 4094 { 4095 #pragma omp teams // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 4096 ++a; 4097 } 4098 #pragma omp master 4099 { 4100 #pragma omp taskloop 4101 for (int i = 0; i < 10; ++i) 4102 ++a; 4103 } 4104 #pragma omp master 4105 { 4106 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'master' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 4107 for (int i = 0; i < 10; ++i) 4108 ; 4109 } 4110 4111 // CRITICAL DIRECTIVE 4112 #pragma omp critical 4113 { 4114 #pragma omp for // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 4115 for (int i = 0; i < 10; ++i) 4116 ; 4117 } 4118 #pragma omp critical 4119 { 4120 #pragma omp simd 4121 for (int i = 0; i < 10; ++i) 4122 ; 4123 } 4124 #pragma omp critical 4125 { 4126 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 4127 for (int i = 0; i < 10; ++i) 4128 ; 4129 } 4130 #pragma omp critical 4131 { 4132 #pragma omp parallel 4133 for (int i = 0; i < 10; ++i) 4134 ; 4135 } 4136 #pragma omp critical 4137 { 4138 #pragma omp single // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 4139 { 4140 bar(); 4141 } 4142 } 4143 #pragma omp critical 4144 { 4145 #pragma omp master // OK, though second 'master' is redundant 4146 { 4147 bar(); 4148 } 4149 } 4150 #pragma omp critical 4151 { 4152 #pragma omp critical 4153 { 4154 bar(); 4155 } 4156 } 4157 #pragma omp critical 4158 { 4159 #pragma omp sections // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 4160 { 4161 bar(); 4162 } 4163 } 4164 #pragma omp critical 4165 { 4166 #pragma omp parallel 4167 { 4168 #pragma omp master // OK 4169 { 4170 bar(); 4171 } 4172 #pragma omp for // OK 4173 for (int i = 0; i < 10; ++i) 4174 ; 4175 #pragma omp for simd // OK 4176 for (int i = 0; i < 10; ++i) 4177 ; 4178 #pragma omp sections // OK 4179 { 4180 bar(); 4181 } 4182 } 4183 } 4184 #pragma omp critical 4185 { 4186 #pragma omp parallel for 4187 for (int i = 0; i < 10; ++i) 4188 ; 4189 } 4190 #pragma omp critical 4191 { 4192 #pragma omp parallel for simd 4193 for (int i = 0; i < 10; ++i) 4194 ; 4195 } 4196 #pragma omp critical 4197 { 4198 #pragma omp parallel sections 4199 { 4200 bar(); 4201 } 4202 } 4203 #pragma omp critical 4204 { 4205 #pragma omp task 4206 { 4207 bar(); 4208 } 4209 } 4210 #pragma omp critical 4211 { 4212 #pragma omp taskyield 4213 bar(); 4214 } 4215 #pragma omp critical 4216 { 4217 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'critical' region}} 4218 bar(); 4219 } 4220 #pragma omp critical 4221 { 4222 #pragma omp taskwait 4223 bar(); 4224 } 4225 #pragma omp critical(Belka) 4226 { 4227 #pragma omp critical(Strelka) 4228 bar(); 4229 } 4230 #pragma omp critical(Tuzik) // expected-note {{previous 'critical' region starts here}} 4231 { 4232 #pragma omp critical(grelka) // expected-note {{previous 'critical' region starts here}} 4233 { 4234 #pragma omp critical(Tuzik) // expected-error {{cannot nest 'critical' regions having the same name 'Tuzik'}} 4235 { 4236 #pragma omp parallel 4237 #pragma omp critical(grelka) // expected-error {{cannot nest 'critical' regions having the same name 'grelka'}} 4238 { 4239 bar(); 4240 } 4241 } 4242 } 4243 } 4244 #pragma omp critical 4245 { 4246 #pragma omp flush 4247 bar(); 4248 } 4249 #pragma omp critical 4250 { 4251 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 4252 bar(); 4253 } 4254 #pragma omp critical 4255 { 4256 #pragma omp atomic 4257 ++a; 4258 } 4259 #pragma omp critical 4260 { 4261 #pragma omp target 4262 ++a; 4263 } 4264 #pragma omp critical 4265 { 4266 #pragma omp teams // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 4267 ++a; 4268 } 4269 #pragma omp critical 4270 { 4271 #pragma omp taskloop 4272 for (int i = 0; i < 10; ++i) 4273 ++a; 4274 } 4275 #pragma omp critical 4276 { 4277 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'critical' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 4278 for (int i = 0; i < 10; ++i) 4279 ; 4280 } 4281 4282 // PARALLEL FOR DIRECTIVE 4283 #pragma omp parallel for 4284 for (int i = 0; i < 10; ++i) { 4285 #pragma omp for // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 4286 for (int i = 0; i < 10; ++i) 4287 ; 4288 } 4289 #pragma omp parallel for 4290 for (int i = 0; i < 10; ++i) { 4291 #pragma omp simd 4292 for (int i = 0; i < 10; ++i) 4293 ; 4294 } 4295 #pragma omp parallel for 4296 for (int i = 0; i < 10; ++i) { 4297 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 4298 for (int i = 0; i < 10; ++i) 4299 ; 4300 } 4301 4302 #pragma omp parallel for 4303 for (int i = 0; i < 10; ++i) { 4304 #pragma omp parallel 4305 for (int i = 0; i < 10; ++i) 4306 ; 4307 } 4308 #pragma omp parallel for 4309 for (int i = 0; i < 10; ++i) { 4310 #pragma omp sections // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 4311 { 4312 bar(); 4313 } 4314 } 4315 #pragma omp parallel for 4316 for (int i = 0; i < 10; ++i) { 4317 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a parallel for region}} 4318 { 4319 bar(); 4320 } 4321 } 4322 #pragma omp parallel for 4323 for (int i = 0; i < 10; ++i) { 4324 #pragma omp single // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 4325 { 4326 bar(); 4327 } 4328 #pragma omp master // expected-error {{region cannot be closely nested inside 'parallel for' region}} 4329 { 4330 bar(); 4331 } 4332 #pragma omp critical 4333 { 4334 bar(); 4335 } 4336 } 4337 #pragma omp parallel for 4338 for (int i = 0; i < 10; ++i) { 4339 #pragma omp parallel 4340 { 4341 #pragma omp single // OK 4342 { 4343 bar(); 4344 } 4345 #pragma omp master // OK 4346 { 4347 bar(); 4348 } 4349 #pragma omp critical // OK 4350 { 4351 bar(); 4352 } 4353 #pragma omp for // OK 4354 for (int i = 0; i < 10; ++i) 4355 ; 4356 #pragma omp for simd // OK 4357 for (int i = 0; i < 10; ++i) 4358 ; 4359 #pragma omp sections // OK 4360 { 4361 bar(); 4362 } 4363 } 4364 } 4365 #pragma omp parallel for 4366 for (int i = 0; i < 10; ++i) { 4367 #pragma omp parallel for 4368 for (int i = 0; i < 10; ++i) 4369 ; 4370 } 4371 #pragma omp parallel for 4372 for (int i = 0; i < 10; ++i) { 4373 #pragma omp parallel for simd 4374 for (int i = 0; i < 10; ++i) 4375 ; 4376 } 4377 #pragma omp parallel for 4378 for (int i = 0; i < 10; ++i) { 4379 #pragma omp parallel sections 4380 { 4381 bar(); 4382 } 4383 } 4384 #pragma omp parallel for 4385 for (int i = 0; i < 10; ++i) { 4386 #pragma omp task 4387 { 4388 bar(); 4389 } 4390 } 4391 #pragma omp parallel for 4392 for (int i = 0; i < 10; ++i) { 4393 #pragma omp taskyield 4394 bar(); 4395 } 4396 #pragma omp parallel for 4397 for (int i = 0; i < 10; ++i) { 4398 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel for' region}} 4399 bar(); 4400 } 4401 #pragma omp parallel for 4402 for (int i = 0; i < 10; ++i) { 4403 #pragma omp taskwait 4404 bar(); 4405 } 4406 #pragma omp parallel for 4407 for (int i = 0; i < 10; ++i) { 4408 #pragma omp flush 4409 bar(); 4410 } 4411 #pragma omp parallel for 4412 for (int i = 0; i < 10; ++i) { 4413 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 4414 bar(); 4415 } 4416 #pragma omp parallel for ordered 4417 for (int i = 0; i < 10; ++i) { 4418 #pragma omp ordered // OK 4419 bar(); 4420 } 4421 #pragma omp parallel for 4422 for (int i = 0; i < 10; ++i) { 4423 #pragma omp atomic 4424 ++a; 4425 } 4426 #pragma omp parallel for 4427 for (int i = 0; i < 10; ++i) { 4428 #pragma omp target 4429 ++a; 4430 } 4431 #pragma omp parallel for 4432 for (int i = 0; i < 10; ++i) { 4433 #pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 4434 ++a; 4435 } 4436 #pragma omp parallel for 4437 for (int i = 0; i < 10; ++i) { 4438 #pragma omp taskloop 4439 for (int i = 0; i < 10; ++i) 4440 ++a; 4441 } 4442 #pragma omp parallel for 4443 for (int i = 0; i < 10; ++i) { 4444 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'parallel for' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 4445 for (int j = 0; j < 10; ++j) 4446 ; 4447 } 4448 4449 // PARALLEL FOR SIMD DIRECTIVE 4450 #pragma omp parallel for simd 4451 for (int i = 0; i < 10; ++i) { 4452 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4453 for (int i = 0; i < 10; ++i) 4454 ; 4455 } 4456 #pragma omp parallel for simd 4457 for (int i = 0; i < 10; ++i) { 4458 #pragma omp simd// expected-error {{OpenMP constructs may not be nested inside a simd region}} 4459 for (int i = 0; i < 10; ++i) 4460 ; 4461 } 4462 #pragma omp parallel for simd 4463 for (int i = 0; i < 10; ++i) { 4464 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4465 for (int i = 0; i < 10; ++i) 4466 ; 4467 } 4468 #pragma omp parallel for simd 4469 for (int i = 0; i < 10; ++i) { 4470 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4471 for (int i = 0; i < 10; ++i) 4472 ; 4473 } 4474 #pragma omp parallel for simd 4475 for (int i = 0; i < 10; ++i) { 4476 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4477 { 4478 bar(); 4479 } 4480 } 4481 #pragma omp parallel for simd 4482 for (int i = 0; i < 10; ++i) { 4483 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4484 { 4485 bar(); 4486 } 4487 } 4488 #pragma omp parallel for simd 4489 for (int i = 0; i < 10; ++i) { 4490 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4491 { 4492 bar(); 4493 } 4494 } 4495 4496 #pragma omp parallel for simd 4497 for (int i = 0; i < 10; ++i) { 4498 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4499 { 4500 bar(); 4501 } 4502 } 4503 4504 #pragma omp parallel for simd 4505 for (int i = 0; i < 10; ++i) { 4506 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4507 { 4508 bar(); 4509 } 4510 } 4511 4512 #pragma omp parallel for simd 4513 for (int i = 0; i < 10; ++i) { 4514 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4515 { 4516 #pragma omp single 4517 { 4518 bar(); 4519 } 4520 #pragma omp for 4521 for (int i = 0; i < 10; ++i) 4522 ; 4523 #pragma omp for simd 4524 for (int i = 0; i < 10; ++i) 4525 ; 4526 #pragma omp sections 4527 { 4528 bar(); 4529 } 4530 } 4531 } 4532 #pragma omp parallel for simd 4533 for (int i = 0; i < 10; ++i) { 4534 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4535 for (int i = 0; i < 10; ++i) 4536 ; 4537 } 4538 #pragma omp parallel for simd 4539 for (int i = 0; i < 10; ++i) { 4540 #pragma omp parallel for simd// expected-error {{OpenMP constructs may not be nested inside a simd region}} 4541 for (int i = 0; i < 10; ++i) 4542 ; 4543 } 4544 #pragma omp parallel for simd 4545 for (int i = 0; i < 10; ++i) { 4546 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4547 { 4548 bar(); 4549 } 4550 } 4551 #pragma omp parallel for simd 4552 for (int i = 0; i < 10; ++i) { 4553 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4554 { 4555 bar(); 4556 } 4557 } 4558 #pragma omp parallel for simd 4559 for (int i = 0; i < 10; ++i) { 4560 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4561 bar(); 4562 } 4563 #pragma omp parallel for simd 4564 for (int i = 0; i < 10; ++i) { 4565 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4566 bar(); 4567 } 4568 #pragma omp parallel for simd 4569 for (int i = 0; i < 10; ++i) { 4570 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4571 bar(); 4572 } 4573 #pragma omp parallel for simd 4574 for (int i = 0; i < 10; ++i) { 4575 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4576 bar(); 4577 } 4578 #pragma omp parallel for simd 4579 for (int i = 0; i < 10; ++i) { 4580 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4581 bar(); 4582 } 4583 #pragma omp parallel for simd 4584 for (int i = 0; i < 10; ++i) { 4585 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4586 bar(); 4587 } 4588 #pragma omp parallel for simd 4589 for (int i = 0; i < 10; ++i) { 4590 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4591 ++a; 4592 } 4593 #pragma omp parallel for simd 4594 for (int i = 0; i < 10; ++i) { 4595 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4596 ++a; 4597 } 4598 #pragma omp parallel for simd 4599 for (int i = 0; i < 10; ++i) { 4600 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4601 ++a; 4602 } 4603 #pragma omp parallel for simd 4604 for (int i = 0; i < 10; ++i) { 4605 #pragma omp taskloop // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4606 for (int i = 0; i < 10; ++i) 4607 ++a; 4608 } 4609 #pragma omp parallel for simd 4610 for (int i = 0; i < 10; ++i) { 4611 #pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside a simd region}} 4612 for (int j = 0; j < 10; ++j) 4613 ; 4614 } 4615 4616 // PARALLEL SECTIONS DIRECTIVE 4617 #pragma omp parallel sections 4618 { 4619 #pragma omp for // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 4620 for (int i = 0; i < 10; ++i) 4621 ; 4622 } 4623 #pragma omp parallel sections 4624 { 4625 #pragma omp simd 4626 for (int i = 0; i < 10; ++i) 4627 ; 4628 } 4629 #pragma omp parallel sections 4630 { 4631 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 4632 for (int i = 0; i < 10; ++i) 4633 ; 4634 } 4635 #pragma omp parallel sections 4636 { 4637 #pragma omp parallel 4638 for (int i = 0; i < 10; ++i) 4639 ; 4640 } 4641 #pragma omp parallel sections 4642 { 4643 #pragma omp sections // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 4644 { 4645 bar(); 4646 } 4647 } 4648 #pragma omp parallel sections 4649 { 4650 #pragma omp section 4651 { 4652 bar(); 4653 } 4654 } 4655 #pragma omp parallel sections 4656 { 4657 #pragma omp section 4658 { 4659 #pragma omp single // expected-error {{region cannot be closely nested inside 'section' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 4660 bar(); 4661 #pragma omp master // expected-error {{region cannot be closely nested inside 'section' region}} 4662 bar(); 4663 #pragma omp critical 4664 bar(); 4665 } 4666 } 4667 #pragma omp parallel sections 4668 { 4669 #pragma omp parallel 4670 { 4671 #pragma omp single // OK 4672 { 4673 bar(); 4674 } 4675 #pragma omp master // OK 4676 { 4677 bar(); 4678 } 4679 #pragma omp critical // OK 4680 { 4681 bar(); 4682 } 4683 #pragma omp for // OK 4684 for (int i = 0; i < 10; ++i) 4685 ; 4686 #pragma omp for simd // OK 4687 for (int i = 0; i < 10; ++i) 4688 ; 4689 #pragma omp sections // OK 4690 { 4691 bar(); 4692 } 4693 } 4694 } 4695 #pragma omp parallel sections 4696 { 4697 #pragma omp parallel for 4698 for (int i = 0; i < 10; ++i) 4699 ; 4700 } 4701 #pragma omp parallel sections 4702 { 4703 #pragma omp parallel for simd 4704 for (int i = 0; i < 10; ++i) 4705 ; 4706 } 4707 #pragma omp parallel sections 4708 { 4709 #pragma omp parallel sections 4710 { 4711 bar(); 4712 } 4713 } 4714 #pragma omp parallel sections 4715 { 4716 #pragma omp task 4717 { 4718 bar(); 4719 } 4720 } 4721 #pragma omp parallel sections 4722 { 4723 #pragma omp taskyield 4724 } 4725 #pragma omp parallel sections 4726 { 4727 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel sections' region}} 4728 } 4729 #pragma omp parallel sections 4730 { 4731 #pragma omp taskwait 4732 } 4733 #pragma omp parallel sections 4734 { 4735 #pragma omp flush 4736 } 4737 #pragma omp parallel sections 4738 { 4739 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 4740 bar(); 4741 } 4742 #pragma omp parallel sections 4743 { 4744 #pragma omp atomic 4745 ++a; 4746 } 4747 #pragma omp parallel sections 4748 { 4749 #pragma omp target 4750 ++a; 4751 } 4752 #pragma omp parallel sections 4753 { 4754 #pragma omp teams // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 4755 ++a; 4756 } 4757 #pragma omp parallel sections 4758 { 4759 #pragma omp taskloop 4760 for (int i = 0; i < 10; ++i) 4761 ++a; 4762 } 4763 #pragma omp parallel sections 4764 { 4765 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'parallel sections' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 4766 for (int i = 0; i < 10; ++i) 4767 ; 4768 } 4769 4770 // TASK DIRECTIVE 4771 #pragma omp task 4772 #pragma omp for // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 4773 for (int i = 0; i < 10; ++i) 4774 ; 4775 #pragma omp task 4776 #pragma omp simd 4777 for (int i = 0; i < 10; ++i) 4778 ; 4779 #pragma omp task 4780 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 4781 for (int i = 0; i < 10; ++i) 4782 ; 4783 #pragma omp task 4784 #pragma omp sections // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 4785 { 4786 bar(); 4787 } 4788 #pragma omp task 4789 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a task region}} 4790 { 4791 bar(); 4792 } 4793 #pragma omp task 4794 #pragma omp single // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 4795 bar(); 4796 #pragma omp task 4797 #pragma omp master // expected-error {{region cannot be closely nested inside 'task' region}} 4798 bar(); 4799 #pragma omp task 4800 #pragma omp critical 4801 bar(); 4802 #pragma omp task 4803 #pragma omp parallel for 4804 for (int i = 0; i < 10; ++i) 4805 ; 4806 #pragma omp task 4807 #pragma omp parallel for simd 4808 for (int i = 0; i < 10; ++i) 4809 ; 4810 #pragma omp task 4811 #pragma omp parallel sections 4812 { 4813 bar(); 4814 } 4815 #pragma omp task 4816 #pragma omp task 4817 { 4818 bar(); 4819 } 4820 #pragma omp task 4821 { 4822 #pragma omp taskyield 4823 bar(); 4824 } 4825 #pragma omp task 4826 { 4827 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'task' region}} 4828 bar(); 4829 } 4830 #pragma omp task 4831 { 4832 #pragma omp taskwait 4833 bar(); 4834 } 4835 #pragma omp task 4836 { 4837 #pragma omp flush 4838 bar(); 4839 } 4840 #pragma omp task 4841 { 4842 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 4843 bar(); 4844 } 4845 #pragma omp task 4846 { 4847 #pragma omp atomic 4848 ++a; 4849 } 4850 #pragma omp task 4851 { 4852 #pragma omp target 4853 ++a; 4854 } 4855 #pragma omp task 4856 { 4857 #pragma omp teams // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 4858 ++a; 4859 } 4860 #pragma omp task 4861 { 4862 #pragma omp taskloop 4863 for (int i = 0; i < 10; ++i) 4864 ++a; 4865 } 4866 #pragma omp task 4867 { 4868 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 4869 for (int i = 0; i < 10; ++i) 4870 ; 4871 } 4872 4873 // ATOMIC DIRECTIVE 4874 #pragma omp atomic 4875 // 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}} 4876 // expected-note@+1 {{expected an expression statement}} 4877 { 4878 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4879 for (int i = 0; i < 10; ++i) 4880 ; 4881 } 4882 #pragma omp atomic 4883 // 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}} 4884 // expected-note@+1 {{expected an expression statement}} 4885 { 4886 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4887 for (int i = 0; i < 10; ++i) 4888 ; 4889 } 4890 #pragma omp atomic 4891 // 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}} 4892 // expected-note@+1 {{expected an expression statement}} 4893 { 4894 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4895 for (int i = 0; i < 10; ++i) 4896 ; 4897 } 4898 #pragma omp atomic 4899 // 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}} 4900 // expected-note@+1 {{expected an expression statement}} 4901 { 4902 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4903 for (int i = 0; i < 10; ++i) 4904 ; 4905 } 4906 #pragma omp atomic 4907 // 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}} 4908 // expected-note@+1 {{expected an expression statement}} 4909 { 4910 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4911 { 4912 bar(); 4913 } 4914 } 4915 #pragma omp atomic 4916 // 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}} 4917 // expected-note@+1 {{expected an expression statement}} 4918 { 4919 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4920 { 4921 bar(); 4922 } 4923 } 4924 #pragma omp atomic 4925 // 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}} 4926 // expected-note@+1 {{expected an expression statement}} 4927 { 4928 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4929 { 4930 bar(); 4931 } 4932 } 4933 #pragma omp atomic 4934 // 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}} 4935 // expected-note@+1 {{expected an expression statement}} 4936 { 4937 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4938 { 4939 bar(); 4940 } 4941 } 4942 #pragma omp atomic 4943 // 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}} 4944 // expected-note@+1 {{expected an expression statement}} 4945 { 4946 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4947 { 4948 bar(); 4949 } 4950 } 4951 #pragma omp atomic 4952 // 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}} 4953 // expected-note@+1 {{expected an expression statement}} 4954 { 4955 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4956 for (int i = 0; i < 10; ++i) 4957 ; 4958 } 4959 #pragma omp atomic 4960 // 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}} 4961 // expected-note@+1 {{expected an expression statement}} 4962 { 4963 #pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4964 for (int i = 0; i < 10; ++i) 4965 ; 4966 } 4967 #pragma omp atomic 4968 // 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}} 4969 // expected-note@+1 {{expected an expression statement}} 4970 { 4971 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4972 { 4973 bar(); 4974 } 4975 } 4976 #pragma omp atomic 4977 // 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}} 4978 // expected-note@+1 {{expected an expression statement}} 4979 { 4980 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4981 { 4982 bar(); 4983 } 4984 } 4985 #pragma omp atomic 4986 // 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}} 4987 // expected-note@+1 {{expected an expression statement}} 4988 { 4989 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4990 bar(); 4991 } 4992 #pragma omp atomic 4993 // 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}} 4994 // expected-note@+1 {{expected an expression statement}} 4995 { 4996 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 4997 bar(); 4998 } 4999 #pragma omp atomic 5000 // 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}} 5001 // expected-note@+1 {{expected an expression statement}} 5002 { 5003 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 5004 bar(); 5005 } 5006 #pragma omp atomic 5007 // 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}} 5008 // expected-note@+1 {{expected an expression statement}} 5009 { 5010 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 5011 bar(); 5012 } 5013 #pragma omp atomic 5014 // 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}} 5015 // expected-note@+1 {{expected an expression statement}} 5016 { 5017 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 5018 bar(); 5019 } 5020 #pragma omp atomic 5021 // 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}} 5022 // expected-note@+1 {{expected an expression statement}} 5023 { 5024 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 5025 ++a; 5026 } 5027 #pragma omp atomic 5028 // 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}} 5029 // expected-note@+1 {{expected an expression statement}} 5030 { 5031 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 5032 ++a; 5033 } 5034 #pragma omp atomic 5035 // 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}} 5036 // expected-note@+1 {{expected an expression statement}} 5037 { 5038 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 5039 ++a; 5040 } 5041 #pragma omp atomic 5042 // 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}} 5043 // expected-note@+1 {{expected an expression statement}} 5044 { 5045 #pragma omp taskloop // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 5046 for (int i = 0; i < 10; ++i) 5047 ++a; 5048 } 5049 #pragma omp atomic 5050 // 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}} 5051 // expected-note@+1 {{expected an expression statement}} 5052 { 5053 #pragma omp distribute // expected-error {{OpenMP constructs may not be nested inside an atomic region}} 5054 for (int i = 0; i < 10; ++i) 5055 ; 5056 } 5057 5058 // TARGET DIRECTIVE 5059 #pragma omp target 5060 #pragma omp parallel 5061 bar(); 5062 #pragma omp target 5063 #pragma omp for 5064 for (int i = 0; i < 10; ++i) 5065 ; 5066 #pragma omp target 5067 #pragma omp simd 5068 for (int i = 0; i < 10; ++i) 5069 ; 5070 #pragma omp target 5071 #pragma omp for simd 5072 for (int i = 0; i < 10; ++i) 5073 ; 5074 #pragma omp target 5075 #pragma omp sections 5076 { 5077 bar(); 5078 } 5079 #pragma omp target 5080 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a target region}} 5081 { 5082 bar(); 5083 } 5084 #pragma omp target 5085 #pragma omp single 5086 bar(); 5087 5088 #pragma omp target 5089 #pragma omp master 5090 { 5091 bar(); 5092 } 5093 #pragma omp target 5094 #pragma omp critical 5095 { 5096 bar(); 5097 } 5098 #pragma omp target 5099 #pragma omp parallel for 5100 for (int i = 0; i < 10; ++i) 5101 ; 5102 #pragma omp target 5103 #pragma omp parallel for simd 5104 for (int i = 0; i < 10; ++i) 5105 ; 5106 #pragma omp target 5107 #pragma omp parallel sections 5108 { 5109 bar(); 5110 } 5111 #pragma omp target 5112 #pragma omp task 5113 { 5114 bar(); 5115 } 5116 #pragma omp target 5117 { 5118 #pragma omp taskyield 5119 bar(); 5120 } 5121 #pragma omp target 5122 { 5123 #pragma omp barrier 5124 bar(); 5125 } 5126 #pragma omp target 5127 { 5128 #pragma omp taskwait 5129 bar(); 5130 } 5131 #pragma omp target 5132 { 5133 #pragma omp flush 5134 bar(); 5135 } 5136 #pragma omp target 5137 { 5138 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'target' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 5139 bar(); 5140 } 5141 #pragma omp target 5142 { 5143 #pragma omp atomic 5144 ++a; 5145 } 5146 #pragma omp target 5147 { 5148 #pragma omp target 5149 ++a; 5150 } 5151 #pragma omp target 5152 { 5153 #pragma omp teams 5154 ++a; 5155 } 5156 #pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}} 5157 { 5158 ++a; // expected-note {{statement outside teams construct here}} 5159 #pragma omp teams // expected-note {{nested teams construct here}} 5160 ++a; 5161 } 5162 #pragma omp target 5163 { 5164 #pragma omp taskloop 5165 for (int i = 0; i < 10; ++i) 5166 ++a; 5167 } 5168 #pragma omp target 5169 { 5170 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'target' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 5171 for (int i = 0; i < 10; ++i) 5172 ; 5173 } 5174 5175 // TEAMS DIRECTIVE 5176 #pragma omp target 5177 #pragma omp teams 5178 #pragma omp parallel 5179 bar(); 5180 #pragma omp target 5181 #pragma omp teams 5182 #pragma omp for // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 5183 for (int i = 0; i < 10; ++i) 5184 ; 5185 #pragma omp target 5186 #pragma omp teams 5187 #pragma omp simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp simd' directive into a parallel region?}} 5188 for (int i = 0; i < 10; ++i) 5189 ; 5190 #pragma omp target 5191 #pragma omp teams 5192 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 5193 for (int i = 0; i < 10; ++i) 5194 ; 5195 #pragma omp target 5196 #pragma omp teams 5197 #pragma omp sections // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 5198 { 5199 bar(); 5200 } 5201 #pragma omp target 5202 #pragma omp teams 5203 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a teams region}} 5204 { 5205 bar(); 5206 } 5207 #pragma omp target 5208 #pragma omp teams 5209 #pragma omp single // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 5210 bar(); 5211 5212 #pragma omp target 5213 #pragma omp teams 5214 #pragma omp master // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp master' directive into a parallel region?}} 5215 { 5216 bar(); 5217 } 5218 #pragma omp target 5219 #pragma omp teams 5220 #pragma omp critical // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp critical' directive into a parallel region?}} 5221 { 5222 bar(); 5223 } 5224 #pragma omp target 5225 #pragma omp teams 5226 #pragma omp parallel for 5227 for (int i = 0; i < 10; ++i) 5228 ; 5229 #pragma omp target 5230 #pragma omp teams 5231 #pragma omp parallel for simd 5232 for (int i = 0; i < 10; ++i) 5233 ; 5234 #pragma omp target 5235 #pragma omp teams 5236 #pragma omp parallel sections 5237 { 5238 bar(); 5239 } 5240 #pragma omp target 5241 #pragma omp teams 5242 #pragma omp task // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp task' directive into a parallel region?}} 5243 { 5244 bar(); 5245 } 5246 #pragma omp target 5247 #pragma omp teams 5248 { 5249 #pragma omp taskyield // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskyield' directive into a parallel region?}} 5250 bar(); 5251 } 5252 #pragma omp target 5253 #pragma omp teams 5254 { 5255 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp barrier' directive into a parallel region?}} 5256 bar(); 5257 } 5258 #pragma omp target 5259 #pragma omp teams 5260 { 5261 #pragma omp taskwait // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskwait' directive into a parallel region?}} 5262 bar(); 5263 } 5264 #pragma omp target 5265 #pragma omp teams 5266 { 5267 #pragma omp flush // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp flush' directive into a parallel region?}} 5268 bar(); 5269 } 5270 #pragma omp target 5271 #pragma omp teams 5272 { 5273 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 5274 bar(); 5275 } 5276 #pragma omp target 5277 #pragma omp teams 5278 { 5279 #pragma omp atomic // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp atomic' directive into a parallel region?}} 5280 ++a; 5281 } 5282 #pragma omp target 5283 #pragma omp teams 5284 { 5285 #pragma omp target // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp target' directive into a parallel region?}} 5286 ++a; 5287 } 5288 #pragma omp target 5289 #pragma omp teams 5290 { 5291 #pragma omp teams // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 5292 ++a; 5293 } 5294 #pragma omp target 5295 #pragma omp teams 5296 { 5297 #pragma omp taskloop // expected-error {{region cannot be closely nested inside 'teams' region; perhaps you forget to enclose 'omp taskloop' directive into a parallel region?}} 5298 for (int i = 0; i < 10; ++i) 5299 ++a; 5300 } 5301 #pragma omp target 5302 #pragma omp teams 5303 #pragma omp distribute 5304 for (int i = 0; i < 10; ++i) 5305 ; 5306 #pragma omp target 5307 #pragma omp teams 5308 #pragma omp distribute 5309 for (int i = 0; i < 10; ++i) 5310 ; 5311 #pragma omp distribute 5312 for (int j = 0; j < 10; ++j) 5313 ; 5314 5315 // TASKLOOP DIRECTIVE 5316 #pragma omp taskloop 5317 for (int i = 0; i < 10; ++i) { 5318 #pragma omp for // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}} 5319 for (int i = 0; i < 10; ++i) 5320 ; 5321 } 5322 #pragma omp taskloop 5323 for (int i = 0; i < 10; ++i) { 5324 #pragma omp simd 5325 for (int i = 0; i < 10; ++i) 5326 ; 5327 } 5328 #pragma omp taskloop 5329 for (int i = 0; i < 10; ++i) { 5330 #pragma omp for simd // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp for simd' directive into a parallel region?}} 5331 for (int i = 0; i < 10; ++i) 5332 ; 5333 } 5334 #pragma omp taskloop 5335 for (int i = 0; i < 10; ++i) { 5336 #pragma omp parallel 5337 for (int i = 0; i < 10; ++i) 5338 ; 5339 } 5340 #pragma omp taskloop 5341 for (int i = 0; i < 10; ++i) { 5342 #pragma omp sections // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp sections' directive into a parallel region?}} 5343 { 5344 bar(); 5345 } 5346 } 5347 #pragma omp taskloop 5348 for (int i = 0; i < 10; ++i) { 5349 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a taskloop region}} 5350 { 5351 bar(); 5352 } 5353 } 5354 #pragma omp taskloop 5355 for (int i = 0; i < 10; ++i) { 5356 #pragma omp single // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp single' directive into a parallel region?}} 5357 { 5358 bar(); 5359 } 5360 } 5361 5362 #pragma omp taskloop 5363 for (int i = 0; i < 10; ++i) { 5364 #pragma omp master // expected-error {{region cannot be closely nested inside 'taskloop' region}} 5365 { 5366 bar(); 5367 } 5368 } 5369 #pragma omp taskloop 5370 for (int i = 0; i < 10; ++i) { 5371 #pragma omp critical 5372 { 5373 bar(); 5374 } 5375 } 5376 #pragma omp taskloop 5377 for (int i = 0; i < 10; ++i) { 5378 #pragma omp parallel 5379 { 5380 #pragma omp single // OK 5381 { 5382 bar(); 5383 } 5384 #pragma omp for // OK 5385 for (int i = 0; i < 10; ++i) 5386 ; 5387 #pragma omp sections // OK 5388 { 5389 bar(); 5390 } 5391 } 5392 } 5393 #pragma omp taskloop 5394 for (int i = 0; i < 10; ++i) { 5395 #pragma omp parallel for 5396 for (int i = 0; i < 10; ++i) 5397 ; 5398 } 5399 #pragma omp taskloop 5400 for (int i = 0; i < 10; ++i) { 5401 #pragma omp parallel for simd 5402 for (int i = 0; i < 10; ++i) 5403 ; 5404 } 5405 #pragma omp taskloop 5406 for (int i = 0; i < 10; ++i) { 5407 #pragma omp parallel sections 5408 { 5409 bar(); 5410 } 5411 } 5412 #pragma omp taskloop 5413 for (int i = 0; i < 10; ++i) { 5414 #pragma omp task 5415 { 5416 bar(); 5417 } 5418 } 5419 #pragma omp taskloop 5420 for (int i = 0; i < 10; ++i) { 5421 #pragma omp taskyield 5422 bar(); 5423 } 5424 #pragma omp taskloop 5425 for (int i = 0; i < 10; ++i) { 5426 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'taskloop' region}} 5427 bar(); 5428 } 5429 #pragma omp taskloop 5430 for (int i = 0; i < 10; ++i) { 5431 #pragma omp taskwait 5432 bar(); 5433 } 5434 #pragma omp taskloop 5435 for (int i = 0; i < 10; ++i) { 5436 #pragma omp flush 5437 bar(); 5438 } 5439 #pragma omp taskloop 5440 for (int i = 0; i < 10; ++i) { 5441 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 5442 bar(); 5443 } 5444 #pragma omp taskloop 5445 for (int i = 0; i < 10; ++i) { 5446 #pragma omp atomic 5447 ++a; 5448 } 5449 #pragma omp taskloop 5450 for (int i = 0; i < 10; ++i) { 5451 #pragma omp target 5452 ++a; 5453 } 5454 #pragma omp taskloop 5455 for (int i = 0; i < 10; ++i) { 5456 #pragma omp teams // expected-error {{region cannot be closely nested inside 'taskloop' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 5457 ++a; 5458 } 5459 #pragma omp taskloop 5460 for (int i = 0; i < 10; ++i) { 5461 #pragma omp taskloop 5462 for (int i = 0; i < 10; ++i) 5463 ++a; 5464 } 5465 5466 // DISTRIBUTE DIRECTIVE 5467 #pragma omp target 5468 #pragma omp teams 5469 #pragma omp distribute 5470 for (int i = 0; i < 10; ++i) { 5471 #pragma omp distribute // expected-error {{region cannot be closely nested inside 'distribute' region; perhaps you forget to enclose 'omp distribute' directive into a teams region?}} 5472 for (int i = 0; i < 10; ++i) 5473 ; 5474 } 5475 #pragma omp target 5476 #pragma omp teams 5477 #pragma omp distribute 5478 for (int i = 0; i < 10; ++i) { 5479 #pragma omp for 5480 for (int i = 0; i < 10; ++i) 5481 ; 5482 } 5483 #pragma omp target 5484 #pragma omp teams 5485 #pragma omp distribute 5486 for (int i = 0; i < 10; ++i) { 5487 #pragma omp simd 5488 for (int i = 0; i < 10; ++i) 5489 ; 5490 } 5491 #pragma omp target 5492 #pragma omp teams 5493 #pragma omp distribute 5494 for (int i = 0; i < 10; ++i) { 5495 #pragma omp for simd 5496 for (int i = 0; i < 10; ++i) 5497 ; 5498 } 5499 #pragma omp target 5500 #pragma omp teams 5501 #pragma omp distribute 5502 for (int i = 0; i < 10; ++i) { 5503 #pragma omp parallel 5504 for (int i = 0; i < 10; ++i) 5505 ; 5506 } 5507 #pragma omp target 5508 #pragma omp teams 5509 #pragma omp distribute 5510 for (int i = 0; i < 10; ++i) { 5511 #pragma omp sections 5512 { 5513 bar(); 5514 } 5515 } 5516 #pragma omp target 5517 #pragma omp teams 5518 #pragma omp distribute 5519 for (int i = 0; i < 10; ++i) { 5520 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a distribute region}} 5521 { 5522 bar(); 5523 } 5524 } 5525 #pragma omp target 5526 #pragma omp teams 5527 #pragma omp distribute 5528 for (int i = 0; i < 10; ++i) { 5529 #pragma omp single 5530 { 5531 bar(); 5532 } 5533 } 5534 #pragma omp target 5535 #pragma omp teams 5536 #pragma omp distribute 5537 for (int i = 0; i < 10; ++i) { 5538 #pragma omp master 5539 { 5540 bar(); 5541 } 5542 } 5543 #pragma omp target 5544 #pragma omp teams 5545 #pragma omp distribute 5546 for (int i = 0; i < 10; ++i) { 5547 #pragma omp critical 5548 { 5549 bar(); 5550 } 5551 } 5552 #pragma omp target 5553 #pragma omp teams 5554 #pragma omp distribute 5555 for (int i = 0; i < 10; ++i) { 5556 #pragma omp parallel 5557 { 5558 #pragma omp single 5559 { 5560 bar(); 5561 } 5562 } 5563 } 5564 #pragma omp target 5565 #pragma omp teams 5566 #pragma omp distribute 5567 for (int i = 0; i < 10; ++i) { 5568 #pragma omp parallel for 5569 for (int i = 0; i < 10; ++i) 5570 ; 5571 } 5572 #pragma omp target 5573 #pragma omp teams 5574 #pragma omp distribute 5575 for (int i = 0; i < 10; ++i) { 5576 #pragma omp parallel for simd 5577 for (int i = 0; i < 10; ++i) 5578 ; 5579 } 5580 #pragma omp target 5581 #pragma omp teams 5582 #pragma omp distribute 5583 for (int i = 0; i < 10; ++i) { 5584 #pragma omp parallel sections 5585 { 5586 bar(); 5587 } 5588 } 5589 #pragma omp target 5590 #pragma omp teams 5591 #pragma omp distribute 5592 for (int i = 0; i < 10; ++i) { 5593 #pragma omp task 5594 { 5595 bar(); 5596 } 5597 } 5598 #pragma omp target 5599 #pragma omp teams 5600 #pragma omp distribute 5601 for (int i = 0; i < 10; ++i) { 5602 #pragma omp taskyield 5603 bar(); 5604 } 5605 #pragma omp target 5606 #pragma omp teams 5607 #pragma omp distribute 5608 for (int i = 0; i < 10; ++i) { 5609 #pragma omp barrier 5610 bar(); 5611 } 5612 #pragma omp target 5613 #pragma omp teams 5614 #pragma omp distribute 5615 for (int i = 0; i < 10; ++i) { 5616 #pragma omp taskwait 5617 bar(); 5618 } 5619 #pragma omp target 5620 #pragma omp teams 5621 #pragma omp distribute 5622 for (int i = 0; i < 10; ++i) { 5623 #pragma omp flush 5624 bar(); 5625 } 5626 #pragma omp target 5627 #pragma omp teams 5628 #pragma omp distribute 5629 for (int i = 0; i < 10; ++i) { 5630 #pragma omp ordered // expected-error {{region cannot be closely nested inside 'distribute' region; perhaps you forget to enclose 'omp ordered' directive into a for or a parallel for region with 'ordered' clause?}} 5631 bar(); 5632 } 5633 #pragma omp target 5634 #pragma omp teams 5635 #pragma omp distribute 5636 for (int i = 0; i < 10; ++i) { 5637 #pragma omp atomic 5638 ++a; 5639 } 5640 #pragma omp target 5641 #pragma omp teams 5642 #pragma omp distribute 5643 for (int i = 0; i < 10; ++i) { 5644 #pragma omp target 5645 ++a; 5646 } 5647 #pragma omp target 5648 #pragma omp teams 5649 #pragma omp distribute 5650 for (int i = 0; i < 10; ++i) { 5651 #pragma omp teams // expected-error {{region cannot be closely nested inside 'distribute' region; perhaps you forget to enclose 'omp teams' directive into a target region?}} 5652 ++a; 5653 } 5654 return foo<int>(); 5655 } 5656 5657