1 // RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-target 2 3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-target 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 S2(const S2 &s2) : a(s2.a) {} 20 static float S2s; 21 static const float S2sc; 22 }; 23 const float S2::S2sc = 0; 24 const S2 b; 25 const S2 ba[5]; 26 class S3 { 27 int a; 28 29 public: 30 S3() : a(0) {} 31 S3(const S3 &s3) : a(s3.a) {} 32 }; 33 const S3 c; 34 const S3 ca[5]; 35 extern const int f; 36 class S4 { 37 int a; 38 S4(); 39 S4(const S4 &s4); // expected-note {{implicitly declared private here}} 40 public: 41 S4(int v) : a(v) {} 42 }; 43 class S5 { 44 int a; 45 S5() : a(0) {} 46 S5(const S5 &s5) : a(s5.a) {} // expected-note {{implicitly declared private here}} 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; 69 #pragma omp target 70 #pragma omp teams firstprivate // expected-error {{expected '(' after 'firstprivate'}} 71 foo(); 72 #pragma omp target 73 #pragma omp teams firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 74 foo(); 75 #pragma omp target 76 #pragma omp teams firstprivate() // expected-error {{expected expression}} 77 foo(); 78 #pragma omp target 79 #pragma omp teams firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 80 foo(); 81 #pragma omp target 82 #pragma omp teams firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 83 foo(); 84 #pragma omp target 85 #pragma omp teams firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 86 foo(); 87 #pragma omp target 88 #pragma omp teams firstprivate(argc) 89 foo(); 90 #pragma omp target 91 #pragma omp teams firstprivate(S1) // expected-error {{'S1' does not refer to a value}} 92 foo(); 93 #pragma omp target 94 #pragma omp teams firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} 95 foo(); 96 #pragma omp target 97 #pragma omp teams firstprivate(argv[1]) // expected-error {{expected variable name}} 98 foo(); 99 #pragma omp target 100 #pragma omp teams firstprivate(ba) 101 foo(); 102 #pragma omp target 103 #pragma omp teams firstprivate(ca) 104 foo(); 105 #pragma omp target 106 #pragma omp teams firstprivate(da) 107 foo(); 108 #pragma omp target 109 #pragma omp teams firstprivate(S2::S2s) 110 foo(); 111 #pragma omp target 112 #pragma omp teams firstprivate(S2::S2sc) 113 foo(); 114 #pragma omp target 115 #pragma omp teams firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} 116 foo(); 117 #pragma omp target 118 #pragma omp teams firstprivate(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be firstprivate}} 119 foo(); 120 #pragma omp target 121 #pragma omp teams private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}} 122 foo(); 123 #pragma omp target 124 #pragma omp teams shared(i) 125 foo(); 126 #pragma omp target 127 #pragma omp teams firstprivate(i) 128 foo(); 129 #pragma omp target 130 #pragma omp teams firstprivate(j) 131 foo(); 132 static int m; 133 #pragma omp target 134 #pragma omp teams firstprivate(m) // OK 135 foo(); 136 137 return 0; 138 } 139