1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 %s -Wuninitialized 2 3 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 %s -Wuninitialized 4 5 typedef void **omp_allocator_handle_t; 6 extern const omp_allocator_handle_t omp_null_allocator; 7 extern const omp_allocator_handle_t omp_default_mem_alloc; 8 extern const omp_allocator_handle_t omp_large_cap_mem_alloc; 9 extern const omp_allocator_handle_t omp_const_mem_alloc; 10 extern const omp_allocator_handle_t omp_high_bw_mem_alloc; 11 extern const omp_allocator_handle_t omp_low_lat_mem_alloc; 12 extern const omp_allocator_handle_t omp_cgroup_mem_alloc; 13 extern const omp_allocator_handle_t omp_pteam_mem_alloc; 14 extern const omp_allocator_handle_t omp_thread_mem_alloc; 15 16 void foo() { 17 } 18 19 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} expected-note 1 {{forward declaration of 'S1'}} expected-note {{forward declaration of 'S1'}} 20 extern S1 a; 21 class S2 { 22 mutable int a; 23 24 public: 25 S2() : a(0) {} 26 static float S2s; // expected-note {{static data member is predetermined as shared}} expected-note 1 {{static data member is predetermined as shared}} 27 }; 28 const S2 b; 29 const S2 ba[5]; 30 class S3 { 31 int a; 32 33 public: 34 S3() : a(0) {} 35 }; 36 const S3 c; // expected-note 2 {{'c' defined here}} 37 const S3 ca[5]; // expected-note 2 {{'ca' defined here}} 38 extern const int f; // expected-note 2 {{'f' declared here}} 39 40 int threadvar; 41 #pragma omp threadprivate(threadvar) // expected-note {{defined as threadprivate or thread local}} expected-note 1 {{defined as threadprivate or thread local}} 42 43 class S4 { 44 int a; 45 S4(); // expected-note {{implicitly declared private here}} expected-note 1 {{implicitly declared private here}} 46 47 public: 48 S4(int v) : a(v) {} 49 }; 50 class S5 { 51 int a; 52 S5() : a(0) {} // expected-note {{implicitly declared private here}} expected-note 1 {{implicitly declared private here}} 53 54 public: 55 S5(int v) : a(v) {} 56 }; 57 namespace A { 58 double x; 59 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} expected-note 1 {{defined as threadprivate or thread local}} expected-note 2 {{defined as threadprivate or thread local}} 60 } 61 namespace B { 62 using A::x; 63 } 64 65 S3 h; 66 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} 67 68 template <class I, class C, class D, class E> 69 int foomain(I argc, C **argv) { 70 const I d = 5; // expected-note {{'d' defined here}} 71 const I da[5] = { 0 }; // expected-note {{'da' defined here}} 72 D e(4); 73 E g[] = {5, 6}; 74 I i; 75 I &j = i; 76 #pragma omp target parallel private // expected-error {{expected '(' after 'private'}} 77 {} 78 #pragma omp target parallel private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 79 {} 80 #pragma omp target parallel private() // expected-error {{expected expression}} 81 {} 82 #pragma omp target parallel private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 83 {} 84 #pragma omp target parallel private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 85 {} 86 #pragma omp target parallel private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 87 {} 88 #pragma omp target parallel private(argc argv) // expected-error {{expected ',' or ')' in 'private' clause}} 89 {} 90 #pragma omp target parallel private(argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}} 91 {} 92 #pragma omp target parallel private(S1) // expected-error {{'S1' does not refer to a value}} 93 {} 94 #pragma omp target parallel private(a, b) // expected-error {{private variable with incomplete type 'S1'}} 95 {} 96 #pragma omp target parallel private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 1 {{const-qualified variable without mutable fields cannot be private}} expected-error 2 {{const-qualified variable cannot be private}} 97 {} 98 #pragma omp target parallel private(argv[1]) // expected-error {{expected variable name}} 99 {} 100 #pragma omp target parallel allocate(omp_thread_mem_alloc: ba) private(ba) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target parallel' directive}} expected-error {{allocator must be specified in the 'uses_allocators' clause}} 101 {} 102 #pragma omp target parallel private(ca) // expected-error {{const-qualified variable without mutable fields cannot be private}} 103 {} 104 #pragma omp target parallel private(da) // expected-error {{const-qualified variable cannot be private}} 105 {} 106 #pragma omp target parallel private(S2::S2s) // expected-error {{shared variable cannot be private}} 107 {} 108 #pragma omp target parallel private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} 109 {} 110 #pragma omp target parallel private(threadvar, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}} 111 {} 112 #pragma omp target parallel shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}} 113 foo(); 114 #pragma omp target parallel firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}} 115 foo(); 116 #pragma omp target parallel private(i) 117 {} 118 #pragma omp target parallel private(j) 119 foo(); 120 #pragma omp parallel firstprivate(i) 121 for (int k = 0; k < 10; ++k) { 122 #pragma omp target parallel private(i) 123 foo(); 124 } 125 static int m; 126 #pragma omp target parallel private(m) // OK 127 foo(); 128 #pragma omp target parallel private(h) // expected-error {{threadprivate or thread local variable cannot be private}} 129 {} 130 #pragma omp target parallel private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}} 131 #pragma omp parallel 132 { 133 int v = 0; 134 int i; 135 } 136 #pragma omp target parallel shared(i) 137 {} 138 #pragma omp target parallel private(i) 139 {} 140 #pragma omp target parallel private(j) 141 {} 142 #pragma omp target parallel private(i) 143 {} 144 static int si; 145 #pragma omp target parallel private(si) // OK 146 {} 147 return 0; 148 } 149 150 void bar(S4 a[2]) { 151 #pragma omp parallel 152 #pragma omp target parallel private(a) 153 {} 154 } 155 156 int main(int argc, char **argv) { 157 const int d = 5; // expected-note {{'d' defined here}} 158 const int da[5] = { 0 }; // expected-note {{'da' defined here}} 159 S4 e(4); 160 S5 g[] = {5, 6}; 161 int i; 162 int &j = i; 163 #pragma omp target parallel private // expected-error {{expected '(' after 'private'}} 164 {} 165 #pragma omp target parallel private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 166 {} 167 #pragma omp target parallel private() // expected-error {{expected expression}} 168 {} 169 #pragma omp target parallel private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 170 {} 171 #pragma omp target parallel private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 172 {} 173 #pragma omp target parallel private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 174 {} 175 #pragma omp target parallel private(argc argv) // expected-error {{expected ',' or ')' in 'private' clause}} 176 {} 177 #pragma omp target parallel private(argc) 178 {} 179 #pragma omp target parallel private(S1) // expected-error {{'S1' does not refer to a value}} 180 {} 181 #pragma omp target parallel private(a, b) // expected-error {{private variable with incomplete type 'S1'}} 182 {} 183 #pragma omp target parallel private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 1 {{const-qualified variable without mutable fields cannot be private}} expected-error 2 {{const-qualified variable cannot be private}} 184 {} 185 #pragma omp target parallel private(argv[1]) // expected-error {{expected variable name}} 186 {} 187 #pragma omp target parallel private(ba) 188 {} 189 #pragma omp target parallel private(ca) // expected-error {{const-qualified variable without mutable fields cannot be private}} 190 {} 191 #pragma omp target parallel private(da) // expected-error {{const-qualified variable cannot be private}} 192 {} 193 #pragma omp target parallel private(S2::S2s) // expected-error {{shared variable cannot be private}} 194 {} 195 #pragma omp target parallel private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} 196 {} 197 #pragma omp target parallel private(threadvar, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}} 198 {} 199 #pragma omp target parallel shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}} 200 foo(); 201 #pragma omp target parallel firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}} 202 foo(); 203 #pragma omp target parallel private(i) 204 {} 205 #pragma omp target parallel private(j) 206 foo(); 207 #pragma omp parallel firstprivate(i) 208 for (int k = 0; k < 10; ++k) { 209 #pragma omp target parallel private(i) 210 foo(); 211 } 212 static int m; 213 #pragma omp target parallel private(m) // OK 214 foo(); 215 #pragma omp target parallel private(h) // expected-error {{threadprivate or thread local variable cannot be private}} 216 {} 217 #pragma omp target parallel private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}} 218 #pragma omp parallel 219 { 220 int i; 221 } 222 #pragma omp target parallel shared(i) 223 {} 224 #pragma omp target parallel private(i) 225 {} 226 #pragma omp target parallel private(j) 227 {} 228 #pragma omp target parallel private(i) 229 {} 230 static int si; 231 #pragma omp target parallel private(si) // OK 232 {} 233 return foomain<int, char, S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char, S4, S5>' requested here}} 234 } 235 236