Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s
      2 
      3 void foo() {
      4 }
      5 
      6 bool foobool(int argc) {
      7   return argc;
      8 }
      9 
     10 struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}}
     11 extern S1 a;
     12 class S2 {
     13   mutable int a;
     14 
     15 public:
     16   S2() : a(0) {}
     17   S2(const S2 &s2) : a(s2.a) {}
     18   static float S2s;
     19   static const float S2sc;
     20 };
     21 const float S2::S2sc = 0;
     22 const S2 b;
     23 const S2 ba[5];
     24 class S3 {
     25   int a;
     26 
     27 public:
     28   S3() : a(0) {}
     29   S3(const S3 &s3) : a(s3.a) {}
     30 };
     31 const S3 c;
     32 const S3 ca[5];
     33 extern const int f;
     34 class S4 {
     35   int a;
     36   S4();
     37   S4(const S4 &s4); // expected-note 2 {{implicitly declared private here}}
     38 
     39 public:
     40   S4(int v) : a(v) {}
     41 };
     42 class S5 {
     43   int a;
     44   S5() : a(0) {}
     45   S5(const S5 &s5) : a(s5.a) {} // expected-note 2 {{implicitly declared private here}}
     46 
     47 public:
     48   S5(int v) : a(v) {}
     49 };
     50 
     51 S3 h;
     52 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
     53 
     54 namespace A {
     55 double x;
     56 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
     57 }
     58 namespace B {
     59 using A::x;
     60 }
     61 
     62 int main(int argc, char **argv) {
     63   const int d = 5;
     64   const int da[5] = {0};
     65   S4 e(4);
     66   S5 g(5);
     67   int i;
     68   int &j = i;                                               // expected-note {{'j' defined here}}
     69 #pragma omp task firstprivate                               // expected-error {{expected '(' after 'firstprivate'}}
     70 #pragma omp task firstprivate(                              // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     71 #pragma omp task firstprivate()                             // expected-error {{expected expression}}
     72 #pragma omp task firstprivate(argc                          // expected-error {{expected ')'}} expected-note {{to match this '('}}
     73 #pragma omp task firstprivate(argc,                         // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
     74 #pragma omp task firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
     75 #pragma omp task firstprivate(argc)
     76 #pragma omp task firstprivate(S1)            // expected-error {{'S1' does not refer to a value}}
     77 #pragma omp task firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
     78 #pragma omp task firstprivate(argv[1])       // expected-error {{expected variable name}}
     79 #pragma omp task firstprivate(ba)
     80 #pragma omp task firstprivate(ca)
     81 #pragma omp task firstprivate(da)
     82 #pragma omp task firstprivate(S2::S2s)
     83 #pragma omp task firstprivate(S2::S2sc)
     84 #pragma omp task firstprivate(e, g)          // expected-error 2 {{calling a private constructor of class 'S4'}} expected-error 2 {{calling a private constructor of class 'S5'}}
     85 #pragma omp task firstprivate(h, B::x)       // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}}
     86 #pragma omp task private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}}
     87   foo();
     88 #pragma omp task shared(i)
     89 #pragma omp task firstprivate(i)
     90 #pragma omp task firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
     91   foo();
     92 
     93   return 0;
     94 }
     95