1 // RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-mapping -Wuninitialized 2 3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-mapping -Wuninitialized 4 5 void foo() { 6 } 7 8 bool foobool(int argc) { 9 return argc; 10 } 11 struct S1; // expected-note {{declared here}} // expected-note {{forward declaration of 'S1'}} 12 extern S1 a; 13 class S2 { 14 mutable int a; 15 public: 16 S2():a(0) { } 17 S2(S2 &s2):a(s2.a) { } 18 }; 19 const S2 b; 20 const S2 ba[5]; 21 class S3 { 22 int a; 23 public: 24 S3():a(0) { } 25 S3(S3 &s3):a(s3.a) { } 26 }; 27 const S3 c; 28 const S3 ca[5]; 29 extern const int f; 30 class S4 { 31 int a; 32 S4(); 33 S4(const S4 &s4); 34 public: 35 S4(int v):a(v) { } 36 }; 37 class S5 { 38 int a; 39 S5():a(0) {} 40 S5(const S5 &s5):a(s5.a) { } 41 public: 42 S5(int v):a(v) { } 43 }; 44 45 S3 h; 46 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} 47 48 namespace A { 49 double x; 50 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} 51 } 52 namespace B { 53 using A::x; 54 } 55 56 int main(int argc, char **argv) { 57 const int d = 5; 58 const int da[5] = { 0 }; 59 S4 e(4); 60 S5 g(5); 61 int i, z; 62 int &j = i; 63 #pragma omp target 64 #pragma omp teams shared // expected-error {{expected '(' after 'shared'}} 65 foo(); 66 #pragma omp target 67 #pragma omp teams shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 68 foo(); 69 #pragma omp target 70 #pragma omp teams shared () // expected-error {{expected expression}} 71 foo(); 72 #pragma omp target 73 #pragma omp teams shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 74 foo(); 75 #pragma omp target 76 #pragma omp teams shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 77 foo(); 78 #pragma omp target 79 #pragma omp teams shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 80 foo(); 81 #pragma omp target 82 #pragma omp teams shared (argc) 83 foo(); 84 #pragma omp target 85 #pragma omp teams shared (S1) // expected-error {{'S1' does not refer to a value}} 86 foo(); 87 #pragma omp target 88 #pragma omp teams shared (a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} 89 foo(); 90 #pragma omp target 91 #pragma omp teams shared (argv[1]) // expected-error {{expected variable name}} 92 foo(); 93 #pragma omp target 94 #pragma omp teams shared(ba) 95 foo(); 96 #pragma omp target 97 #pragma omp teams shared(ca) 98 foo(); 99 #pragma omp target 100 #pragma omp teams shared(da) 101 foo(); 102 #pragma omp target 103 #pragma omp teams shared(e, g, z) 104 foo(); 105 #pragma omp target 106 #pragma omp teams shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}} 107 foo(); 108 #pragma omp target 109 #pragma omp teams private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}} 110 foo(); 111 #pragma omp target 112 #pragma omp teams firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}} 113 foo(); 114 #pragma omp target 115 #pragma omp teams private(i) 116 foo(); 117 #pragma omp target 118 #pragma omp teams shared(i) 119 foo(); 120 #pragma omp target 121 #pragma omp teams shared(j) 122 foo(); 123 #pragma omp target 124 #pragma omp teams firstprivate(i) 125 foo(); 126 #pragma omp target 127 #pragma omp teams shared(i) 128 foo(); 129 #pragma omp target 130 #pragma omp teams shared(j) 131 foo(); 132 133 return 0; 134 } 135