Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -fsyntax-only -fopenmp=libiomp5 -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 
    104 // SIMD DIRECTIVE
    105 #pragma omp simd
    106   for (int i = 0; i < 10; ++i) {
    107 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    108     for (int i = 0; i < 10; ++i)
    109       ;
    110   }
    111 #pragma omp simd
    112   for (int i = 0; i < 10; ++i) {
    113 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    114     for (int i = 0; i < 10; ++i)
    115       ;
    116   }
    117 #pragma omp simd
    118   for (int i = 0; i < 10; ++i) {
    119 #pragma omp for simd // 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 parallel // 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 sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    132     {
    133       bar();
    134     }
    135   }
    136 #pragma omp simd
    137   for (int i = 0; i < 10; ++i) {
    138 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    139     {
    140       bar();
    141     }
    142   }
    143 #pragma omp simd
    144   for (int i = 0; i < 10; ++i) {
    145 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    146     {
    147       bar();
    148     }
    149   }
    150 #pragma omp simd
    151   for (int i = 0; i < 10; ++i) {
    152 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    153     {
    154       bar();
    155     }
    156   }
    157 #pragma omp simd
    158   for (int i = 0; i < 10; ++i) {
    159 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    160     {
    161       bar();
    162     }
    163   }
    164 #pragma omp simd
    165   for (int i = 0; i < 10; ++i) {
    166 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    167     for (int i = 0; i < 10; ++i)
    168       ;
    169   }
    170 #pragma omp simd
    171   for (int i = 0; i < 10; ++i) {
    172 #pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    173     for (int i = 0; i < 10; ++i)
    174       ;
    175   }
    176 #pragma omp simd
    177   for (int i = 0; i < 10; ++i) {
    178 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    179     {
    180       bar();
    181     }
    182   }
    183 #pragma omp simd
    184   for (int i = 0; i < 10; ++i) {
    185 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    186     {
    187       bar();
    188     }
    189   }
    190 #pragma omp simd
    191   for (int i = 0; i < 10; ++i) {
    192 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    193     bar();
    194   }
    195 #pragma omp simd
    196   for (int i = 0; i < 10; ++i) {
    197 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    198     bar();
    199   }
    200 #pragma omp simd
    201   for (int i = 0; i < 10; ++i) {
    202 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    203     bar();
    204   }
    205 #pragma omp simd
    206   for (int i = 0; i < 10; ++i) {
    207 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    208     bar();
    209   }
    210 #pragma omp simd
    211   for (int i = 0; i < 10; ++i) {
    212 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    213     bar();
    214   }
    215 #pragma omp simd
    216   for (int i = 0; i < 10; ++i) {
    217 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    218     ++a;
    219   }
    220 #pragma omp simd
    221   for (int i = 0; i < 10; ++i) {
    222 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    223     ++a;
    224   }
    225 #pragma omp simd
    226   for (int i = 0; i < 10; ++i) {
    227 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    228     ++a;
    229   }
    230 
    231 // FOR DIRECTIVE
    232 #pragma omp for
    233   for (int i = 0; i < 10; ++i) {
    234 #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?}}
    235     for (int i = 0; i < 10; ++i)
    236       ;
    237   }
    238 #pragma omp for
    239   for (int i = 0; i < 10; ++i) {
    240 #pragma omp simd
    241     for (int i = 0; i < 10; ++i)
    242       ;
    243   }
    244 #pragma omp for
    245   for (int i = 0; i < 10; ++i) {
    246 #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?}}
    247     for (int i = 0; i < 10; ++i)
    248       ;
    249   }
    250 #pragma omp for
    251   for (int i = 0; i < 10; ++i) {
    252 #pragma omp parallel
    253     for (int i = 0; i < 10; ++i)
    254       ;
    255   }
    256 #pragma omp for
    257   for (int i = 0; i < 10; ++i) {
    258 #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?}}
    259     {
    260       bar();
    261     }
    262   }
    263 #pragma omp for
    264   for (int i = 0; i < 10; ++i) {
    265 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a for region}}
    266     {
    267       bar();
    268     }
    269   }
    270 #pragma omp for
    271   for (int i = 0; i < 10; ++i) {
    272 #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?}}
    273     {
    274       bar();
    275     }
    276   }
    277 
    278 #pragma omp for
    279   for (int i = 0; i < 10; ++i) {
    280 #pragma omp master // expected-error {{region cannot be closely nested inside 'for' region}}
    281     {
    282       bar();
    283     }
    284   }
    285 #pragma omp for
    286   for (int i = 0; i < 10; ++i) {
    287 #pragma omp critical
    288     {
    289       bar();
    290     }
    291   }
    292 #pragma omp for
    293   for (int i = 0; i < 10; ++i) {
    294 #pragma omp parallel
    295     {
    296 #pragma omp single // OK
    297       {
    298         bar();
    299       }
    300 #pragma omp for // OK
    301       for (int i = 0; i < 10; ++i)
    302         ;
    303 #pragma omp sections // OK
    304       {
    305         bar();
    306       }
    307     }
    308   }
    309 #pragma omp for
    310   for (int i = 0; i < 10; ++i) {
    311 #pragma omp parallel for
    312     for (int i = 0; i < 10; ++i)
    313       ;
    314   }
    315 #pragma omp for
    316   for (int i = 0; i < 10; ++i) {
    317 #pragma omp parallel for simd
    318     for (int i = 0; i < 10; ++i)
    319       ;
    320   }
    321 #pragma omp for
    322   for (int i = 0; i < 10; ++i) {
    323 #pragma omp parallel sections
    324     {
    325       bar();
    326     }
    327   }
    328 #pragma omp for
    329   for (int i = 0; i < 10; ++i) {
    330 #pragma omp task
    331     {
    332       bar();
    333     }
    334   }
    335 #pragma omp for
    336   for (int i = 0; i < 10; ++i) {
    337 #pragma omp taskyield
    338     bar();
    339   }
    340 #pragma omp for
    341   for (int i = 0; i < 10; ++i) {
    342 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'for' region}}
    343     bar();
    344   }
    345 #pragma omp for
    346   for (int i = 0; i < 10; ++i) {
    347 #pragma omp taskwait
    348     bar();
    349   }
    350 #pragma omp for
    351   for (int i = 0; i < 10; ++i) {
    352 #pragma omp flush
    353     bar();
    354   }
    355 #pragma omp for
    356   for (int i = 0; i < 10; ++i) {
    357 #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?}}
    358     bar();
    359   }
    360 #pragma omp for ordered
    361   for (int i = 0; i < 10; ++i) {
    362 #pragma omp ordered // OK
    363     bar();
    364   }
    365 #pragma omp for
    366   for (int i = 0; i < 10; ++i) {
    367 #pragma omp atomic
    368     ++a;
    369   }
    370 #pragma omp for
    371   for (int i = 0; i < 10; ++i) {
    372 #pragma omp target
    373     ++a;
    374   }
    375 #pragma omp for
    376   for (int i = 0; i < 10; ++i) {
    377 #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?}}
    378     ++a;
    379   }
    380 
    381 // FOR SIMD DIRECTIVE
    382 #pragma omp for simd
    383   for (int i = 0; i < 10; ++i) {
    384 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    385     for (int i = 0; i < 10; ++i)
    386       ;
    387   }
    388 #pragma omp for simd
    389   for (int i = 0; i < 10; ++i) {
    390 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    391     for (int i = 0; i < 10; ++i)
    392       ;
    393   }
    394 #pragma omp for simd
    395   for (int i = 0; i < 10; ++i) {
    396 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    397     for (int i = 0; i < 10; ++i)
    398       ;
    399   }
    400 #pragma omp for simd
    401   for (int i = 0; i < 10; ++i) {
    402 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    403     for (int i = 0; i < 10; ++i)
    404       ;
    405   }
    406 #pragma omp for simd
    407   for (int i = 0; i < 10; ++i) {
    408 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    409     {
    410       bar();
    411     }
    412   }
    413 #pragma omp for simd
    414   for (int i = 0; i < 10; ++i) {
    415 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    416     {
    417       bar();
    418     }
    419   }
    420 #pragma omp for simd
    421   for (int i = 0; i < 10; ++i) {
    422 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    423     {
    424       bar();
    425     }
    426   }
    427 #pragma omp for simd
    428   for (int i = 0; i < 10; ++i) {
    429 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    430     {
    431       bar();
    432     }
    433   }
    434 #pragma omp for simd
    435   for (int i = 0; i < 10; ++i) {
    436 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    437     {
    438       bar();
    439     }
    440   }
    441 #pragma omp for simd
    442   for (int i = 0; i < 10; ++i) {
    443 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    444     for (int i = 0; i < 10; ++i)
    445       ;
    446   }
    447 #pragma omp for simd
    448   for (int i = 0; i < 10; ++i) {
    449 #pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    450     for (int i = 0; i < 10; ++i)
    451       ;
    452   }
    453 #pragma omp for simd
    454   for (int i = 0; i < 10; ++i) {
    455 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    456     {
    457       bar();
    458     }
    459   }
    460 #pragma omp for simd
    461   for (int i = 0; i < 10; ++i) {
    462 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    463     {
    464       bar();
    465     }
    466   }
    467 #pragma omp for simd
    468   for (int i = 0; i < 10; ++i) {
    469 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    470     bar();
    471   }
    472 #pragma omp for simd
    473   for (int i = 0; i < 10; ++i) {
    474 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    475     bar();
    476   }
    477 #pragma omp for simd
    478   for (int i = 0; i < 10; ++i) {
    479 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    480     bar();
    481   }
    482 #pragma omp for simd
    483   for (int i = 0; i < 10; ++i) {
    484 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    485     bar();
    486   }
    487 #pragma omp for simd
    488   for (int i = 0; i < 10; ++i) {
    489 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    490     bar();
    491   }
    492 #pragma omp for simd
    493   for (int i = 0; i < 10; ++i) {
    494 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    495     ++a;
    496   }
    497 #pragma omp for simd
    498   for (int i = 0; i < 10; ++i) {
    499 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    500     ++a;
    501   }
    502 #pragma omp for simd
    503   for (int i = 0; i < 10; ++i) {
    504 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
    505     ++a;
    506   }
    507 
    508 // SECTIONS DIRECTIVE
    509 #pragma omp sections
    510   {
    511 #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?}}
    512     for (int i = 0; i < 10; ++i)
    513       ;
    514   }
    515 #pragma omp sections
    516   {
    517 #pragma omp simd
    518     for (int i = 0; i < 10; ++i)
    519       ;
    520   }
    521 #pragma omp sections
    522   {
    523 #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?}}
    524     for (int i = 0; i < 10; ++i)
    525       ;
    526   }
    527 #pragma omp sections
    528   {
    529 #pragma omp parallel
    530     for (int i = 0; i < 10; ++i)
    531       ;
    532   }
    533 #pragma omp sections
    534   {
    535 #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?}}
    536     {
    537       bar();
    538     }
    539   }
    540 #pragma omp sections
    541   {
    542 #pragma omp section
    543     {
    544       bar();
    545     }
    546   }
    547 #pragma omp sections
    548   {
    549 #pragma omp parallel
    550     {
    551 #pragma omp single // OK
    552       {
    553         bar();
    554       }
    555 #pragma omp for // OK
    556       for (int i = 0; i < 10; ++i)
    557         ;
    558 #pragma omp sections // OK
    559       {
    560         bar();
    561       }
    562     }
    563   }
    564 #pragma omp sections
    565   {
    566 #pragma omp parallel
    567     {
    568 #pragma omp master // OK
    569       {
    570         bar();
    571       }
    572 #pragma omp for // OK
    573       for (int i = 0; i < 10; ++i)
    574         ;
    575 #pragma omp master // OK
    576       {
    577         bar();
    578       }
    579     }
    580 #pragma omp master // expected-error {{region cannot be closely nested inside 'sections' region}}
    581     bar();
    582   }
    583 #pragma omp sections
    584   {
    585 #pragma omp parallel
    586     {
    587 #pragma omp critical(A) // OK
    588       {
    589         bar();
    590       }
    591 #pragma omp for // OK
    592       for (int i = 0; i < 10; ++i)
    593         ;
    594 #pragma omp critical // OK
    595       {
    596         bar();
    597       }
    598     }
    599 #pragma omp critical(A) // expected-error {{statement in 'omp sections' directive must be enclosed into a section region}}
    600     bar();
    601   }
    602 #pragma omp sections
    603   {
    604 #pragma omp parallel for
    605     for (int i = 0; i < 10; ++i)
    606       ;
    607   }
    608 #pragma omp sections
    609   {
    610 #pragma omp parallel for simd
    611     for (int i = 0; i < 10; ++i)
    612       ;
    613   }
    614 #pragma omp sections
    615   {
    616 #pragma omp parallel sections
    617     {
    618       bar();
    619     }
    620   }
    621 #pragma omp sections
    622   {
    623 #pragma omp task
    624     {
    625       bar();
    626     }
    627   }
    628 #pragma omp sections
    629   {
    630 #pragma omp taskyield
    631   }
    632 #pragma omp sections
    633   {
    634 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'sections' region}}
    635   }
    636 #pragma omp sections
    637   {
    638 #pragma omp taskwait
    639   }
    640 #pragma omp sections
    641   {
    642 #pragma omp flush
    643   }
    644 #pragma omp sections
    645   {
    646 #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?}}
    647     bar();
    648   }
    649 #pragma omp sections
    650   {
    651 #pragma omp atomic
    652     ++a;
    653   }
    654 #pragma omp sections
    655   {
    656 #pragma omp target
    657     ++a;
    658   }
    659 #pragma omp sections
    660   {
    661 #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?}}
    662     ++a;
    663   }
    664 
    665 // SECTION DIRECTIVE
    666 #pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
    667   {
    668     bar();
    669   }
    670 #pragma omp sections
    671   {
    672 #pragma omp section
    673     {
    674 #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?}}
    675       for (int i = 0; i < 10; ++i)
    676         ;
    677     }
    678   }
    679 #pragma omp sections
    680   {
    681 #pragma omp section
    682     {
    683 #pragma omp simd
    684       for (int i = 0; i < 10; ++i)
    685         ;
    686     }
    687   }
    688 #pragma omp sections
    689   {
    690 #pragma omp section
    691     {
    692 #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?}}
    693       for (int i = 0; i < 10; ++i)
    694         ;
    695     }
    696   }
    697 #pragma omp sections
    698   {
    699 #pragma omp section
    700     {
    701 #pragma omp parallel
    702       for (int i = 0; i < 10; ++i)
    703         ;
    704     }
    705   }
    706 #pragma omp sections
    707   {
    708 #pragma omp section
    709     {
    710 #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?}}
    711       {
    712         bar();
    713       }
    714     }
    715   }
    716 #pragma omp sections
    717   {
    718 #pragma omp section
    719     {
    720 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a section region}}
    721       {
    722         bar();
    723       }
    724     }
    725   }
    726 #pragma omp sections
    727   {
    728 #pragma omp section
    729     {
    730 #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?}}
    731       bar();
    732 #pragma omp master // expected-error {{region cannot be closely nested inside 'section' region}}
    733       bar();
    734 #pragma omp critical
    735       bar();
    736     }
    737   }
    738 #pragma omp sections
    739   {
    740 #pragma omp section
    741     {
    742 #pragma omp parallel
    743       {
    744 #pragma omp single // OK
    745         {
    746           bar();
    747         }
    748 #pragma omp for // OK
    749         for (int i = 0; i < 10; ++i)
    750           ;
    751 #pragma omp for simd // OK
    752         for (int i = 0; i < 10; ++i)
    753           ;
    754 #pragma omp sections // OK
    755         {
    756           bar();
    757         }
    758       }
    759     }
    760   }
    761 #pragma omp sections
    762   {
    763 #pragma omp section
    764     {
    765 #pragma omp parallel for
    766       for (int i = 0; i < 10; ++i)
    767         ;
    768     }
    769   }
    770 #pragma omp sections
    771   {
    772 #pragma omp section
    773     {
    774 #pragma omp parallel for simd
    775       for (int i = 0; i < 10; ++i)
    776         ;
    777     }
    778   }
    779 #pragma omp sections
    780   {
    781 #pragma omp section
    782     {
    783 #pragma omp parallel sections
    784       {
    785         bar();
    786       }
    787     }
    788   }
    789 #pragma omp sections
    790   {
    791 #pragma omp section
    792     {
    793 #pragma omp task
    794       {
    795         bar();
    796       }
    797     }
    798   }
    799 #pragma omp sections
    800   {
    801 #pragma omp section
    802     {
    803 #pragma omp taskyield
    804       bar();
    805     }
    806   }
    807 #pragma omp sections
    808   {
    809 #pragma omp section
    810     {
    811 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'section' region}}
    812       bar();
    813     }
    814   }
    815 #pragma omp sections
    816   {
    817 #pragma omp section
    818     {
    819 #pragma omp taskwait
    820       bar();
    821     }
    822   }
    823 #pragma omp sections
    824   {
    825 #pragma omp section
    826     {
    827 #pragma omp flush
    828       bar();
    829     }
    830   }
    831 #pragma omp sections
    832   {
    833 #pragma omp section
    834     {
    835 #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?}}
    836       bar();
    837     }
    838   }
    839 #pragma omp sections
    840   {
    841 #pragma omp section
    842 #pragma omp atomic
    843     ++a;
    844   }
    845 #pragma omp sections
    846   {
    847 #pragma omp section
    848 #pragma omp target
    849     ++a;
    850   }
    851 #pragma omp sections
    852   {
    853 #pragma omp section
    854 #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?}}
    855     ++a;
    856   }
    857 
    858 // SINGLE DIRECTIVE
    859 #pragma omp single
    860   {
    861 #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?}}
    862     for (int i = 0; i < 10; ++i)
    863       ;
    864   }
    865 #pragma omp single
    866   {
    867 #pragma omp simd
    868     for (int i = 0; i < 10; ++i)
    869       ;
    870   }
    871 #pragma omp single
    872   {
    873 #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?}}
    874     for (int i = 0; i < 10; ++i)
    875       ;
    876   }
    877 #pragma omp single
    878   {
    879 #pragma omp parallel
    880     for (int i = 0; i < 10; ++i)
    881       ;
    882   }
    883 #pragma omp single
    884   {
    885 #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?}}
    886     {
    887       bar();
    888     }
    889   }
    890 #pragma omp single
    891   {
    892 #pragma omp master // expected-error {{region cannot be closely nested inside 'single' region}}
    893     {
    894       bar();
    895     }
    896   }
    897 #pragma omp single
    898   {
    899 #pragma omp critical
    900     {
    901       bar();
    902     }
    903   }
    904 #pragma omp single
    905   {
    906 #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?}}
    907     {
    908       bar();
    909     }
    910   }
    911 #pragma omp single
    912   {
    913 #pragma omp parallel
    914     {
    915 #pragma omp single // OK
    916       {
    917         bar();
    918       }
    919 #pragma omp for // OK
    920       for (int i = 0; i < 10; ++i)
    921         ;
    922 #pragma omp for simd // OK
    923       for (int i = 0; i < 10; ++i)
    924         ;
    925 #pragma omp sections // OK
    926       {
    927         bar();
    928       }
    929     }
    930   }
    931 #pragma omp single
    932   {
    933 #pragma omp parallel for
    934     for (int i = 0; i < 10; ++i)
    935       ;
    936   }
    937 #pragma omp single
    938   {
    939 #pragma omp parallel for simd
    940     for (int i = 0; i < 10; ++i)
    941       ;
    942   }
    943 #pragma omp single
    944   {
    945 #pragma omp parallel sections
    946     {
    947       bar();
    948     }
    949   }
    950 #pragma omp single
    951   {
    952 #pragma omp task
    953     {
    954       bar();
    955     }
    956   }
    957 #pragma omp single
    958   {
    959 #pragma omp taskyield
    960     bar();
    961   }
    962 #pragma omp single
    963   {
    964 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'single' region}}
    965     bar();
    966   }
    967 #pragma omp single
    968   {
    969 #pragma omp taskwait
    970     bar();
    971   }
    972 #pragma omp single
    973   {
    974 #pragma omp flush
    975     bar();
    976   }
    977 #pragma omp single
    978   {
    979 #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?}}
    980     bar();
    981   }
    982 #pragma omp single
    983   {
    984 #pragma omp atomic
    985     ++a;
    986   }
    987 #pragma omp single
    988   {
    989 #pragma omp target
    990     ++a;
    991   }
    992 #pragma omp single
    993   {
    994 #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?}}
    995     ++a;
    996   }
    997 
    998 // MASTER DIRECTIVE
    999 #pragma omp master
   1000   {
   1001 #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?}}
   1002     for (int i = 0; i < 10; ++i)
   1003       ;
   1004   }
   1005 #pragma omp master
   1006   {
   1007 #pragma omp simd
   1008     for (int i = 0; i < 10; ++i)
   1009       ;
   1010   }
   1011 #pragma omp master
   1012   {
   1013 #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?}}
   1014     for (int i = 0; i < 10; ++i)
   1015       ;
   1016   }
   1017 #pragma omp master
   1018   {
   1019 #pragma omp parallel
   1020     for (int i = 0; i < 10; ++i)
   1021       ;
   1022   }
   1023 #pragma omp master
   1024   {
   1025 #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?}}
   1026     {
   1027       bar();
   1028     }
   1029   }
   1030 #pragma omp master
   1031   {
   1032 #pragma omp master // OK, though second 'master' is redundant
   1033     {
   1034       bar();
   1035     }
   1036   }
   1037 #pragma omp master
   1038   {
   1039 #pragma omp critical
   1040     {
   1041       bar();
   1042     }
   1043   }
   1044 #pragma omp master
   1045   {
   1046 #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?}}
   1047     {
   1048       bar();
   1049     }
   1050   }
   1051 #pragma omp master
   1052   {
   1053 #pragma omp parallel
   1054     {
   1055 #pragma omp master // OK
   1056       {
   1057         bar();
   1058       }
   1059 #pragma omp for // OK
   1060       for (int i = 0; i < 10; ++i)
   1061         ;
   1062 #pragma omp for simd // OK
   1063       for (int i = 0; i < 10; ++i)
   1064         ;
   1065 #pragma omp sections // OK
   1066       {
   1067         bar();
   1068       }
   1069     }
   1070   }
   1071 #pragma omp master
   1072   {
   1073 #pragma omp parallel for
   1074     for (int i = 0; i < 10; ++i)
   1075       ;
   1076   }
   1077 #pragma omp master
   1078   {
   1079 #pragma omp parallel for simd
   1080     for (int i = 0; i < 10; ++i)
   1081       ;
   1082   }
   1083 #pragma omp master
   1084   {
   1085 #pragma omp parallel sections
   1086     {
   1087       bar();
   1088     }
   1089   }
   1090 #pragma omp master
   1091   {
   1092 #pragma omp task
   1093     {
   1094       bar();
   1095     }
   1096   }
   1097 #pragma omp master
   1098   {
   1099 #pragma omp taskyield
   1100     bar();
   1101   }
   1102 #pragma omp master
   1103   {
   1104 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'master' region}}
   1105     bar();
   1106   }
   1107 #pragma omp master
   1108   {
   1109 #pragma omp taskwait
   1110     bar();
   1111   }
   1112 #pragma omp master
   1113   {
   1114 #pragma omp flush
   1115     bar();
   1116   }
   1117 #pragma omp master
   1118   {
   1119 #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?}}
   1120     bar();
   1121   }
   1122 #pragma omp master
   1123   {
   1124 #pragma omp atomic
   1125     ++a;
   1126   }
   1127 #pragma omp master
   1128   {
   1129 #pragma omp target
   1130     ++a;
   1131   }
   1132 #pragma omp master
   1133   {
   1134 #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?}}
   1135     ++a;
   1136   }
   1137 
   1138 // CRITICAL DIRECTIVE
   1139 #pragma omp critical
   1140   {
   1141 #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?}}
   1142     for (int i = 0; i < 10; ++i)
   1143       ;
   1144   }
   1145 #pragma omp critical
   1146   {
   1147 #pragma omp simd
   1148     for (int i = 0; i < 10; ++i)
   1149       ;
   1150   }
   1151 #pragma omp critical
   1152   {
   1153 #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?}}
   1154     for (int i = 0; i < 10; ++i)
   1155       ;
   1156   }
   1157 #pragma omp critical
   1158   {
   1159 #pragma omp parallel
   1160     for (int i = 0; i < 10; ++i)
   1161       ;
   1162   }
   1163 #pragma omp critical
   1164   {
   1165 #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?}}
   1166     {
   1167       bar();
   1168     }
   1169   }
   1170 #pragma omp critical
   1171   {
   1172 #pragma omp master // OK, though second 'master' is redundant
   1173     {
   1174       bar();
   1175     }
   1176   }
   1177 #pragma omp critical
   1178   {
   1179 #pragma omp critical
   1180     {
   1181       bar();
   1182     }
   1183   }
   1184 #pragma omp critical
   1185   {
   1186 #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?}}
   1187     {
   1188       bar();
   1189     }
   1190   }
   1191 #pragma omp critical
   1192   {
   1193 #pragma omp parallel
   1194     {
   1195 #pragma omp master // OK
   1196       {
   1197         bar();
   1198       }
   1199 #pragma omp for // OK
   1200       for (int i = 0; i < 10; ++i)
   1201         ;
   1202 #pragma omp for simd // OK
   1203       for (int i = 0; i < 10; ++i)
   1204         ;
   1205 #pragma omp sections // OK
   1206       {
   1207         bar();
   1208       }
   1209     }
   1210   }
   1211 #pragma omp critical
   1212   {
   1213 #pragma omp parallel for
   1214     for (int i = 0; i < 10; ++i)
   1215       ;
   1216   }
   1217 #pragma omp critical
   1218   {
   1219 #pragma omp parallel for simd
   1220     for (int i = 0; i < 10; ++i)
   1221       ;
   1222   }
   1223 #pragma omp critical
   1224   {
   1225 #pragma omp parallel sections
   1226     {
   1227       bar();
   1228     }
   1229   }
   1230 #pragma omp critical
   1231   {
   1232 #pragma omp task
   1233     {
   1234       bar();
   1235     }
   1236   }
   1237 #pragma omp critical
   1238   {
   1239 #pragma omp taskyield
   1240     bar();
   1241   }
   1242 #pragma omp critical
   1243   {
   1244 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'critical' region}}
   1245     bar();
   1246   }
   1247 #pragma omp critical
   1248   {
   1249 #pragma omp taskwait
   1250     bar();
   1251   }
   1252 #pragma omp critical(Tuzik)
   1253   {
   1254 #pragma omp critical(grelka)
   1255     bar();
   1256   }
   1257 #pragma omp critical(Belka) // expected-note {{previous 'critical' region starts here}}
   1258   {
   1259 #pragma omp critical(Belka) // expected-error {{cannot nest 'critical' regions having the same name 'Belka'}}
   1260     {
   1261 #pragma omp critical(Tuzik)
   1262       {
   1263 #pragma omp parallel
   1264 #pragma omp critical(grelka)
   1265         {
   1266           bar();
   1267         }
   1268       }
   1269     }
   1270   }
   1271 #pragma omp critical
   1272   {
   1273 #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?}}
   1274     bar();
   1275   }
   1276 #pragma omp critical
   1277   {
   1278 #pragma omp atomic
   1279     ++a;
   1280   }
   1281 #pragma omp critical
   1282   {
   1283 #pragma omp target
   1284     ++a;
   1285   }
   1286 #pragma omp critical
   1287   {
   1288 #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?}}
   1289     ++a;
   1290   }
   1291 
   1292 // PARALLEL FOR DIRECTIVE
   1293 #pragma omp parallel for
   1294   for (int i = 0; i < 10; ++i) {
   1295 #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?}}
   1296     for (int i = 0; i < 10; ++i)
   1297       ;
   1298   }
   1299 #pragma omp parallel for
   1300   for (int i = 0; i < 10; ++i) {
   1301 #pragma omp simd
   1302     for (int i = 0; i < 10; ++i)
   1303       ;
   1304   }
   1305 #pragma omp parallel for
   1306   for (int i = 0; i < 10; ++i) {
   1307 #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?}}
   1308     for (int i = 0; i < 10; ++i)
   1309       ;
   1310   }
   1311 #pragma omp parallel for
   1312   for (int i = 0; i < 10; ++i) {
   1313 #pragma omp parallel
   1314     for (int i = 0; i < 10; ++i)
   1315       ;
   1316   }
   1317 #pragma omp parallel for
   1318   for (int i = 0; i < 10; ++i) {
   1319 #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?}}
   1320     {
   1321       bar();
   1322     }
   1323   }
   1324 #pragma omp parallel for
   1325   for (int i = 0; i < 10; ++i) {
   1326 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a parallel for region}}
   1327     {
   1328       bar();
   1329     }
   1330   }
   1331 #pragma omp parallel for
   1332   for (int i = 0; i < 10; ++i) {
   1333 #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?}}
   1334     {
   1335       bar();
   1336     }
   1337   }
   1338 
   1339 #pragma omp parallel for
   1340   for (int i = 0; i < 10; ++i) {
   1341 #pragma omp master // expected-error {{region cannot be closely nested inside 'parallel for' region}}
   1342     {
   1343       bar();
   1344     }
   1345   }
   1346 
   1347 #pragma omp parallel for
   1348   for (int i = 0; i < 10; ++i) {
   1349 #pragma omp critical
   1350     {
   1351       bar();
   1352     }
   1353   }
   1354 
   1355 #pragma omp parallel for
   1356   for (int i = 0; i < 10; ++i) {
   1357 #pragma omp parallel
   1358     {
   1359 #pragma omp single // OK
   1360       {
   1361         bar();
   1362       }
   1363 #pragma omp for // OK
   1364       for (int i = 0; i < 10; ++i)
   1365         ;
   1366 #pragma omp for simd // OK
   1367       for (int i = 0; i < 10; ++i)
   1368         ;
   1369 #pragma omp sections // OK
   1370       {
   1371         bar();
   1372       }
   1373     }
   1374   }
   1375 #pragma omp parallel for
   1376   for (int i = 0; i < 10; ++i) {
   1377 #pragma omp parallel for
   1378     for (int i = 0; i < 10; ++i)
   1379       ;
   1380   }
   1381 #pragma omp parallel for
   1382   for (int i = 0; i < 10; ++i) {
   1383 #pragma omp parallel for simd
   1384     for (int i = 0; i < 10; ++i)
   1385       ;
   1386   }
   1387 #pragma omp parallel for
   1388   for (int i = 0; i < 10; ++i) {
   1389 #pragma omp parallel sections
   1390     {
   1391       bar();
   1392     }
   1393   }
   1394 #pragma omp parallel for
   1395   for (int i = 0; i < 10; ++i) {
   1396 #pragma omp task
   1397     {
   1398       bar();
   1399     }
   1400   }
   1401 #pragma omp parallel for
   1402   for (int i = 0; i < 10; ++i) {
   1403 #pragma omp taskyield
   1404     bar();
   1405   }
   1406 #pragma omp parallel for
   1407   for (int i = 0; i < 10; ++i) {
   1408 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel for' region}}
   1409     bar();
   1410   }
   1411 #pragma omp parallel for
   1412   for (int i = 0; i < 10; ++i) {
   1413 #pragma omp taskwait
   1414     bar();
   1415   }
   1416 #pragma omp parallel for
   1417   for (int i = 0; i < 10; ++i) {
   1418 #pragma omp flush
   1419     bar();
   1420   }
   1421 #pragma omp parallel for
   1422   for (int i = 0; i < 10; ++i) {
   1423 #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?}}
   1424     bar();
   1425   }
   1426 #pragma omp parallel for ordered
   1427   for (int i = 0; i < 10; ++i) {
   1428 #pragma omp ordered // OK
   1429     bar();
   1430   }
   1431 #pragma omp parallel for
   1432   for (int i = 0; i < 10; ++i) {
   1433 #pragma omp atomic
   1434     ++a;
   1435   }
   1436 #pragma omp parallel for
   1437   for (int i = 0; i < 10; ++i) {
   1438 #pragma omp target
   1439     ++a;
   1440   }
   1441 #pragma omp parallel for
   1442   for (int i = 0; i < 10; ++i) {
   1443 #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?}}
   1444     ++a;
   1445   }
   1446 
   1447 // PARALLEL FOR SIMD DIRECTIVE
   1448 #pragma omp parallel for simd
   1449   for (int i = 0; i < 10; ++i) {
   1450 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1451     for (int i = 0; i < 10; ++i)
   1452       ;
   1453   }
   1454 #pragma omp parallel for simd
   1455   for (int i = 0; i < 10; ++i) {
   1456 #pragma omp simd// expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1457     for (int i = 0; i < 10; ++i)
   1458       ;
   1459   }
   1460 #pragma omp parallel for simd
   1461   for (int i = 0; i < 10; ++i) {
   1462 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1463     for (int i = 0; i < 10; ++i)
   1464       ;
   1465   }
   1466 #pragma omp parallel for simd
   1467   for (int i = 0; i < 10; ++i) {
   1468 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1469     for (int i = 0; i < 10; ++i)
   1470       ;
   1471   }
   1472 #pragma omp parallel for simd
   1473   for (int i = 0; i < 10; ++i) {
   1474 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1475     {
   1476       bar();
   1477     }
   1478   }
   1479 #pragma omp parallel for simd
   1480   for (int i = 0; i < 10; ++i) {
   1481 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1482     {
   1483       bar();
   1484     }
   1485   }
   1486 #pragma omp parallel for simd
   1487   for (int i = 0; i < 10; ++i) {
   1488 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1489     {
   1490       bar();
   1491     }
   1492   }
   1493 
   1494 #pragma omp parallel for simd
   1495   for (int i = 0; i < 10; ++i) {
   1496 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1497     {
   1498       bar();
   1499     }
   1500   }
   1501 
   1502 #pragma omp parallel for simd
   1503   for (int i = 0; i < 10; ++i) {
   1504 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1505     {
   1506       bar();
   1507     }
   1508   }
   1509 
   1510 #pragma omp parallel for simd
   1511   for (int i = 0; i < 10; ++i) {
   1512 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1513     {
   1514 #pragma omp single
   1515       {
   1516         bar();
   1517       }
   1518 #pragma omp for
   1519       for (int i = 0; i < 10; ++i)
   1520         ;
   1521 #pragma omp for simd
   1522       for (int i = 0; i < 10; ++i)
   1523         ;
   1524 #pragma omp sections
   1525       {
   1526         bar();
   1527       }
   1528     }
   1529   }
   1530 #pragma omp parallel for simd
   1531   for (int i = 0; i < 10; ++i) {
   1532 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1533     for (int i = 0; i < 10; ++i)
   1534       ;
   1535   }
   1536 #pragma omp parallel for simd
   1537   for (int i = 0; i < 10; ++i) {
   1538 #pragma omp parallel for simd// expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1539     for (int i = 0; i < 10; ++i)
   1540       ;
   1541   }
   1542 #pragma omp parallel for simd
   1543   for (int i = 0; i < 10; ++i) {
   1544 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1545     {
   1546       bar();
   1547     }
   1548   }
   1549 #pragma omp parallel for simd
   1550   for (int i = 0; i < 10; ++i) {
   1551 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1552     {
   1553       bar();
   1554     }
   1555   }
   1556 #pragma omp parallel for simd
   1557   for (int i = 0; i < 10; ++i) {
   1558 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1559     bar();
   1560   }
   1561 #pragma omp parallel for simd
   1562   for (int i = 0; i < 10; ++i) {
   1563 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1564     bar();
   1565   }
   1566 #pragma omp parallel for simd
   1567   for (int i = 0; i < 10; ++i) {
   1568 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1569     bar();
   1570   }
   1571 #pragma omp parallel for simd
   1572   for (int i = 0; i < 10; ++i) {
   1573 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1574     bar();
   1575   }
   1576 #pragma omp parallel for simd
   1577   for (int i = 0; i < 10; ++i) {
   1578 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1579     bar();
   1580   }
   1581 #pragma omp parallel for simd
   1582   for (int i = 0; i < 10; ++i) {
   1583 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1584     bar();
   1585   }
   1586 #pragma omp parallel for simd
   1587   for (int i = 0; i < 10; ++i) {
   1588 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1589     ++a;
   1590   }
   1591 #pragma omp parallel for simd
   1592   for (int i = 0; i < 10; ++i) {
   1593 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1594     ++a;
   1595   }
   1596 #pragma omp parallel for simd
   1597   for (int i = 0; i < 10; ++i) {
   1598 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1599     ++a;
   1600   }
   1601 
   1602 // PARALLEL SECTIONS DIRECTIVE
   1603 #pragma omp parallel sections
   1604   {
   1605 #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?}}
   1606     for (int i = 0; i < 10; ++i)
   1607       ;
   1608   }
   1609 #pragma omp parallel sections
   1610   {
   1611 #pragma omp simd
   1612     for (int i = 0; i < 10; ++i)
   1613       ;
   1614   }
   1615 #pragma omp parallel sections
   1616   {
   1617 #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?}}
   1618     for (int i = 0; i < 10; ++i)
   1619       ;
   1620   }
   1621 #pragma omp parallel sections
   1622   {
   1623 #pragma omp parallel
   1624     for (int i = 0; i < 10; ++i)
   1625       ;
   1626   }
   1627 #pragma omp parallel sections
   1628   {
   1629 #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?}}
   1630     {
   1631       bar();
   1632     }
   1633   }
   1634 #pragma omp parallel sections
   1635   {
   1636 #pragma omp section
   1637     {
   1638       bar();
   1639     }
   1640   }
   1641 #pragma omp parallel sections
   1642   {
   1643 #pragma omp section
   1644     {
   1645 #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?}}
   1646       bar();
   1647     }
   1648   }
   1649 #pragma omp parallel sections
   1650   {
   1651 #pragma omp section
   1652     {
   1653 #pragma omp master // expected-error {{region cannot be closely nested inside 'section' region}}
   1654       bar();
   1655     }
   1656   }
   1657 #pragma omp parallel sections
   1658   {
   1659 #pragma omp section
   1660     {
   1661 #pragma omp critical
   1662       bar();
   1663     }
   1664   }
   1665 #pragma omp parallel sections
   1666   {
   1667 #pragma omp parallel
   1668     {
   1669 #pragma omp single // OK
   1670       {
   1671         bar();
   1672       }
   1673 #pragma omp for // OK
   1674       for (int i = 0; i < 10; ++i)
   1675         ;
   1676 #pragma omp for simd // OK
   1677       for (int i = 0; i < 10; ++i)
   1678         ;
   1679 #pragma omp sections // OK
   1680       {
   1681         bar();
   1682       }
   1683     }
   1684   }
   1685 #pragma omp parallel sections
   1686   {
   1687 #pragma omp parallel for
   1688     for (int i = 0; i < 10; ++i)
   1689       ;
   1690   }
   1691 #pragma omp parallel sections
   1692   {
   1693 #pragma omp parallel for simd
   1694     for (int i = 0; i < 10; ++i)
   1695       ;
   1696   }
   1697 #pragma omp parallel sections
   1698   {
   1699 #pragma omp parallel sections
   1700     {
   1701       bar();
   1702     }
   1703   }
   1704 #pragma omp parallel sections
   1705   {
   1706 #pragma omp task
   1707     {
   1708       bar();
   1709     }
   1710   }
   1711 #pragma omp parallel sections
   1712   {
   1713 #pragma omp taskyield
   1714   }
   1715 #pragma omp parallel sections
   1716   {
   1717 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel sections' region}}
   1718   }
   1719 #pragma omp parallel sections
   1720   {
   1721 #pragma omp taskwait
   1722   }
   1723 #pragma omp parallel sections
   1724   {
   1725 #pragma omp flush
   1726   }
   1727 #pragma omp parallel sections
   1728   {
   1729 #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?}}
   1730     bar();
   1731   }
   1732 #pragma omp parallel sections
   1733   {
   1734 #pragma omp atomic
   1735     ++a;
   1736   }
   1737 #pragma omp parallel sections
   1738   {
   1739 #pragma omp target
   1740     ++a;
   1741   }
   1742 #pragma omp parallel sections
   1743   {
   1744 #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?}}
   1745     ++a;
   1746   }
   1747 
   1748 // TASK DIRECTIVE
   1749 #pragma omp task
   1750 #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?}}
   1751   for (int i = 0; i < 10; ++i)
   1752     ;
   1753 #pragma omp task
   1754 #pragma omp simd
   1755   for (int i = 0; i < 10; ++i)
   1756     ;
   1757 #pragma omp task
   1758 #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?}}
   1759   for (int i = 0; i < 10; ++i)
   1760     ;
   1761 #pragma omp task
   1762 #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?}}
   1763   {
   1764     bar();
   1765   }
   1766 #pragma omp task
   1767 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a task region}}
   1768   {
   1769     bar();
   1770   }
   1771 #pragma omp task
   1772 #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?}}
   1773   bar();
   1774 #pragma omp task
   1775 #pragma omp master // expected-error {{region cannot be closely nested inside 'task' region}}
   1776   bar();
   1777 #pragma omp task
   1778 #pragma omp critical
   1779   bar();
   1780 
   1781 #pragma omp task
   1782 #pragma omp parallel for
   1783   for (int i = 0; i < 10; ++i)
   1784     ;
   1785 #pragma omp task
   1786 #pragma omp parallel for simd
   1787   for (int i = 0; i < 10; ++i)
   1788     ;
   1789 #pragma omp task
   1790 #pragma omp parallel sections
   1791   {
   1792     bar();
   1793   }
   1794 #pragma omp task
   1795 #pragma omp task
   1796   {
   1797     bar();
   1798   }
   1799 #pragma omp task
   1800   {
   1801 #pragma omp taskyield
   1802     bar();
   1803   }
   1804 #pragma omp task
   1805   {
   1806 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'task' region}}
   1807     bar();
   1808   }
   1809 #pragma omp task
   1810   {
   1811 #pragma omp taskwait
   1812     bar();
   1813   }
   1814 #pragma omp task
   1815   {
   1816 #pragma omp flush
   1817     bar();
   1818   }
   1819 #pragma omp task
   1820   {
   1821 #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?}}
   1822     bar();
   1823   }
   1824 #pragma omp task
   1825   {
   1826 #pragma omp atomic
   1827     ++a;
   1828   }
   1829 #pragma omp task
   1830   {
   1831 #pragma omp target
   1832     ++a;
   1833   }
   1834 #pragma omp task
   1835   {
   1836 #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?}}
   1837     ++a;
   1838   }
   1839 
   1840 // ORDERED DIRECTIVE
   1841 #pragma omp ordered
   1842   {
   1843 #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?}}
   1844     for (int i = 0; i < 10; ++i)
   1845       ;
   1846   }
   1847 #pragma omp ordered
   1848   {
   1849 #pragma omp simd
   1850     for (int i = 0; i < 10; ++i)
   1851       ;
   1852   }
   1853 #pragma omp ordered
   1854   {
   1855 #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?}}
   1856     for (int i = 0; i < 10; ++i)
   1857       ;
   1858   }
   1859 #pragma omp ordered
   1860   {
   1861 #pragma omp parallel
   1862     for (int i = 0; i < 10; ++i)
   1863       ;
   1864   }
   1865 #pragma omp ordered
   1866   {
   1867 #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?}}
   1868     {
   1869       bar();
   1870     }
   1871   }
   1872 #pragma omp ordered
   1873   {
   1874 #pragma omp master // OK, though second 'ordered' is redundant
   1875     {
   1876       bar();
   1877     }
   1878   }
   1879 #pragma omp ordered
   1880   {
   1881 #pragma omp critical
   1882     {
   1883       bar();
   1884     }
   1885   }
   1886 #pragma omp ordered
   1887   {
   1888 #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?}}
   1889     {
   1890       bar();
   1891     }
   1892   }
   1893 #pragma omp ordered
   1894   {
   1895 #pragma omp parallel for ordered
   1896     for (int j = 0; j < 10; ++j) {
   1897 #pragma omp ordered // OK
   1898       {
   1899         bar();
   1900       }
   1901     }
   1902   }
   1903 #pragma omp ordered
   1904   {
   1905 #pragma omp parallel for simd ordered //expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp parallel for simd'}}
   1906     for (int j = 0; j < 10; ++j) {
   1907 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   1908       {
   1909         bar();
   1910       }
   1911     }
   1912   }
   1913 #pragma omp ordered
   1914   {
   1915 #pragma omp parallel for
   1916     for (int i = 0; i < 10; ++i)
   1917       ;
   1918   }
   1919 #pragma omp ordered
   1920   {
   1921 #pragma omp parallel for simd
   1922     for (int i = 0; i < 10; ++i)
   1923       ;
   1924   }
   1925 #pragma omp ordered
   1926   {
   1927 #pragma omp parallel sections
   1928     {
   1929       bar();
   1930     }
   1931   }
   1932 #pragma omp ordered
   1933   {
   1934 #pragma omp task
   1935     {
   1936       bar();
   1937     }
   1938   }
   1939 #pragma omp ordered
   1940   {
   1941 #pragma omp taskyield
   1942     bar();
   1943   }
   1944 #pragma omp ordered
   1945   {
   1946 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'ordered' region}}
   1947     bar();
   1948   }
   1949 #pragma omp ordered
   1950   {
   1951 #pragma omp taskwait
   1952     bar();
   1953   }
   1954 #pragma omp ordered
   1955   {
   1956 #pragma omp flush
   1957     bar();
   1958   }
   1959 #pragma omp ordered
   1960   {
   1961 #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?}}
   1962     bar();
   1963   }
   1964 #pragma omp ordered
   1965   {
   1966 #pragma omp atomic
   1967     ++a;
   1968   }
   1969 #pragma omp ordered
   1970   {
   1971 #pragma omp target
   1972     ++a;
   1973   }
   1974 #pragma omp ordered
   1975   {
   1976 #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?}}
   1977     ++a;
   1978   }
   1979 
   1980 // ATOMIC DIRECTIVE
   1981 #pragma omp atomic
   1982   // 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}}
   1983   // expected-note@+1 {{expected an expression statement}}
   1984   {
   1985 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   1986     for (int i = 0; i < 10; ++i)
   1987       ;
   1988   }
   1989 #pragma omp atomic
   1990   // 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}}
   1991   // expected-note@+1 {{expected an expression statement}}
   1992   {
   1993 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   1994     for (int i = 0; i < 10; ++i)
   1995       ;
   1996   }
   1997 #pragma omp atomic
   1998   // 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}}
   1999   // expected-note@+1 {{expected an expression statement}}
   2000   {
   2001 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2002     for (int i = 0; i < 10; ++i)
   2003       ;
   2004   }
   2005 #pragma omp atomic
   2006   // 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}}
   2007   // expected-note@+1 {{expected an expression statement}}
   2008   {
   2009 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2010     for (int i = 0; i < 10; ++i)
   2011       ;
   2012   }
   2013 #pragma omp atomic
   2014   // 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}}
   2015   // expected-note@+1 {{expected an expression statement}}
   2016   {
   2017 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2018     {
   2019       bar();
   2020     }
   2021   }
   2022 #pragma omp atomic
   2023   // 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}}
   2024   // expected-note@+1 {{expected an expression statement}}
   2025   {
   2026 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2027     {
   2028       bar();
   2029     }
   2030   }
   2031 #pragma omp atomic
   2032   // 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}}
   2033   // expected-note@+1 {{expected an expression statement}}
   2034   {
   2035 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2036     {
   2037       bar();
   2038     }
   2039   }
   2040 #pragma omp atomic
   2041   // 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}}
   2042   // expected-note@+1 {{expected an expression statement}}
   2043   {
   2044 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2045     {
   2046       bar();
   2047     }
   2048   }
   2049 #pragma omp atomic
   2050   // 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}}
   2051   // expected-note@+1 {{expected an expression statement}}
   2052   {
   2053 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2054     {
   2055       bar();
   2056     }
   2057   }
   2058 #pragma omp atomic
   2059   // 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}}
   2060   // expected-note@+1 {{expected an expression statement}}
   2061   {
   2062 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2063     for (int i = 0; i < 10; ++i)
   2064       ;
   2065   }
   2066 #pragma omp atomic
   2067   // 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}}
   2068   // expected-note@+1 {{expected an expression statement}}
   2069   {
   2070 #pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2071     for (int i = 0; i < 10; ++i)
   2072       ;
   2073   }
   2074 #pragma omp atomic
   2075   // 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}}
   2076   // expected-note@+1 {{expected an expression statement}}
   2077   {
   2078 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2079     {
   2080       bar();
   2081     }
   2082   }
   2083 #pragma omp atomic
   2084   // 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}}
   2085   // expected-note@+1 {{expected an expression statement}}
   2086   {
   2087 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2088     {
   2089       bar();
   2090     }
   2091   }
   2092 #pragma omp atomic
   2093   // 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}}
   2094   // expected-note@+1 {{expected an expression statement}}
   2095   {
   2096 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2097     bar();
   2098   }
   2099 #pragma omp atomic
   2100   // 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}}
   2101   // expected-note@+1 {{expected an expression statement}}
   2102   {
   2103 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2104     bar();
   2105   }
   2106 #pragma omp atomic
   2107   // 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}}
   2108   // expected-note@+1 {{expected an expression statement}}
   2109   {
   2110 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2111     bar();
   2112   }
   2113 #pragma omp atomic
   2114   // 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}}
   2115   // expected-note@+1 {{expected an expression statement}}
   2116   {
   2117 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2118     bar();
   2119   }
   2120 #pragma omp atomic
   2121   // 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}}
   2122   // expected-note@+1 {{expected an expression statement}}
   2123   {
   2124 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2125     bar();
   2126   }
   2127 #pragma omp atomic
   2128   // 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}}
   2129   // expected-note@+1 {{expected an expression statement}}
   2130   {
   2131 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2132     ++a;
   2133   }
   2134 #pragma omp atomic
   2135   // 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}}
   2136   // expected-note@+1 {{expected an expression statement}}
   2137   {
   2138 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2139     ++a;
   2140   }
   2141 #pragma omp atomic
   2142   // 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}}
   2143   // expected-note@+1 {{expected an expression statement}}
   2144   {
   2145 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   2146     ++a;
   2147   }
   2148 
   2149 // TARGET DIRECTIVE
   2150 #pragma omp target
   2151 #pragma omp parallel
   2152   bar();
   2153 #pragma omp target
   2154 #pragma omp for
   2155   for (int i = 0; i < 10; ++i)
   2156     ;
   2157 #pragma omp target
   2158 #pragma omp simd
   2159   for (int i = 0; i < 10; ++i)
   2160     ;
   2161 #pragma omp target
   2162 #pragma omp for simd
   2163   for (int i = 0; i < 10; ++i)
   2164     ;
   2165 #pragma omp target
   2166 #pragma omp sections
   2167   {
   2168     bar();
   2169   }
   2170 #pragma omp target
   2171 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a target region}}
   2172   {
   2173     bar();
   2174   }
   2175 #pragma omp target
   2176 #pragma omp single
   2177   bar();
   2178 
   2179 #pragma omp target
   2180 #pragma omp master
   2181   {
   2182     bar();
   2183   }
   2184 #pragma omp target
   2185 #pragma omp critical
   2186   {
   2187     bar();
   2188   }
   2189 #pragma omp target
   2190 #pragma omp parallel for
   2191   for (int i = 0; i < 10; ++i)
   2192     ;
   2193 #pragma omp target
   2194 #pragma omp parallel for simd
   2195   for (int i = 0; i < 10; ++i)
   2196     ;
   2197 #pragma omp target
   2198 #pragma omp parallel sections
   2199   {
   2200     bar();
   2201   }
   2202 #pragma omp target
   2203 #pragma omp task
   2204   {
   2205     bar();
   2206   }
   2207 #pragma omp target
   2208   {
   2209 #pragma omp taskyield
   2210     bar();
   2211   }
   2212 #pragma omp target
   2213   {
   2214 #pragma omp barrier
   2215     bar();
   2216   }
   2217 #pragma omp target
   2218   {
   2219 #pragma omp taskwait
   2220     bar();
   2221   }
   2222 #pragma omp target
   2223   {
   2224 #pragma omp flush
   2225     bar();
   2226   }
   2227 #pragma omp target
   2228   {
   2229 #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?}}
   2230     bar();
   2231   }
   2232 #pragma omp target
   2233   {
   2234 #pragma omp atomic
   2235     ++a;
   2236   }
   2237 #pragma omp target
   2238   {
   2239 #pragma omp target
   2240     ++a;
   2241   }
   2242 #pragma omp target
   2243   {
   2244 #pragma omp teams
   2245     ++a;
   2246   }
   2247 #pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}}
   2248   {
   2249     ++a;           // expected-note {{statement outside teams construct here}}
   2250 #pragma omp teams  // expected-note {{nested teams construct here}}
   2251     ++a;
   2252   }
   2253 
   2254 // TEAMS DIRECTIVE
   2255 #pragma omp target
   2256 #pragma omp teams
   2257 #pragma omp parallel
   2258   bar();
   2259 #pragma omp target
   2260 #pragma omp teams
   2261 #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?}}
   2262   for (int i = 0; i < 10; ++i)
   2263     ;
   2264 #pragma omp target
   2265 #pragma omp teams
   2266 #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?}}
   2267   for (int i = 0; i < 10; ++i)
   2268     ;
   2269 #pragma omp target
   2270 #pragma omp teams
   2271 #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?}}
   2272   for (int i = 0; i < 10; ++i)
   2273     ;
   2274 #pragma omp target
   2275 #pragma omp teams
   2276 #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?}}
   2277   {
   2278     bar();
   2279   }
   2280 #pragma omp target
   2281 #pragma omp teams
   2282 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a teams region}}
   2283   {
   2284     bar();
   2285   }
   2286 #pragma omp target
   2287 #pragma omp teams
   2288 #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?}}
   2289   bar();
   2290 
   2291 #pragma omp target
   2292 #pragma omp teams
   2293 #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?}}
   2294   {
   2295     bar();
   2296   }
   2297 #pragma omp target
   2298 #pragma omp teams
   2299 #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?}}
   2300   {
   2301     bar();
   2302   }
   2303 #pragma omp target
   2304 #pragma omp teams
   2305 #pragma omp parallel for
   2306   for (int i = 0; i < 10; ++i)
   2307     ;
   2308 #pragma omp target
   2309 #pragma omp teams
   2310 #pragma omp parallel for simd
   2311   for (int i = 0; i < 10; ++i)
   2312     ;
   2313 #pragma omp target
   2314 #pragma omp teams
   2315 #pragma omp parallel sections
   2316   {
   2317     bar();
   2318   }
   2319 #pragma omp target
   2320 #pragma omp teams
   2321 #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?}}
   2322   {
   2323     bar();
   2324   }
   2325 #pragma omp target
   2326 #pragma omp teams
   2327   {
   2328 #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?}}
   2329     bar();
   2330   }
   2331 #pragma omp target
   2332 #pragma omp teams
   2333   {
   2334 #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?}}
   2335     bar();
   2336   }
   2337 #pragma omp target
   2338 #pragma omp teams
   2339   {
   2340 #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?}}
   2341     bar();
   2342   }
   2343 #pragma omp target
   2344 #pragma omp teams
   2345   {
   2346 #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?}}
   2347     bar();
   2348   }
   2349 #pragma omp target
   2350 #pragma omp teams
   2351   {
   2352 #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?}}
   2353     bar();
   2354   }
   2355 #pragma omp target
   2356 #pragma omp teams
   2357   {
   2358 #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?}}
   2359     ++a;
   2360   }
   2361 #pragma omp target
   2362 #pragma omp teams
   2363   {
   2364 #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?}}
   2365     ++a;
   2366   }
   2367 #pragma omp target
   2368 #pragma omp teams
   2369   {
   2370 #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?}}
   2371     ++a;
   2372   }
   2373 }
   2374 
   2375 void foo() {
   2376   int a = 0;
   2377 // PARALLEL DIRECTIVE
   2378 #pragma omp parallel
   2379 #pragma omp for
   2380   for (int i = 0; i < 10; ++i)
   2381     ;
   2382 #pragma omp parallel
   2383 #pragma omp simd
   2384   for (int i = 0; i < 10; ++i)
   2385     ;
   2386 #pragma omp parallel
   2387 #pragma omp for simd
   2388   for (int i = 0; i < 10; ++i)
   2389     ;
   2390 #pragma omp parallel
   2391 #pragma omp sections
   2392   {
   2393     bar();
   2394   }
   2395 #pragma omp parallel
   2396 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a parallel region}}
   2397   {
   2398     bar();
   2399   }
   2400 #pragma omp parallel
   2401 #pragma omp sections
   2402   {
   2403     bar();
   2404   }
   2405 #pragma omp parallel
   2406 #pragma omp single
   2407   bar();
   2408 #pragma omp parallel
   2409 #pragma omp master
   2410   bar();
   2411 #pragma omp parallel
   2412 #pragma omp critical
   2413   bar();
   2414 #pragma omp parallel
   2415 #pragma omp parallel for
   2416   for (int i = 0; i < 10; ++i)
   2417     ;
   2418 #pragma omp parallel
   2419 #pragma omp parallel for simd
   2420   for (int i = 0; i < 10; ++i)
   2421     ;
   2422 #pragma omp parallel
   2423 #pragma omp parallel sections
   2424   {
   2425     bar();
   2426   }
   2427 #pragma omp parallel
   2428 #pragma omp task
   2429   {
   2430     bar();
   2431   }
   2432 #pragma omp parallel
   2433   {
   2434 #pragma omp taskyield
   2435     bar();
   2436   }
   2437 #pragma omp parallel
   2438   {
   2439 #pragma omp barrier
   2440     bar();
   2441   }
   2442 #pragma omp parallel
   2443   {
   2444 #pragma omp taskwait
   2445     bar();
   2446   }
   2447 #pragma omp parallel
   2448   {
   2449 #pragma omp flush
   2450     bar();
   2451   }
   2452 #pragma omp parallel
   2453   {
   2454 #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?}}
   2455     bar();
   2456   }
   2457 #pragma omp parallel
   2458   {
   2459 #pragma omp atomic
   2460     ++a;
   2461   }
   2462 #pragma omp parallel
   2463   {
   2464 #pragma omp target
   2465     ++a;
   2466   }
   2467 #pragma omp parallel
   2468   {
   2469 #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?}}
   2470     ++a;
   2471   }
   2472 
   2473 // SIMD DIRECTIVE
   2474 #pragma omp simd
   2475   for (int i = 0; i < 10; ++i) {
   2476 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2477     for (int i = 0; i < 10; ++i)
   2478       ;
   2479   }
   2480 #pragma omp simd
   2481   for (int i = 0; i < 10; ++i) {
   2482 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2483     for (int i = 0; i < 10; ++i)
   2484       ;
   2485   }
   2486 #pragma omp simd
   2487   for (int i = 0; i < 10; ++i) {
   2488 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2489     for (int i = 0; i < 10; ++i)
   2490       ;
   2491   }
   2492 #pragma omp simd
   2493   for (int i = 0; i < 10; ++i) {
   2494 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2495     for (int i = 0; i < 10; ++i)
   2496       ;
   2497   }
   2498 #pragma omp simd
   2499   for (int i = 0; i < 10; ++i) {
   2500 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2501     {
   2502       bar();
   2503     }
   2504   }
   2505 #pragma omp simd
   2506   for (int i = 0; i < 10; ++i) {
   2507 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2508     {
   2509       bar();
   2510     }
   2511   }
   2512 #pragma omp simd
   2513   for (int i = 0; i < 10; ++i) {
   2514 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2515     bar();
   2516 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2517     bar();
   2518   }
   2519 #pragma omp simd
   2520   for (int i = 0; i < 10; ++i) {
   2521 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2522     bar();
   2523 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2524     bar();
   2525   }
   2526 #pragma omp simd
   2527   for (int i = 0; i < 10; ++i) {
   2528 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2529     for (int i = 0; i < 10; ++i)
   2530       ;
   2531   }
   2532 #pragma omp simd
   2533   for (int i = 0; i < 10; ++i) {
   2534 #pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2535     for (int i = 0; i < 10; ++i)
   2536       ;
   2537   }
   2538 #pragma omp simd
   2539   for (int i = 0; i < 10; ++i) {
   2540 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2541     {
   2542       bar();
   2543     }
   2544   }
   2545 #pragma omp simd
   2546   for (int i = 0; i < 10; ++i) {
   2547 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2548     {
   2549       bar();
   2550     }
   2551   }
   2552 #pragma omp simd
   2553   for (int i = 0; i < 10; ++i) {
   2554 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2555     bar();
   2556   }
   2557 #pragma omp simd
   2558   for (int i = 0; i < 10; ++i) {
   2559 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2560     bar();
   2561   }
   2562 #pragma omp simd
   2563   for (int i = 0; i < 10; ++i) {
   2564 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2565     bar();
   2566   }
   2567 #pragma omp simd
   2568   for (int i = 0; i < 10; ++i) {
   2569 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2570     bar();
   2571   }
   2572 #pragma omp simd
   2573   for (int i = 0; i < 10; ++i) {
   2574 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2575     bar();
   2576   }
   2577 #pragma omp simd
   2578   for (int i = 0; i < 10; ++i) {
   2579 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2580     ++a;
   2581   }
   2582 #pragma omp simd
   2583   for (int i = 0; i < 10; ++i) {
   2584 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2585     ++a;
   2586   }
   2587 #pragma omp simd
   2588   for (int i = 0; i < 10; ++i) {
   2589 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2590     ++a;
   2591   }
   2592 
   2593 // FOR DIRECTIVE
   2594 #pragma omp for
   2595   for (int i = 0; i < 10; ++i) {
   2596 #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?}}
   2597     for (int i = 0; i < 10; ++i)
   2598       ;
   2599   }
   2600 #pragma omp for
   2601   for (int i = 0; i < 10; ++i) {
   2602 #pragma omp simd
   2603     for (int i = 0; i < 10; ++i)
   2604       ;
   2605   }
   2606 #pragma omp for
   2607   for (int i = 0; i < 10; ++i) {
   2608 #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?}}
   2609     for (int i = 0; i < 10; ++i)
   2610       ;
   2611   }
   2612 #pragma omp for
   2613   for (int i = 0; i < 10; ++i) {
   2614 #pragma omp parallel
   2615     for (int i = 0; i < 10; ++i)
   2616       ;
   2617   }
   2618 #pragma omp for
   2619   for (int i = 0; i < 10; ++i) {
   2620 #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?}}
   2621     {
   2622       bar();
   2623     }
   2624   }
   2625 #pragma omp for
   2626   for (int i = 0; i < 10; ++i) {
   2627 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a for region}}
   2628     {
   2629       bar();
   2630     }
   2631   }
   2632 #pragma omp for
   2633   for (int i = 0; i < 10; ++i) {
   2634 #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?}}
   2635     bar();
   2636 #pragma omp master // expected-error {{region cannot be closely nested inside 'for' region}}
   2637     bar();
   2638 #pragma omp critical
   2639     bar();
   2640   }
   2641 #pragma omp for
   2642   for (int i = 0; i < 10; ++i) {
   2643 #pragma omp parallel
   2644     {
   2645 #pragma omp single // OK
   2646       {
   2647         bar();
   2648       }
   2649 #pragma omp for // OK
   2650       for (int i = 0; i < 10; ++i)
   2651         ;
   2652 #pragma omp for simd // OK
   2653       for (int i = 0; i < 10; ++i)
   2654         ;
   2655 #pragma omp sections // OK
   2656       {
   2657         bar();
   2658       }
   2659     }
   2660   }
   2661 #pragma omp for
   2662   for (int i = 0; i < 10; ++i) {
   2663 #pragma omp parallel for
   2664     for (int i = 0; i < 10; ++i)
   2665       ;
   2666   }
   2667 #pragma omp for
   2668   for (int i = 0; i < 10; ++i) {
   2669 #pragma omp parallel for simd
   2670     for (int i = 0; i < 10; ++i)
   2671       ;
   2672   }
   2673 #pragma omp for
   2674   for (int i = 0; i < 10; ++i) {
   2675 #pragma omp parallel sections
   2676     {
   2677       bar();
   2678     }
   2679   }
   2680 #pragma omp for
   2681   for (int i = 0; i < 10; ++i) {
   2682 #pragma omp task
   2683     {
   2684       bar();
   2685     }
   2686   }
   2687 #pragma omp for
   2688   for (int i = 0; i < 10; ++i) {
   2689 #pragma omp taskyield
   2690     bar();
   2691   }
   2692 #pragma omp for
   2693   for (int i = 0; i < 10; ++i) {
   2694 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'for' region}}
   2695     bar();
   2696   }
   2697 #pragma omp for
   2698   for (int i = 0; i < 10; ++i) {
   2699 #pragma omp taskwait
   2700     bar();
   2701   }
   2702 #pragma omp for
   2703   for (int i = 0; i < 10; ++i) {
   2704 #pragma omp flush
   2705     bar();
   2706   }
   2707 #pragma omp for
   2708   for (int i = 0; i < 10; ++i) {
   2709 #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?}}
   2710     bar();
   2711   }
   2712 #pragma omp for ordered
   2713   for (int i = 0; i < 10; ++i) {
   2714 #pragma omp ordered // OK
   2715     bar();
   2716   }
   2717 #pragma omp for
   2718   for (int i = 0; i < 10; ++i) {
   2719 #pragma omp atomic
   2720     ++a;
   2721   }
   2722 #pragma omp for
   2723   for (int i = 0; i < 10; ++i) {
   2724 #pragma omp target
   2725     ++a;
   2726   }
   2727 #pragma omp for
   2728   for (int i = 0; i < 10; ++i) {
   2729 #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?}}
   2730     ++a;
   2731   }
   2732 
   2733 // FOR SIMD DIRECTIVE
   2734 #pragma omp for simd
   2735   for (int i = 0; i < 10; ++i) {
   2736 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2737     for (int i = 0; i < 10; ++i)
   2738       ;
   2739   }
   2740 #pragma omp for simd
   2741   for (int i = 0; i < 10; ++i) {
   2742 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2743     for (int i = 0; i < 10; ++i)
   2744       ;
   2745   }
   2746 #pragma omp for simd
   2747   for (int i = 0; i < 10; ++i) {
   2748 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2749     for (int i = 0; i < 10; ++i)
   2750       ;
   2751   }
   2752 #pragma omp for simd
   2753   for (int i = 0; i < 10; ++i) {
   2754 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2755     for (int i = 0; i < 10; ++i)
   2756       ;
   2757   }
   2758 #pragma omp for simd
   2759   for (int i = 0; i < 10; ++i) {
   2760 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2761     {
   2762       bar();
   2763     }
   2764   }
   2765 #pragma omp for simd
   2766   for (int i = 0; i < 10; ++i) {
   2767 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2768     {
   2769       bar();
   2770     }
   2771   }
   2772 #pragma omp for simd
   2773   for (int i = 0; i < 10; ++i) {
   2774 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2775     bar();
   2776 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2777     bar();
   2778   }
   2779 #pragma omp for simd
   2780   for (int i = 0; i < 10; ++i) {
   2781 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2782     bar();
   2783 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2784     bar();
   2785   }
   2786 #pragma omp for simd
   2787   for (int i = 0; i < 10; ++i) {
   2788 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2789     for (int i = 0; i < 10; ++i)
   2790       ;
   2791   }
   2792 #pragma omp for simd
   2793   for (int i = 0; i < 10; ++i) {
   2794 #pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2795     for (int i = 0; i < 10; ++i)
   2796       ;
   2797   }
   2798 #pragma omp for simd
   2799   for (int i = 0; i < 10; ++i) {
   2800 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2801     {
   2802       bar();
   2803     }
   2804   }
   2805 #pragma omp for simd
   2806   for (int i = 0; i < 10; ++i) {
   2807 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2808     {
   2809       bar();
   2810     }
   2811   }
   2812 #pragma omp for simd
   2813   for (int i = 0; i < 10; ++i) {
   2814 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2815     bar();
   2816   }
   2817 #pragma omp for simd
   2818   for (int i = 0; i < 10; ++i) {
   2819 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2820     bar();
   2821   }
   2822 #pragma omp for simd
   2823   for (int i = 0; i < 10; ++i) {
   2824 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2825     bar();
   2826   }
   2827 #pragma omp for simd
   2828   for (int i = 0; i < 10; ++i) {
   2829 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2830     bar();
   2831   }
   2832 #pragma omp for simd
   2833   for (int i = 0; i < 10; ++i) {
   2834 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2835     bar();
   2836   }
   2837 #pragma omp for simd
   2838   for (int i = 0; i < 10; ++i) {
   2839 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2840     ++a;
   2841   }
   2842 #pragma omp for simd
   2843   for (int i = 0; i < 10; ++i) {
   2844 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2845     ++a;
   2846   }
   2847 #pragma omp for simd
   2848   for (int i = 0; i < 10; ++i) {
   2849 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   2850     ++a;
   2851   }
   2852 
   2853 // SECTIONS DIRECTIVE
   2854 #pragma omp sections
   2855   {
   2856 #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?}}
   2857     for (int i = 0; i < 10; ++i)
   2858       ;
   2859   }
   2860 #pragma omp sections
   2861   {
   2862 #pragma omp simd
   2863     for (int i = 0; i < 10; ++i)
   2864       ;
   2865   }
   2866 #pragma omp sections
   2867   {
   2868 #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?}}
   2869     for (int i = 0; i < 10; ++i)
   2870       ;
   2871   }
   2872 #pragma omp sections
   2873   {
   2874 #pragma omp parallel
   2875     for (int i = 0; i < 10; ++i)
   2876       ;
   2877   }
   2878 #pragma omp sections
   2879   {
   2880 #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?}}
   2881     {
   2882       bar();
   2883     }
   2884   }
   2885 #pragma omp sections
   2886   {
   2887 #pragma omp section
   2888     {
   2889       bar();
   2890     }
   2891   }
   2892 #pragma omp sections
   2893   {
   2894 #pragma omp critical
   2895     bar();
   2896 #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?}}
   2897     bar();
   2898 #pragma omp master // expected-error {{region cannot be closely nested inside 'sections' region}}
   2899     bar();
   2900   }
   2901 #pragma omp sections
   2902   {
   2903 #pragma omp parallel
   2904     {
   2905 #pragma omp single // OK
   2906       {
   2907         bar();
   2908       }
   2909 #pragma omp for // OK
   2910       for (int i = 0; i < 10; ++i)
   2911         ;
   2912 #pragma omp for simd // OK
   2913       for (int i = 0; i < 10; ++i)
   2914         ;
   2915 #pragma omp sections // OK
   2916       {
   2917         bar();
   2918       }
   2919     }
   2920   }
   2921 #pragma omp sections
   2922   {
   2923 #pragma omp parallel for
   2924     for (int i = 0; i < 10; ++i)
   2925       ;
   2926   }
   2927 #pragma omp sections
   2928   {
   2929 #pragma omp parallel for simd
   2930     for (int i = 0; i < 10; ++i)
   2931       ;
   2932   }
   2933 #pragma omp sections
   2934   {
   2935 #pragma omp parallel sections
   2936     {
   2937       bar();
   2938     }
   2939   }
   2940 #pragma omp sections
   2941   {
   2942 #pragma omp task
   2943     {
   2944       bar();
   2945     }
   2946   }
   2947 #pragma omp sections
   2948   {
   2949 #pragma omp taskyield
   2950   }
   2951 #pragma omp sections
   2952   {
   2953 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'sections' region}}
   2954     bar();
   2955   }
   2956 #pragma omp sections
   2957   {
   2958 #pragma omp taskwait
   2959   }
   2960 #pragma omp sections
   2961   {
   2962 #pragma omp flush
   2963   }
   2964 #pragma omp sections
   2965   {
   2966 #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?}}
   2967     bar();
   2968   }
   2969 #pragma omp sections
   2970   {
   2971 #pragma omp atomic
   2972     ++a;
   2973   }
   2974 #pragma omp sections
   2975   {
   2976 #pragma omp target
   2977     ++a;
   2978   }
   2979 #pragma omp sections
   2980   {
   2981 #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?}}
   2982     ++a;
   2983   }
   2984 
   2985 // SECTION DIRECTIVE
   2986 #pragma omp section // expected-error {{orphaned 'omp section' directives are prohibited, it must be closely nested to a sections region}}
   2987   {
   2988     bar();
   2989   }
   2990 #pragma omp sections
   2991   {
   2992 #pragma omp section
   2993     {
   2994 #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?}}
   2995       for (int i = 0; i < 10; ++i)
   2996         ;
   2997     }
   2998   }
   2999 #pragma omp sections
   3000   {
   3001 #pragma omp section
   3002     {
   3003 #pragma omp simd
   3004       for (int i = 0; i < 10; ++i)
   3005         ;
   3006     }
   3007   }
   3008 #pragma omp sections
   3009   {
   3010 #pragma omp section
   3011     {
   3012 #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?}}
   3013       for (int i = 0; i < 10; ++i)
   3014         ;
   3015     }
   3016   }
   3017 #pragma omp sections
   3018   {
   3019 #pragma omp section
   3020     {
   3021 #pragma omp parallel
   3022       for (int i = 0; i < 10; ++i)
   3023         ;
   3024     }
   3025   }
   3026 #pragma omp sections
   3027   {
   3028 #pragma omp section
   3029     {
   3030 #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?}}
   3031       {
   3032         bar();
   3033       }
   3034     }
   3035   }
   3036 #pragma omp sections
   3037   {
   3038 #pragma omp section
   3039     {
   3040 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a section region}}
   3041       {
   3042         bar();
   3043       }
   3044     }
   3045   }
   3046 #pragma omp sections
   3047   {
   3048 #pragma omp section
   3049     {
   3050 #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?}}
   3051       bar();
   3052 #pragma omp master // expected-error {{region cannot be closely nested inside 'section' region}}
   3053       bar();
   3054 #pragma omp critical
   3055       bar();
   3056     }
   3057   }
   3058 #pragma omp sections
   3059   {
   3060 #pragma omp section
   3061     {
   3062 #pragma omp parallel
   3063       {
   3064 #pragma omp single // OK
   3065         {
   3066           bar();
   3067         }
   3068 #pragma omp for // OK
   3069         for (int i = 0; i < 10; ++i)
   3070           ;
   3071 #pragma omp for simd // OK
   3072         for (int i = 0; i < 10; ++i)
   3073           ;
   3074 #pragma omp sections // OK
   3075         {
   3076           bar();
   3077         }
   3078       }
   3079     }
   3080   }
   3081 #pragma omp sections
   3082   {
   3083 #pragma omp section
   3084     {
   3085 #pragma omp parallel for
   3086       for (int i = 0; i < 10; ++i)
   3087         ;
   3088     }
   3089   }
   3090 #pragma omp sections
   3091   {
   3092 #pragma omp section
   3093     {
   3094 #pragma omp parallel for simd
   3095       for (int i = 0; i < 10; ++i)
   3096         ;
   3097     }
   3098   }
   3099 #pragma omp sections
   3100   {
   3101 #pragma omp section
   3102     {
   3103 #pragma omp parallel sections
   3104       {
   3105         bar();
   3106       }
   3107     }
   3108   }
   3109 #pragma omp sections
   3110   {
   3111 #pragma omp section
   3112     {
   3113 #pragma omp task
   3114       {
   3115         bar();
   3116       }
   3117     }
   3118   }
   3119 #pragma omp sections
   3120   {
   3121 #pragma omp section
   3122     {
   3123 #pragma omp taskyield
   3124       bar();
   3125     }
   3126   }
   3127 #pragma omp sections
   3128   {
   3129 #pragma omp section
   3130     {
   3131 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'section' region}}
   3132       bar();
   3133     }
   3134   }
   3135 #pragma omp sections
   3136   {
   3137 #pragma omp section
   3138     {
   3139 #pragma omp taskwait
   3140       bar();
   3141     }
   3142   }
   3143 #pragma omp sections
   3144   {
   3145 #pragma omp section
   3146     {
   3147 #pragma omp flush
   3148       bar();
   3149     }
   3150   }
   3151 #pragma omp sections
   3152   {
   3153 #pragma omp section
   3154     {
   3155 #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?}}
   3156       bar();
   3157     }
   3158   }
   3159 #pragma omp sections
   3160   {
   3161 #pragma omp section
   3162     {
   3163 #pragma omp atomic
   3164       ++a;
   3165     }
   3166   }
   3167 #pragma omp sections
   3168   {
   3169 #pragma omp section
   3170     {
   3171 #pragma omp target
   3172       ++a;
   3173     }
   3174   }
   3175 #pragma omp sections
   3176   {
   3177 #pragma omp section
   3178     {
   3179 #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?}}
   3180       ++a;
   3181     }
   3182   }
   3183 
   3184 // SINGLE DIRECTIVE
   3185 #pragma omp single
   3186   {
   3187 #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?}}
   3188     for (int i = 0; i < 10; ++i)
   3189       ;
   3190   }
   3191 #pragma omp single
   3192   {
   3193 #pragma omp simd
   3194     for (int i = 0; i < 10; ++i)
   3195       ;
   3196   }
   3197 #pragma omp single
   3198   {
   3199 #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?}}
   3200     for (int i = 0; i < 10; ++i)
   3201       ;
   3202   }
   3203 #pragma omp single
   3204   {
   3205 #pragma omp parallel
   3206     for (int i = 0; i < 10; ++i)
   3207       ;
   3208   }
   3209 #pragma omp single
   3210   {
   3211 #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?}}
   3212     {
   3213       bar();
   3214     }
   3215 #pragma omp master // expected-error {{region cannot be closely nested inside 'single' region}}
   3216     bar();
   3217 #pragma omp critical
   3218     bar();
   3219   }
   3220 #pragma omp single
   3221   {
   3222 #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?}}
   3223     {
   3224       bar();
   3225     }
   3226   }
   3227 #pragma omp single
   3228   {
   3229 #pragma omp parallel
   3230     {
   3231 #pragma omp single // OK
   3232       {
   3233         bar();
   3234       }
   3235 #pragma omp for // OK
   3236       for (int i = 0; i < 10; ++i)
   3237         ;
   3238 #pragma omp for simd // OK
   3239       for (int i = 0; i < 10; ++i)
   3240         ;
   3241 #pragma omp sections // OK
   3242       {
   3243         bar();
   3244       }
   3245     }
   3246   }
   3247 #pragma omp single
   3248   {
   3249 #pragma omp parallel for
   3250     for (int i = 0; i < 10; ++i)
   3251       ;
   3252   }
   3253 #pragma omp single
   3254   {
   3255 #pragma omp parallel for simd
   3256     for (int i = 0; i < 10; ++i)
   3257       ;
   3258   }
   3259 #pragma omp single
   3260   {
   3261 #pragma omp parallel sections
   3262     {
   3263       bar();
   3264     }
   3265   }
   3266 #pragma omp single
   3267   {
   3268 #pragma omp task
   3269     {
   3270       bar();
   3271     }
   3272   }
   3273 #pragma omp single
   3274   {
   3275 #pragma omp taskyield
   3276     bar();
   3277   }
   3278 #pragma omp single
   3279   {
   3280 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'single' region}}
   3281     bar();
   3282   }
   3283 #pragma omp single
   3284   {
   3285 #pragma omp taskwait
   3286     bar();
   3287   }
   3288 #pragma omp single
   3289   {
   3290 #pragma omp flush
   3291     bar();
   3292   }
   3293 #pragma omp single
   3294   {
   3295 #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?}}
   3296     bar();
   3297   }
   3298 #pragma omp single
   3299   {
   3300 #pragma omp atomic
   3301     ++a;
   3302   }
   3303 #pragma omp single
   3304   {
   3305 #pragma omp target
   3306     ++a;
   3307   }
   3308 #pragma omp single
   3309   {
   3310 #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?}}
   3311     ++a;
   3312   }
   3313 
   3314 // MASTER DIRECTIVE
   3315 #pragma omp master
   3316   {
   3317 #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?}}
   3318     for (int i = 0; i < 10; ++i)
   3319       ;
   3320   }
   3321 #pragma omp master
   3322   {
   3323 #pragma omp simd
   3324     for (int i = 0; i < 10; ++i)
   3325       ;
   3326   }
   3327 #pragma omp master
   3328   {
   3329 #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?}}
   3330     for (int i = 0; i < 10; ++i)
   3331       ;
   3332   }
   3333 #pragma omp master
   3334   {
   3335 #pragma omp parallel
   3336     for (int i = 0; i < 10; ++i)
   3337       ;
   3338   }
   3339 #pragma omp master
   3340   {
   3341 #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?}}
   3342     {
   3343       bar();
   3344     }
   3345   }
   3346 #pragma omp master
   3347   {
   3348 #pragma omp master // OK, though second 'master' is redundant
   3349     {
   3350       bar();
   3351     }
   3352   }
   3353 #pragma omp master
   3354   {
   3355 #pragma omp critical
   3356     {
   3357       bar();
   3358     }
   3359   }
   3360 #pragma omp master
   3361   {
   3362 #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?}}
   3363     {
   3364       bar();
   3365     }
   3366   }
   3367 #pragma omp master
   3368   {
   3369 #pragma omp parallel
   3370     {
   3371 #pragma omp master // OK
   3372       {
   3373         bar();
   3374       }
   3375 #pragma omp for // OK
   3376       for (int i = 0; i < 10; ++i)
   3377         ;
   3378 #pragma omp for simd // OK
   3379       for (int i = 0; i < 10; ++i)
   3380         ;
   3381 #pragma omp sections // OK
   3382       {
   3383         bar();
   3384       }
   3385     }
   3386   }
   3387 #pragma omp master
   3388   {
   3389 #pragma omp parallel for
   3390     for (int i = 0; i < 10; ++i)
   3391       ;
   3392   }
   3393 #pragma omp master
   3394   {
   3395 #pragma omp parallel for simd
   3396     for (int i = 0; i < 10; ++i)
   3397       ;
   3398   }
   3399 #pragma omp master
   3400   {
   3401 #pragma omp parallel sections
   3402     {
   3403       bar();
   3404     }
   3405   }
   3406 #pragma omp master
   3407   {
   3408 #pragma omp task
   3409     {
   3410       bar();
   3411     }
   3412   }
   3413 #pragma omp master
   3414   {
   3415 #pragma omp taskyield
   3416     bar();
   3417   }
   3418 #pragma omp master
   3419   {
   3420 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'master' region}}
   3421     bar();
   3422   }
   3423 #pragma omp master
   3424   {
   3425 #pragma omp taskwait
   3426     bar();
   3427   }
   3428 #pragma omp master
   3429   {
   3430 #pragma omp flush
   3431     bar();
   3432   }
   3433 #pragma omp master
   3434   {
   3435 #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?}}
   3436     bar();
   3437   }
   3438 #pragma omp master
   3439   {
   3440 #pragma omp atomic
   3441     ++a;
   3442   }
   3443 #pragma omp master
   3444   {
   3445 #pragma omp target
   3446     ++a;
   3447   }
   3448 #pragma omp master
   3449   {
   3450 #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?}}
   3451     ++a;
   3452   }
   3453 
   3454 // CRITICAL DIRECTIVE
   3455 #pragma omp critical
   3456   {
   3457 #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?}}
   3458     for (int i = 0; i < 10; ++i)
   3459       ;
   3460   }
   3461 #pragma omp critical
   3462   {
   3463 #pragma omp simd
   3464     for (int i = 0; i < 10; ++i)
   3465       ;
   3466   }
   3467 #pragma omp critical
   3468   {
   3469 #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?}}
   3470     for (int i = 0; i < 10; ++i)
   3471       ;
   3472   }
   3473 #pragma omp critical
   3474   {
   3475 #pragma omp parallel
   3476     for (int i = 0; i < 10; ++i)
   3477       ;
   3478   }
   3479 #pragma omp critical
   3480   {
   3481 #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?}}
   3482     {
   3483       bar();
   3484     }
   3485   }
   3486 #pragma omp critical
   3487   {
   3488 #pragma omp master // OK, though second 'master' is redundant
   3489     {
   3490       bar();
   3491     }
   3492   }
   3493 #pragma omp critical
   3494   {
   3495 #pragma omp critical
   3496     {
   3497       bar();
   3498     }
   3499   }
   3500 #pragma omp critical
   3501   {
   3502 #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?}}
   3503     {
   3504       bar();
   3505     }
   3506   }
   3507 #pragma omp critical
   3508   {
   3509 #pragma omp parallel
   3510     {
   3511 #pragma omp master // OK
   3512       {
   3513         bar();
   3514       }
   3515 #pragma omp for // OK
   3516       for (int i = 0; i < 10; ++i)
   3517         ;
   3518 #pragma omp for simd // OK
   3519       for (int i = 0; i < 10; ++i)
   3520         ;
   3521 #pragma omp sections // OK
   3522       {
   3523         bar();
   3524       }
   3525     }
   3526   }
   3527 #pragma omp critical
   3528   {
   3529 #pragma omp parallel for
   3530     for (int i = 0; i < 10; ++i)
   3531       ;
   3532   }
   3533 #pragma omp critical
   3534   {
   3535 #pragma omp parallel for simd
   3536     for (int i = 0; i < 10; ++i)
   3537       ;
   3538   }
   3539 #pragma omp critical
   3540   {
   3541 #pragma omp parallel sections
   3542     {
   3543       bar();
   3544     }
   3545   }
   3546 #pragma omp critical
   3547   {
   3548 #pragma omp task
   3549     {
   3550       bar();
   3551     }
   3552   }
   3553 #pragma omp critical
   3554   {
   3555 #pragma omp taskyield
   3556     bar();
   3557   }
   3558 #pragma omp critical
   3559   {
   3560 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'critical' region}}
   3561     bar();
   3562   }
   3563 #pragma omp critical
   3564   {
   3565 #pragma omp taskwait
   3566     bar();
   3567   }
   3568 #pragma omp critical(Belka)
   3569   {
   3570 #pragma omp critical(Strelka)
   3571     bar();
   3572   }
   3573 #pragma omp critical(Tuzik) // expected-note {{previous 'critical' region starts here}}
   3574   {
   3575 #pragma omp critical(grelka) // expected-note {{previous 'critical' region starts here}}
   3576     {
   3577 #pragma omp critical(Tuzik) // expected-error {{cannot nest 'critical' regions having the same name 'Tuzik'}}
   3578       {
   3579 #pragma omp parallel
   3580 #pragma omp critical(grelka) // expected-error {{cannot nest 'critical' regions having the same name 'grelka'}}
   3581         {
   3582           bar();
   3583         }
   3584       }
   3585     }
   3586   }
   3587 #pragma omp critical
   3588   {
   3589 #pragma omp flush
   3590     bar();
   3591   }
   3592 #pragma omp critical
   3593   {
   3594 #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?}}
   3595     bar();
   3596   }
   3597 #pragma omp critical
   3598   {
   3599 #pragma omp atomic
   3600     ++a;
   3601   }
   3602 #pragma omp critical
   3603   {
   3604 #pragma omp target
   3605     ++a;
   3606   }
   3607 #pragma omp critical
   3608   {
   3609 #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?}}
   3610     ++a;
   3611   }
   3612 
   3613 // PARALLEL FOR DIRECTIVE
   3614 #pragma omp parallel for
   3615   for (int i = 0; i < 10; ++i) {
   3616 #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?}}
   3617     for (int i = 0; i < 10; ++i)
   3618       ;
   3619   }
   3620 #pragma omp parallel for
   3621   for (int i = 0; i < 10; ++i) {
   3622 #pragma omp simd
   3623     for (int i = 0; i < 10; ++i)
   3624       ;
   3625   }
   3626 #pragma omp parallel for
   3627   for (int i = 0; i < 10; ++i) {
   3628 #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?}}
   3629     for (int i = 0; i < 10; ++i)
   3630       ;
   3631   }
   3632 
   3633 #pragma omp parallel for
   3634   for (int i = 0; i < 10; ++i) {
   3635 #pragma omp parallel
   3636     for (int i = 0; i < 10; ++i)
   3637       ;
   3638   }
   3639 #pragma omp parallel for
   3640   for (int i = 0; i < 10; ++i) {
   3641 #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?}}
   3642     {
   3643       bar();
   3644     }
   3645   }
   3646 #pragma omp parallel for
   3647   for (int i = 0; i < 10; ++i) {
   3648 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a parallel for region}}
   3649     {
   3650       bar();
   3651     }
   3652   }
   3653 #pragma omp parallel for
   3654   for (int i = 0; i < 10; ++i) {
   3655 #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?}}
   3656     {
   3657       bar();
   3658     }
   3659 #pragma omp master // expected-error {{region cannot be closely nested inside 'parallel for' region}}
   3660     {
   3661       bar();
   3662     }
   3663 #pragma omp critical
   3664     {
   3665       bar();
   3666     }
   3667   }
   3668 #pragma omp parallel for
   3669   for (int i = 0; i < 10; ++i) {
   3670 #pragma omp parallel
   3671     {
   3672 #pragma omp single // OK
   3673       {
   3674         bar();
   3675       }
   3676 #pragma omp master // OK
   3677       {
   3678         bar();
   3679       }
   3680 #pragma omp critical // OK
   3681       {
   3682         bar();
   3683       }
   3684 #pragma omp for // OK
   3685       for (int i = 0; i < 10; ++i)
   3686         ;
   3687 #pragma omp for simd // OK
   3688       for (int i = 0; i < 10; ++i)
   3689         ;
   3690 #pragma omp sections // OK
   3691       {
   3692         bar();
   3693       }
   3694     }
   3695   }
   3696 #pragma omp parallel for
   3697   for (int i = 0; i < 10; ++i) {
   3698 #pragma omp parallel for
   3699     for (int i = 0; i < 10; ++i)
   3700       ;
   3701   }
   3702 #pragma omp parallel for
   3703   for (int i = 0; i < 10; ++i) {
   3704 #pragma omp parallel for simd
   3705     for (int i = 0; i < 10; ++i)
   3706       ;
   3707   }
   3708 #pragma omp parallel for
   3709   for (int i = 0; i < 10; ++i) {
   3710 #pragma omp parallel sections
   3711     {
   3712       bar();
   3713     }
   3714   }
   3715 #pragma omp parallel for
   3716   for (int i = 0; i < 10; ++i) {
   3717 #pragma omp task
   3718     {
   3719       bar();
   3720     }
   3721   }
   3722 #pragma omp parallel for
   3723   for (int i = 0; i < 10; ++i) {
   3724 #pragma omp taskyield
   3725     bar();
   3726   }
   3727 #pragma omp parallel for
   3728   for (int i = 0; i < 10; ++i) {
   3729 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel for' region}}
   3730     bar();
   3731   }
   3732 #pragma omp parallel for
   3733   for (int i = 0; i < 10; ++i) {
   3734 #pragma omp taskwait
   3735     bar();
   3736   }
   3737 #pragma omp parallel for
   3738   for (int i = 0; i < 10; ++i) {
   3739 #pragma omp flush
   3740     bar();
   3741   }
   3742 #pragma omp parallel for
   3743   for (int i = 0; i < 10; ++i) {
   3744 #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?}}
   3745     bar();
   3746   }
   3747 #pragma omp parallel for ordered
   3748   for (int i = 0; i < 10; ++i) {
   3749 #pragma omp ordered // OK
   3750     bar();
   3751   }
   3752 #pragma omp parallel for
   3753   for (int i = 0; i < 10; ++i) {
   3754 #pragma omp atomic
   3755     ++a;
   3756   }
   3757 #pragma omp parallel for
   3758   for (int i = 0; i < 10; ++i) {
   3759 #pragma omp target
   3760     ++a;
   3761   }
   3762 #pragma omp parallel for
   3763   for (int i = 0; i < 10; ++i) {
   3764 #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?}}
   3765     ++a;
   3766   }
   3767 
   3768 // PARALLEL FOR SIMD DIRECTIVE
   3769 #pragma omp parallel for simd
   3770   for (int i = 0; i < 10; ++i) {
   3771 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3772     for (int i = 0; i < 10; ++i)
   3773       ;
   3774   }
   3775 #pragma omp parallel for simd
   3776   for (int i = 0; i < 10; ++i) {
   3777 #pragma omp simd// expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3778     for (int i = 0; i < 10; ++i)
   3779       ;
   3780   }
   3781 #pragma omp parallel for simd
   3782   for (int i = 0; i < 10; ++i) {
   3783 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3784     for (int i = 0; i < 10; ++i)
   3785       ;
   3786   }
   3787 #pragma omp parallel for simd
   3788   for (int i = 0; i < 10; ++i) {
   3789 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3790     for (int i = 0; i < 10; ++i)
   3791       ;
   3792   }
   3793 #pragma omp parallel for simd
   3794   for (int i = 0; i < 10; ++i) {
   3795 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3796     {
   3797       bar();
   3798     }
   3799   }
   3800 #pragma omp parallel for simd
   3801   for (int i = 0; i < 10; ++i) {
   3802 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3803     {
   3804       bar();
   3805     }
   3806   }
   3807 #pragma omp parallel for simd
   3808   for (int i = 0; i < 10; ++i) {
   3809 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3810     {
   3811       bar();
   3812     }
   3813   }
   3814 
   3815 #pragma omp parallel for simd
   3816   for (int i = 0; i < 10; ++i) {
   3817 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3818     {
   3819       bar();
   3820     }
   3821   }
   3822 
   3823 #pragma omp parallel for simd
   3824   for (int i = 0; i < 10; ++i) {
   3825 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3826     {
   3827       bar();
   3828     }
   3829   }
   3830 
   3831 #pragma omp parallel for simd
   3832   for (int i = 0; i < 10; ++i) {
   3833 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3834     {
   3835 #pragma omp single
   3836       {
   3837         bar();
   3838       }
   3839 #pragma omp for
   3840       for (int i = 0; i < 10; ++i)
   3841         ;
   3842 #pragma omp for simd
   3843       for (int i = 0; i < 10; ++i)
   3844         ;
   3845 #pragma omp sections
   3846       {
   3847         bar();
   3848       }
   3849     }
   3850   }
   3851 #pragma omp parallel for simd
   3852   for (int i = 0; i < 10; ++i) {
   3853 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3854     for (int i = 0; i < 10; ++i)
   3855       ;
   3856   }
   3857 #pragma omp parallel for simd
   3858   for (int i = 0; i < 10; ++i) {
   3859 #pragma omp parallel for simd// expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3860     for (int i = 0; i < 10; ++i)
   3861       ;
   3862   }
   3863 #pragma omp parallel for simd
   3864   for (int i = 0; i < 10; ++i) {
   3865 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3866     {
   3867       bar();
   3868     }
   3869   }
   3870 #pragma omp parallel for simd
   3871   for (int i = 0; i < 10; ++i) {
   3872 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3873     {
   3874       bar();
   3875     }
   3876   }
   3877 #pragma omp parallel for simd
   3878   for (int i = 0; i < 10; ++i) {
   3879 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3880     bar();
   3881   }
   3882 #pragma omp parallel for simd
   3883   for (int i = 0; i < 10; ++i) {
   3884 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3885     bar();
   3886   }
   3887 #pragma omp parallel for simd
   3888   for (int i = 0; i < 10; ++i) {
   3889 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3890     bar();
   3891   }
   3892 #pragma omp parallel for simd
   3893   for (int i = 0; i < 10; ++i) {
   3894 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3895     bar();
   3896   }
   3897 #pragma omp parallel for simd
   3898   for (int i = 0; i < 10; ++i) {
   3899 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3900     bar();
   3901   }
   3902 #pragma omp parallel for simd
   3903   for (int i = 0; i < 10; ++i) {
   3904 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3905     bar();
   3906   }
   3907 #pragma omp parallel for simd
   3908   for (int i = 0; i < 10; ++i) {
   3909 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3910     ++a;
   3911   }
   3912 #pragma omp parallel for simd
   3913   for (int i = 0; i < 10; ++i) {
   3914 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3915     ++a;
   3916   }
   3917 #pragma omp parallel for simd
   3918   for (int i = 0; i < 10; ++i) {
   3919 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside a simd region}}
   3920     ++a;
   3921   }
   3922 
   3923 // PARALLEL SECTIONS DIRECTIVE
   3924 #pragma omp parallel sections
   3925   {
   3926 #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?}}
   3927     for (int i = 0; i < 10; ++i)
   3928       ;
   3929   }
   3930 #pragma omp parallel sections
   3931   {
   3932 #pragma omp simd
   3933     for (int i = 0; i < 10; ++i)
   3934       ;
   3935   }
   3936 #pragma omp parallel sections
   3937   {
   3938 #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?}}
   3939     for (int i = 0; i < 10; ++i)
   3940       ;
   3941   }
   3942 #pragma omp parallel sections
   3943   {
   3944 #pragma omp parallel
   3945     for (int i = 0; i < 10; ++i)
   3946       ;
   3947   }
   3948 #pragma omp parallel sections
   3949   {
   3950 #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?}}
   3951     {
   3952       bar();
   3953     }
   3954   }
   3955 #pragma omp parallel sections
   3956   {
   3957 #pragma omp section
   3958     {
   3959       bar();
   3960     }
   3961   }
   3962 #pragma omp parallel sections
   3963   {
   3964 #pragma omp section
   3965     {
   3966 #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?}}
   3967       bar();
   3968 #pragma omp master // expected-error {{region cannot be closely nested inside 'section' region}}
   3969       bar();
   3970 #pragma omp critical
   3971       bar();
   3972     }
   3973   }
   3974 #pragma omp parallel sections
   3975   {
   3976 #pragma omp parallel
   3977     {
   3978 #pragma omp single // OK
   3979       {
   3980         bar();
   3981       }
   3982 #pragma omp master // OK
   3983       {
   3984         bar();
   3985       }
   3986 #pragma omp critical // OK
   3987       {
   3988         bar();
   3989       }
   3990 #pragma omp for // OK
   3991       for (int i = 0; i < 10; ++i)
   3992         ;
   3993 #pragma omp for simd // OK
   3994       for (int i = 0; i < 10; ++i)
   3995         ;
   3996 #pragma omp sections // OK
   3997       {
   3998         bar();
   3999       }
   4000     }
   4001   }
   4002 #pragma omp parallel sections
   4003   {
   4004 #pragma omp parallel for
   4005     for (int i = 0; i < 10; ++i)
   4006       ;
   4007   }
   4008 #pragma omp parallel sections
   4009   {
   4010 #pragma omp parallel for simd
   4011     for (int i = 0; i < 10; ++i)
   4012       ;
   4013   }
   4014 #pragma omp parallel sections
   4015   {
   4016 #pragma omp parallel sections
   4017     {
   4018       bar();
   4019     }
   4020   }
   4021 #pragma omp parallel sections
   4022   {
   4023 #pragma omp task
   4024     {
   4025       bar();
   4026     }
   4027   }
   4028 #pragma omp parallel sections
   4029   {
   4030 #pragma omp taskyield
   4031   }
   4032 #pragma omp parallel sections
   4033   {
   4034 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'parallel sections' region}}
   4035   }
   4036 #pragma omp parallel sections
   4037   {
   4038 #pragma omp taskwait
   4039   }
   4040 #pragma omp parallel sections
   4041   {
   4042 #pragma omp flush
   4043   }
   4044 #pragma omp parallel sections
   4045   {
   4046 #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?}}
   4047     bar();
   4048   }
   4049 #pragma omp parallel sections
   4050   {
   4051 #pragma omp atomic
   4052     ++a;
   4053   }
   4054 #pragma omp parallel sections
   4055   {
   4056 #pragma omp target
   4057     ++a;
   4058   }
   4059 #pragma omp parallel sections
   4060   {
   4061 #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?}}
   4062     ++a;
   4063   }
   4064 
   4065 // TASK DIRECTIVE
   4066 #pragma omp task
   4067 #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?}}
   4068   for (int i = 0; i < 10; ++i)
   4069     ;
   4070 #pragma omp task
   4071 #pragma omp simd
   4072   for (int i = 0; i < 10; ++i)
   4073     ;
   4074 #pragma omp task
   4075 #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?}}
   4076   for (int i = 0; i < 10; ++i)
   4077     ;
   4078 #pragma omp task
   4079 #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?}}
   4080   {
   4081     bar();
   4082   }
   4083 #pragma omp task
   4084 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a task region}}
   4085   {
   4086     bar();
   4087   }
   4088 #pragma omp task
   4089 #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?}}
   4090   bar();
   4091 #pragma omp task
   4092 #pragma omp master // expected-error {{region cannot be closely nested inside 'task' region}}
   4093   bar();
   4094 #pragma omp task
   4095 #pragma omp critical
   4096   bar();
   4097 #pragma omp task
   4098 #pragma omp parallel for
   4099   for (int i = 0; i < 10; ++i)
   4100     ;
   4101 #pragma omp task
   4102 #pragma omp parallel for simd
   4103   for (int i = 0; i < 10; ++i)
   4104     ;
   4105 #pragma omp task
   4106 #pragma omp parallel sections
   4107   {
   4108     bar();
   4109   }
   4110 #pragma omp task
   4111 #pragma omp task
   4112   {
   4113     bar();
   4114   }
   4115 #pragma omp task
   4116   {
   4117 #pragma omp taskyield
   4118     bar();
   4119   }
   4120 #pragma omp task
   4121   {
   4122 #pragma omp barrier // expected-error {{region cannot be closely nested inside 'task' region}}
   4123     bar();
   4124   }
   4125 #pragma omp task
   4126   {
   4127 #pragma omp taskwait
   4128     bar();
   4129   }
   4130 #pragma omp task
   4131   {
   4132 #pragma omp flush
   4133     bar();
   4134   }
   4135 #pragma omp task
   4136   {
   4137 #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?}}
   4138     bar();
   4139   }
   4140 #pragma omp task
   4141   {
   4142 #pragma omp atomic
   4143     ++a;
   4144   }
   4145 #pragma omp task
   4146   {
   4147 #pragma omp target
   4148     ++a;
   4149   }
   4150 #pragma omp task
   4151   {
   4152 #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?}}
   4153     ++a;
   4154   }
   4155 
   4156 // ATOMIC DIRECTIVE
   4157 #pragma omp atomic
   4158   // 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}}
   4159   // expected-note@+1 {{expected an expression statement}}
   4160   {
   4161 #pragma omp for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4162     for (int i = 0; i < 10; ++i)
   4163       ;
   4164   }
   4165 #pragma omp atomic
   4166   // 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}}
   4167   // expected-note@+1 {{expected an expression statement}}
   4168   {
   4169 #pragma omp simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4170     for (int i = 0; i < 10; ++i)
   4171       ;
   4172   }
   4173 #pragma omp atomic
   4174   // 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}}
   4175   // expected-note@+1 {{expected an expression statement}}
   4176   {
   4177 #pragma omp for simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4178     for (int i = 0; i < 10; ++i)
   4179       ;
   4180   }
   4181 #pragma omp atomic
   4182   // 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}}
   4183   // expected-note@+1 {{expected an expression statement}}
   4184   {
   4185 #pragma omp parallel // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4186     for (int i = 0; i < 10; ++i)
   4187       ;
   4188   }
   4189 #pragma omp atomic
   4190   // 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}}
   4191   // expected-note@+1 {{expected an expression statement}}
   4192   {
   4193 #pragma omp sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4194     {
   4195       bar();
   4196     }
   4197   }
   4198 #pragma omp atomic
   4199   // 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}}
   4200   // expected-note@+1 {{expected an expression statement}}
   4201   {
   4202 #pragma omp section // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4203     {
   4204       bar();
   4205     }
   4206   }
   4207 #pragma omp atomic
   4208   // 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}}
   4209   // expected-note@+1 {{expected an expression statement}}
   4210   {
   4211 #pragma omp single // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4212     {
   4213       bar();
   4214     }
   4215   }
   4216 #pragma omp atomic
   4217   // 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}}
   4218   // expected-note@+1 {{expected an expression statement}}
   4219   {
   4220 #pragma omp master // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4221     {
   4222       bar();
   4223     }
   4224   }
   4225 #pragma omp atomic
   4226   // 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}}
   4227   // expected-note@+1 {{expected an expression statement}}
   4228   {
   4229 #pragma omp critical // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4230     {
   4231       bar();
   4232     }
   4233   }
   4234 #pragma omp atomic
   4235   // 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}}
   4236   // expected-note@+1 {{expected an expression statement}}
   4237   {
   4238 #pragma omp parallel for // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4239     for (int i = 0; i < 10; ++i)
   4240       ;
   4241   }
   4242 #pragma omp atomic
   4243   // 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}}
   4244   // expected-note@+1 {{expected an expression statement}}
   4245   {
   4246 #pragma omp parallel for simd // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4247     for (int i = 0; i < 10; ++i)
   4248       ;
   4249   }
   4250 #pragma omp atomic
   4251   // 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}}
   4252   // expected-note@+1 {{expected an expression statement}}
   4253   {
   4254 #pragma omp parallel sections // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4255     {
   4256       bar();
   4257     }
   4258   }
   4259 #pragma omp atomic
   4260   // 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}}
   4261   // expected-note@+1 {{expected an expression statement}}
   4262   {
   4263 #pragma omp task // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4264     {
   4265       bar();
   4266     }
   4267   }
   4268 #pragma omp atomic
   4269   // 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}}
   4270   // expected-note@+1 {{expected an expression statement}}
   4271   {
   4272 #pragma omp taskyield // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4273     bar();
   4274   }
   4275 #pragma omp atomic
   4276   // 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}}
   4277   // expected-note@+1 {{expected an expression statement}}
   4278   {
   4279 #pragma omp barrier // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4280     bar();
   4281   }
   4282 #pragma omp atomic
   4283   // 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}}
   4284   // expected-note@+1 {{expected an expression statement}}
   4285   {
   4286 #pragma omp taskwait // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4287     bar();
   4288   }
   4289 #pragma omp atomic
   4290   // 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}}
   4291   // expected-note@+1 {{expected an expression statement}}
   4292   {
   4293 #pragma omp flush // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4294     bar();
   4295   }
   4296 #pragma omp atomic
   4297   // 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}}
   4298   // expected-note@+1 {{expected an expression statement}}
   4299   {
   4300 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4301     bar();
   4302   }
   4303 #pragma omp atomic
   4304   // 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}}
   4305   // expected-note@+1 {{expected an expression statement}}
   4306   {
   4307 #pragma omp atomic // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4308     ++a;
   4309   }
   4310 #pragma omp atomic
   4311   // 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}}
   4312   // expected-note@+1 {{expected an expression statement}}
   4313   {
   4314 #pragma omp target // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4315     ++a;
   4316   }
   4317 #pragma omp atomic
   4318   // 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}}
   4319   // expected-note@+1 {{expected an expression statement}}
   4320   {
   4321 #pragma omp teams // expected-error {{OpenMP constructs may not be nested inside an atomic region}}
   4322     ++a;
   4323   }
   4324 
   4325 // TARGET DIRECTIVE
   4326 #pragma omp target
   4327 #pragma omp parallel
   4328   bar();
   4329 #pragma omp target
   4330 #pragma omp for
   4331   for (int i = 0; i < 10; ++i)
   4332     ;
   4333 #pragma omp target
   4334 #pragma omp simd
   4335   for (int i = 0; i < 10; ++i)
   4336     ;
   4337 #pragma omp target
   4338 #pragma omp for simd
   4339   for (int i = 0; i < 10; ++i)
   4340     ;
   4341 #pragma omp target
   4342 #pragma omp sections
   4343   {
   4344     bar();
   4345   }
   4346 #pragma omp target
   4347 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a target region}}
   4348   {
   4349     bar();
   4350   }
   4351 #pragma omp target
   4352 #pragma omp single
   4353   bar();
   4354 
   4355 #pragma omp target
   4356 #pragma omp master
   4357   {
   4358     bar();
   4359   }
   4360 #pragma omp target
   4361 #pragma omp critical
   4362   {
   4363     bar();
   4364   }
   4365 #pragma omp target
   4366 #pragma omp parallel for
   4367   for (int i = 0; i < 10; ++i)
   4368     ;
   4369 #pragma omp target
   4370 #pragma omp parallel for simd
   4371   for (int i = 0; i < 10; ++i)
   4372     ;
   4373 #pragma omp target
   4374 #pragma omp parallel sections
   4375   {
   4376     bar();
   4377   }
   4378 #pragma omp target
   4379 #pragma omp task
   4380   {
   4381     bar();
   4382   }
   4383 #pragma omp target
   4384   {
   4385 #pragma omp taskyield
   4386     bar();
   4387   }
   4388 #pragma omp target
   4389   {
   4390 #pragma omp barrier
   4391     bar();
   4392   }
   4393 #pragma omp target
   4394   {
   4395 #pragma omp taskwait
   4396     bar();
   4397   }
   4398 #pragma omp target
   4399   {
   4400 #pragma omp flush
   4401     bar();
   4402   }
   4403 #pragma omp target
   4404   {
   4405 #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?}}
   4406     bar();
   4407   }
   4408 #pragma omp target
   4409   {
   4410 #pragma omp atomic
   4411     ++a;
   4412   }
   4413 #pragma omp target
   4414   {
   4415 #pragma omp target
   4416     ++a;
   4417   }
   4418 #pragma omp target
   4419   {
   4420 #pragma omp teams
   4421     ++a;
   4422   }
   4423 #pragma omp target // expected-error {{target construct with nested teams region contains statements outside of the teams construct}}
   4424   {
   4425     ++a;          // expected-note {{statement outside teams construct here}}
   4426 #pragma omp teams // expected-note {{nested teams construct here}}
   4427     ++a;
   4428   }
   4429 
   4430 // TEAMS DIRECTIVE
   4431 #pragma omp target
   4432 #pragma omp teams
   4433 #pragma omp parallel
   4434   bar();
   4435 #pragma omp target
   4436 #pragma omp teams
   4437 #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?}}
   4438   for (int i = 0; i < 10; ++i)
   4439     ;
   4440 #pragma omp target
   4441 #pragma omp teams
   4442 #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?}}
   4443   for (int i = 0; i < 10; ++i)
   4444     ;
   4445 #pragma omp target
   4446 #pragma omp teams
   4447 #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?}}
   4448   for (int i = 0; i < 10; ++i)
   4449     ;
   4450 #pragma omp target
   4451 #pragma omp teams
   4452 #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?}}
   4453   {
   4454     bar();
   4455   }
   4456 #pragma omp target
   4457 #pragma omp teams
   4458 #pragma omp section // expected-error {{'omp section' directive must be closely nested to a sections region, not a teams region}}
   4459   {
   4460     bar();
   4461   }
   4462 #pragma omp target
   4463 #pragma omp teams
   4464 #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?}}
   4465   bar();
   4466 
   4467 #pragma omp target
   4468 #pragma omp teams
   4469 #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?}}
   4470   {
   4471     bar();
   4472   }
   4473 #pragma omp target
   4474 #pragma omp teams
   4475 #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?}}
   4476   {
   4477     bar();
   4478   }
   4479 #pragma omp target
   4480 #pragma omp teams
   4481 #pragma omp parallel for
   4482   for (int i = 0; i < 10; ++i)
   4483     ;
   4484 #pragma omp target
   4485 #pragma omp teams
   4486 #pragma omp parallel for simd
   4487   for (int i = 0; i < 10; ++i)
   4488     ;
   4489 #pragma omp target
   4490 #pragma omp teams
   4491 #pragma omp parallel sections
   4492   {
   4493     bar();
   4494   }
   4495 #pragma omp target
   4496 #pragma omp teams
   4497 #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?}}
   4498   {
   4499     bar();
   4500   }
   4501 #pragma omp target
   4502 #pragma omp teams
   4503   {
   4504 #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?}}
   4505     bar();
   4506   }
   4507 #pragma omp target
   4508 #pragma omp teams
   4509   {
   4510 #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?}}
   4511     bar();
   4512   }
   4513 #pragma omp target
   4514 #pragma omp teams
   4515   {
   4516 #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?}}
   4517     bar();
   4518   }
   4519 #pragma omp target
   4520 #pragma omp teams
   4521   {
   4522 #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?}}
   4523     bar();
   4524   }
   4525 #pragma omp target
   4526 #pragma omp teams
   4527   {
   4528 #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?}}
   4529     bar();
   4530   }
   4531 #pragma omp target
   4532 #pragma omp teams
   4533   {
   4534 #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?}}
   4535     ++a;
   4536   }
   4537 #pragma omp target
   4538 #pragma omp teams
   4539   {
   4540 #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?}}
   4541     ++a;
   4542   }
   4543 #pragma omp target
   4544 #pragma omp teams
   4545   {
   4546 #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?}}
   4547     ++a;
   4548   }
   4549   return foo<int>();
   4550 }
   4551 
   4552