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