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