1 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp %s -Wuninitialized 2 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=50 -fopenmp %s -Wuninitialized 3 4 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp-simd %s -Wuninitialized 5 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-version=50 -fopenmp-simd %s -Wuninitialized 6 7 typedef void **omp_allocator_handle_t; 8 extern const omp_allocator_handle_t omp_default_mem_alloc; 9 extern const omp_allocator_handle_t omp_large_cap_mem_alloc; 10 extern const omp_allocator_handle_t omp_const_mem_alloc; 11 extern const omp_allocator_handle_t omp_high_bw_mem_alloc; 12 extern const omp_allocator_handle_t omp_low_lat_mem_alloc; 13 extern const omp_allocator_handle_t omp_cgroup_mem_alloc; 14 extern const omp_allocator_handle_t omp_pteam_mem_alloc; 15 extern const omp_allocator_handle_t omp_thread_mem_alloc; 16 17 void foo() { 18 } 19 20 bool foobool(int argc) { 21 return argc; 22 } 23 24 struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} 25 extern S1 a; 26 class S2 { 27 mutable int a; 28 29 public: 30 S2() : a(0) {} 31 S2(S2 &s2) : a(s2.a) {} 32 const S2 &operator =(const S2&) const; 33 S2 &operator =(const S2&); 34 static float S2s; // expected-note {{static data member is predetermined as shared}} 35 static const float S2sc; // expected-note {{'S2sc' declared here}} 36 }; 37 const float S2::S2sc = 0; 38 const S2 b; 39 const S2 ba[5]; 40 class S3 { 41 int a; 42 S3 &operator=(const S3 &s3); // expected-note 2 {{implicitly declared private here}} 43 44 public: 45 S3() : a(0) {} 46 S3(S3 &s3) : a(s3.a) {} 47 }; 48 const S3 c; // expected-note {{'c' defined here}} 49 const S3 ca[5]; // expected-note {{'ca' defined here}} 50 extern const int f; // expected-note {{'f' declared here}} 51 class S4 { 52 int a; 53 S4(); // expected-note 3 {{implicitly declared private here}} 54 S4(const S4 &s4); 55 56 public: 57 S4(int v) : a(v) {} 58 }; 59 class S5 { 60 int a; 61 S5() : a(0) {} // expected-note {{implicitly declared private here}} 62 63 public: 64 S5(const S5 &s5) : a(s5.a) {} 65 S5(int v) : a(v) {} 66 }; 67 class S6 { 68 int a; 69 S6() : a(0) {} 70 71 public: 72 S6(const S6 &s6) : a(s6.a) {} 73 S6(int v) : a(v) {} 74 }; 75 76 S3 h; 77 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} 78 79 template <class I, class C> 80 int foomain(int argc, char **argv) { 81 I e(4); 82 I g(5); 83 int i, z; 84 int &j = i; 85 #pragma omp parallel 86 #pragma omp parallel master taskloop simd lastprivate // expected-error {{expected '(' after 'lastprivate'}} 87 for (int k = 0; k < argc; ++k) 88 ++k; 89 #pragma omp parallel 90 #pragma omp parallel master taskloop simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 91 for (int k = 0; k < argc; ++k) 92 ++k; 93 #pragma omp parallel 94 #pragma omp parallel master taskloop simd lastprivate() // expected-error {{expected expression}} 95 for (int k = 0; k < argc; ++k) 96 ++k; 97 #pragma omp parallel 98 #pragma omp parallel master taskloop simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 99 for (int k = 0; k < argc; ++k) 100 ++k; 101 #pragma omp parallel 102 #pragma omp parallel master taskloop simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 103 for (int k = 0; k < argc; ++k) 104 ++k; 105 #pragma omp parallel 106 #pragma omp parallel master taskloop simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 107 for (int k = 0; k < argc; ++k) 108 ++k; 109 #pragma omp parallel 110 #pragma omp parallel master taskloop simd lastprivate(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 '('}} 111 for (int k = 0; k < argc; ++k) 112 ++k; 113 #pragma omp parallel 114 #pragma omp parallel master taskloop simd lastprivate(conditional: argc) lastprivate(conditional: // expected-error 2 {{use of undeclared identifier 'conditional'}} expected-error {{expected ')'}} expected-note {{to match this '('}} 115 for (int k = 0; k < argc; ++k) 116 ++k; 117 #pragma omp parallel 118 #pragma omp parallel master taskloop simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}} 119 for (int k = 0; k < argc; ++k) 120 ++k; 121 #pragma omp parallel 122 #pragma omp parallel master taskloop simd lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}} 123 for (int k = 0; k < argc; ++k) 124 ++k; 125 #pragma omp parallel 126 #pragma omp parallel master taskloop simd lastprivate(argv[1]) // expected-error {{expected variable name}} 127 for (int k = 0; k < argc; ++k) 128 ++k; 129 #pragma omp parallel 130 #pragma omp parallel master taskloop simd lastprivate(z, e, g) // expected-error 2 {{calling a private constructor of class 'S4'}} 131 for (int k = 0; k < argc; ++k) 132 ++k; 133 #pragma omp parallel 134 #pragma omp parallel master taskloop simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} 135 for (int k = 0; k < argc; ++k) 136 ++k; 137 #pragma omp parallel 138 { 139 int v = 0; 140 int i; 141 #pragma omp parallel master taskloop simd allocate(omp_thread_mem_alloc: i) lastprivate(i) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'parallel master taskloop simd' directive}} 142 for (int k = 0; k < argc; ++k) { 143 i = k; 144 v += i; 145 } 146 } 147 #pragma omp parallel shared(i) 148 #pragma omp parallel private(i) 149 #pragma omp parallel master taskloop simd lastprivate(j) 150 for (int k = 0; k < argc; ++k) 151 ++k; 152 #pragma omp parallel 153 #pragma omp parallel master taskloop simd lastprivate(i) 154 for (int k = 0; k < argc; ++k) 155 ++k; 156 return 0; 157 } 158 159 void bar(S4 a[2]) { 160 #pragma omp parallel 161 #pragma omp parallel master taskloop simd lastprivate(a) 162 for (int i = 0; i < 2; ++i) 163 foo(); 164 } 165 166 namespace A { 167 double x; 168 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} 169 } 170 namespace B { 171 using A::x; 172 } 173 174 int main(int argc, char **argv) { 175 const int d = 5; // expected-note {{'d' defined here}} 176 const int da[5] = {0}; // expected-note {{'da' defined here}} 177 S4 e(4); 178 S5 g(5); 179 S3 m; 180 S6 n(2); 181 int i, z; 182 int &j = i; 183 #pragma omp parallel 184 #pragma omp parallel master taskloop simd lastprivate // expected-error {{expected '(' after 'lastprivate'}} 185 for (i = 0; i < argc; ++i) 186 foo(); 187 #pragma omp parallel 188 #pragma omp parallel master taskloop simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 189 for (i = 0; i < argc; ++i) 190 foo(); 191 #pragma omp parallel 192 #pragma omp parallel master taskloop simd lastprivate() // expected-error {{expected expression}} 193 for (i = 0; i < argc; ++i) 194 foo(); 195 #pragma omp parallel 196 #pragma omp parallel master taskloop simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 197 for (i = 0; i < argc; ++i) 198 foo(); 199 #pragma omp parallel 200 #pragma omp parallel master taskloop simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 201 for (i = 0; i < argc; ++i) 202 foo(); 203 #pragma omp parallel 204 #pragma omp parallel master taskloop simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 205 for (i = 0; i < argc; ++i) 206 foo(); 207 #pragma omp parallel 208 #pragma omp parallel master taskloop simd lastprivate(argc, z) 209 for (i = 0; i < argc; ++i) 210 foo(); 211 #pragma omp parallel 212 #pragma omp parallel master taskloop simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}} 213 for (i = 0; i < argc; ++i) 214 foo(); 215 #pragma omp parallel 216 #pragma omp parallel master taskloop simd lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 1 {{const-qualified variable without mutable fields cannot be lastprivate}} expected-error 2 {{const-qualified variable cannot be lastprivate}} 217 for (i = 0; i < argc; ++i) 218 foo(); 219 #pragma omp parallel 220 #pragma omp parallel master taskloop simd lastprivate(argv[1]) // expected-error {{expected variable name}} 221 for (i = 0; i < argc; ++i) 222 foo(); 223 #pragma omp parallel 224 #pragma omp parallel master taskloop simd lastprivate(2 * 2) // expected-error {{expected variable name}} 225 for (i = 0; i < argc; ++i) 226 foo(); 227 #pragma omp parallel 228 #pragma omp parallel master taskloop simd lastprivate(ba) 229 for (i = 0; i < argc; ++i) 230 foo(); 231 #pragma omp parallel 232 #pragma omp parallel master taskloop simd lastprivate(ca) // expected-error {{const-qualified variable without mutable fields cannot be lastprivate}} 233 for (i = 0; i < argc; ++i) 234 foo(); 235 #pragma omp parallel 236 #pragma omp parallel master taskloop simd lastprivate(da) // expected-error {{const-qualified variable cannot be lastprivate}} 237 for (i = 0; i < argc; ++i) 238 foo(); 239 int xa; 240 #pragma omp parallel 241 #pragma omp parallel master taskloop simd lastprivate(xa) // OK 242 for (i = 0; i < argc; ++i) 243 foo(); 244 #pragma omp parallel 245 #pragma omp parallel master taskloop simd lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}} 246 for (i = 0; i < argc; ++i) 247 foo(); 248 #pragma omp parallel 249 #pragma omp parallel master taskloop simd lastprivate(S2::S2sc) // expected-error {{const-qualified variable cannot be lastprivate}} 250 for (i = 0; i < argc; ++i) 251 foo(); 252 #pragma omp parallel 253 #pragma omp parallel master taskloop simd safelen(5) 254 for (i = 0; i < argc; ++i) 255 foo(); 256 #pragma omp parallel 257 #pragma omp parallel master taskloop simd lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} 258 for (i = 0; i < argc; ++i) 259 foo(); 260 #pragma omp parallel 261 #pragma omp parallel master taskloop simd lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} 262 for (i = 0; i < argc; ++i) 263 foo(); 264 #pragma omp parallel 265 #pragma omp parallel master taskloop simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} 266 for (i = 0; i < argc; ++i) 267 foo(); 268 #pragma omp parallel 269 #pragma omp parallel master taskloop simd lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} 270 for (i = 0; i < argc; ++i) 271 foo(); 272 #pragma omp parallel 273 #pragma omp parallel master taskloop simd private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}} 274 for (i = 0; i < argc; ++i) 275 foo(); 276 #pragma omp parallel 277 #pragma omp parallel master taskloop simd linear(i) 278 for (i = 0; i < argc; ++i) 279 foo(); 280 #pragma omp parallel private(xa) 281 #pragma omp parallel master taskloop simd lastprivate(xa) 282 for (i = 0; i < argc; ++i) 283 foo(); 284 #pragma omp parallel reduction(+ : xa) 285 #pragma omp parallel master taskloop simd lastprivate(xa) 286 for (i = 0; i < argc; ++i) 287 foo(); 288 #pragma omp parallel 289 #pragma omp parallel master taskloop simd lastprivate(j) 290 for (i = 0; i < argc; ++i) 291 foo(); 292 #pragma omp parallel 293 #pragma omp parallel master taskloop simd firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} 294 for (i = 0; i < argc; ++i) 295 foo(); 296 #pragma omp parallel 297 #pragma omp parallel master taskloop simd lastprivate(n) firstprivate(n) // OK 298 for (i = 0; i < argc; ++i) 299 foo(); 300 static int si; 301 #pragma omp parallel master taskloop simd lastprivate(si) // OK 302 for (i = 0; i < argc; ++i) 303 si = i + 1; 304 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} 305 } 306