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 parallel for simd // expected-error {{unexpected OpenMP directive '#pragma omp parallel for simd'}}
      7 
      8 int main(int argc, char **argv) {
      9 #pragma omp parallel for simd { // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
     10   for (int i = 0; i < argc; ++i)
     11     foo();
     12 #pragma omp parallel for simd ( // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
     13   for (int i = 0; i < argc; ++i)
     14     foo();
     15 #pragma omp parallel for simd[ // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
     16   for (int i = 0; i < argc; ++i)
     17     foo();
     18 #pragma omp parallel for simd] // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
     19   for (int i = 0; i < argc; ++i)
     20     foo();
     21 #pragma omp parallel for simd) // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
     22   for (int i = 0; i < argc; ++i)
     23     foo();
     24 #pragma omp parallel for simd } // expected-warning {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
     25   for (int i = 0; i < argc; ++i)
     26     foo();
     27 #pragma omp parallel for simd
     28   for (int i = 0; i < argc; ++i)
     29     foo();
     30 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}}
     31 #pragma omp parallel for simd unknown()
     32   for (int i = 0; i < argc; ++i)
     33     foo();
     34 L1:
     35   for (int i = 0; i < argc; ++i)
     36     foo();
     37 #pragma omp parallel for simd
     38   for (int i = 0; i < argc; ++i)
     39     foo();
     40 #pragma omp parallel for simd
     41   for (int i = 0; i < argc; ++i) {
     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 parallel for simd
     50       for (int i = 0; i < argc; ++i) {
     51         foo();
     52         break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
     53         continue;
     54       }
     55     default:
     56       break;
     57     }
     58   }
     59 #pragma omp parallel for simd default(none)
     60   for (int i = 0; i < 10; ++i)
     61     ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
     62 
     63   goto L2; // expected-error {{use of undeclared label 'L2'}}
     64 #pragma omp parallel for simd
     65   for (int i = 0; i < argc; ++i)
     66   L2:
     67   foo();
     68 #pragma omp parallel for simd
     69   for (int i = 0; i < argc; ++i) {
     70     return 1; // expected-error {{cannot return from OpenMP region}}
     71   }
     72 
     73   [[]] // expected-error {{an attribute list cannot appear here}}
     74 #pragma omp parallel for simd
     75       for (int n = 0; n < 100; ++n) {
     76   }
     77 
     78   return 0;
     79 }
     80 
     81 void test_ordered() {
     82 #pragma omp parallel for simd ordered ordered // expected-error {{directive '#pragma omp parallel for simd' cannot contain more than one 'ordered' clause}}
     83   for (int i = 0; i < 16; ++i)
     84     ;
     85 #pragma omp parallel for simd ordered
     86   for (int i = 0; i < 16; ++i)
     87     ;
     88 // expected-error@+1 {{'ordered' clause with a parameter can not be specified in '#pragma omp parallel for simd' directive}}
     89 #pragma omp parallel for simd ordered(1)
     90   for (int i = 0; i < 16; ++i)
     91     ;
     92 }
     93 
     94