Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s
      2 
      3 void foo() {
      4 }
      5 
      6 #pragma omp parallel // expected-error {{unexpected OpenMP directive '#pragma omp parallel'}}
      7 
      8 int main(int argc, char **argv) {
      9   #pragma omp parallel { // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}
     10   foo();
     11   #pragma omp parallel ( // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}
     12   foo();
     13   #pragma omp parallel [ // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}
     14   foo();
     15   #pragma omp parallel ] // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}
     16   foo();
     17   #pragma omp parallel ) // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}
     18   foo();
     19   #pragma omp parallel } // expected-warning {{extra tokens at the end of '#pragma omp parallel' are ignored}}
     20   foo();
     21   #pragma omp parallel
     22   // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel' are ignored}}
     23   #pragma omp parallel unknown()
     24   foo();
     25   L1:
     26     foo();
     27   #pragma omp parallel
     28   ;
     29   #pragma omp parallel
     30   {
     31     goto L1; // expected-error {{use of undeclared label 'L1'}}
     32     argc++;
     33   }
     34 
     35   for (int i = 0; i < 10; ++i) {
     36     switch(argc) {
     37      case (0):
     38       #pragma omp parallel
     39       {
     40         foo();
     41         break; // expected-error {{'break' statement not in loop or switch statement}}
     42         continue; // expected-error {{'continue' statement not in loop statement}}
     43       }
     44       default:
     45        break;
     46     }
     47   }
     48   #pragma omp parallel default(none)
     49   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     50 
     51   goto L2; // expected-error {{use of undeclared label 'L2'}}
     52   #pragma omp parallel
     53   L2:
     54   foo();
     55   #pragma omp parallel
     56   {
     57     return 1; // expected-error {{cannot return from OpenMP region}}
     58   }
     59 
     60   [[]] // expected-error {{an attribute list cannot appear here}}
     61   #pragma omp parallel
     62   for (int n = 0; n < 100; ++n) {}
     63 
     64   return 0;
     65 }
     66 
     67