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