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