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 struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}} 13 extern S1 a; 14 class S2 { 15 mutable int a; 16 17 public: 18 S2() : a(0) {} 19 static float S2s; // expected-note {{static data member is predetermined as shared}} 20 }; 21 const S2 b; 22 const S2 ba[5]; 23 class S3 { 24 int a; 25 26 public: 27 S3() : a(0) {} 28 }; 29 const S3 c; // expected-note {{global variable is predetermined as shared}} 30 const S3 ca[5]; // expected-note {{global variable is predetermined as shared}} 31 extern const int f; // expected-note {{global variable is predetermined as shared}} 32 class S4 { 33 int a; 34 S4(); // expected-note {{implicitly declared private here}} 35 36 public: 37 S4(int v) : a(v) {} 38 }; 39 class S5 { 40 int a; 41 S5() : a(0) {} // expected-note {{implicitly declared private here}} 42 43 public: 44 S5(int v) : a(v) {} 45 }; 46 47 int threadvar; 48 #pragma omp threadprivate(threadvar) // expected-note {{defined as threadprivate or thread local}} 49 50 void bar(int n, int b[n]) { 51 #pragma omp task private(b) 52 foo(); 53 } 54 55 namespace A { 56 double x; 57 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} 58 } 59 namespace B { 60 using A::x; 61 } 62 63 int main(int argc, char **argv) { 64 const int d = 5; // expected-note {{constant variable is predetermined as shared}} 65 const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}} 66 S4 e(4); 67 S5 g(5); 68 int i; 69 int &j = i; 70 #pragma omp task private // expected-error {{expected '(' after 'private'}} 71 #pragma omp task private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 72 #pragma omp task private() // expected-error {{expected expression}} 73 #pragma omp task private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 74 #pragma omp task private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 75 #pragma omp task private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 76 #pragma omp task private(argc argv) // expected-error {{expected ',' or ')' in 'private' clause}} 77 #pragma omp task private(S1) // expected-error {{'S1' does not refer to a value}} 78 #pragma omp task private(a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be private}} 79 #pragma omp task private(argv[1]) // expected-error {{expected variable name}} 80 #pragma omp task private(ba) 81 #pragma omp task private(ca) // expected-error {{shared variable cannot be private}} 82 #pragma omp task private(da) // expected-error {{shared variable cannot be private}} 83 #pragma omp task private(S2::S2s) // expected-error {{shared variable cannot be private}} 84 #pragma omp task private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} 85 #pragma omp task private(threadvar, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}} 86 #pragma omp task shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}} 87 foo(); 88 #pragma omp task firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}} 89 foo(); 90 #pragma omp task private(i) 91 #pragma omp task private(j) 92 foo(); 93 #pragma omp task firstprivate(i) 94 for (int k = 0; k < 10; ++k) { 95 #pragma omp task private(i) 96 foo(); 97 } 98 static int m; 99 #pragma omp task private(m) // OK 100 foo(); 101 102 return 0; 103 } 104