1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 200 %s 2 // rUN: %clang_cc1 -DCCODE -verify -fopenmp -ferror-limit 200 -x c %s 3 #ifdef CCODE 4 void foo(int arg) { 5 const int n = 0; 6 7 double marr[10][10][10]; 8 9 #pragma omp target teams map(marr[2][0:2][0:2]) // expected-error {{array section does not specify contiguous storage}} 10 {} 11 #pragma omp target teams map(marr[:][0:][:]) 12 {} 13 #pragma omp target teams map(marr[:][1:][:]) // expected-error {{array section does not specify contiguous storage}} 14 {} 15 #pragma omp target teams map(marr[:][n:][:]) 16 {} 17 } 18 #else 19 template <typename T, int I> 20 struct SA { 21 static int ss; 22 #pragma omp threadprivate(ss) // expected-note {{defined as threadprivate or thread local}} 23 float a; 24 int b[12]; 25 float *c; 26 T d; 27 float e[I]; 28 T *f; 29 void func(int arg) { 30 #pragma omp target teams map(arg,a,d) 31 {} 32 #pragma omp target teams map(arg[2:2],a,d) // expected-error {{subscripted value is not an array or pointer}} 33 {} 34 #pragma omp target teams map(arg,a*2) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}} 35 {} 36 #pragma omp target teams map(arg,(c+1)[2]) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}} 37 {} 38 #pragma omp target teams map(arg,a[:2],d) // expected-error {{subscripted value is not an array or pointer}} 39 {} 40 #pragma omp target teams map(arg,a,d[:2]) // expected-error {{subscripted value is not an array or pointer}} 41 {} 42 43 #pragma omp target teams map(to:ss) // expected-error {{threadprivate variables are not allowed in 'map' clause}} 44 {} 45 46 #pragma omp target teams map(to:b,e) 47 {} 48 #pragma omp target teams map(to:b,e) map(to:b) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 49 {} 50 #pragma omp target teams map(to:b[:2],e) 51 {} 52 #pragma omp target teams map(to:b,e[:]) 53 {} 54 #pragma omp target teams map(b[-1:]) // expected-error {{array section must be a subset of the original array}} 55 {} 56 #pragma omp target teams map(b[:-1]) // expected-error {{section length is evaluated to a negative value -1}} 57 {} 58 59 #pragma omp target teams map(always, tofrom: c,f) 60 {} 61 #pragma omp target teams map(always, tofrom: c[1:2],f) 62 {} 63 #pragma omp target teams map(always, tofrom: c,f[1:2]) 64 {} 65 #pragma omp target teams map(always, tofrom: c[:],f) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} 66 {} 67 #pragma omp target teams map(always, tofrom: c,f[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} 68 {} 69 return; 70 } 71 }; 72 73 struct SB { 74 unsigned A; 75 unsigned B; 76 float Arr[100]; 77 float *Ptr; 78 float *foo() { 79 return &Arr[0]; 80 } 81 }; 82 83 struct SC { 84 unsigned A : 2; 85 unsigned B : 3; 86 unsigned C; 87 unsigned D; 88 float Arr[100]; 89 SB S; 90 SB ArrS[100]; 91 SB *PtrS; 92 SB *&RPtrS; 93 float *Ptr; 94 95 SC(SB *&_RPtrS) : RPtrS(_RPtrS) {} 96 }; 97 98 union SD { 99 unsigned A; 100 float B; 101 }; 102 103 void SAclient(int arg) { 104 SA<int,123> s; 105 s.func(arg); // expected-note {{in instantiation of member function}} 106 double marr[10][10][10]; 107 double marr2[5][10][1]; 108 double mvla[5][arg][10]; 109 double ***mptr; 110 const int n = 0; 111 const int m = 1; 112 double mvla2[5][arg][m+n+10]; 113 114 SB *p; 115 116 SD u; 117 SC r(p),t(p); 118 #pragma omp target teams map(r) 119 {} 120 #pragma omp target teams map(marr[2][0:2][0:2]) // expected-error {{array section does not specify contiguous storage}} 121 {} 122 #pragma omp target teams map(marr[:][0:2][0:2]) // expected-error {{array section does not specify contiguous storage}} 123 {} 124 #pragma omp target teams map(marr[2][3][0:2]) 125 {} 126 #pragma omp target teams map(marr[:][:][:]) 127 {} 128 #pragma omp target teams map(marr[:2][:][:]) 129 {} 130 #pragma omp target teams map(marr[arg:][:][:]) 131 {} 132 #pragma omp target teams map(marr[arg:]) 133 {} 134 #pragma omp target teams map(marr[arg:][:arg][:]) // correct if arg is the size of dimension 2 135 {} 136 #pragma omp target teams map(marr[:arg][:]) 137 {} 138 #pragma omp target teams map(marr[:arg][n:]) 139 {} 140 #pragma omp target teams map(marr[:][:arg][n:]) // correct if arg is the size of dimension 2 141 {} 142 #pragma omp target teams map(marr[:][:m][n:]) // expected-error {{array section does not specify contiguous storage}} 143 {} 144 #pragma omp target teams map(marr[n:m][:arg][n:]) 145 {} 146 #pragma omp target teams map(marr[:2][:1][:]) // expected-error {{array section does not specify contiguous storage}} 147 {} 148 #pragma omp target teams map(marr[:2][1:][:]) // expected-error {{array section does not specify contiguous storage}} 149 {} 150 #pragma omp target teams map(marr[:2][:][:1]) // expected-error {{array section does not specify contiguous storage}} 151 {} 152 #pragma omp target teams map(marr[:2][:][1:]) // expected-error {{array section does not specify contiguous storage}} 153 {} 154 #pragma omp target teams map(marr[:1][:2][:]) 155 {} 156 #pragma omp target teams map(marr[:1][0][:]) 157 {} 158 #pragma omp target teams map(marr[:arg][:2][:]) // correct if arg is 1 159 {} 160 #pragma omp target teams map(marr[:1][3:1][:2]) 161 {} 162 #pragma omp target teams map(marr[:1][3:arg][:2]) // correct if arg is 1 163 {} 164 #pragma omp target teams map(marr[:1][3:2][:2]) // expected-error {{array section does not specify contiguous storage}} 165 {} 166 #pragma omp target teams map(marr[:2][:10][:]) 167 {} 168 #pragma omp target teams map(marr[:2][:][:5+5]) 169 {} 170 #pragma omp target teams map(marr[:2][2+2-4:][0:5+5]) 171 {} 172 173 #pragma omp target teams map(marr[:1][:2][0]) // expected-error {{array section does not specify contiguous storage}} 174 {} 175 #pragma omp target teams map(marr2[:1][:2][0]) 176 {} 177 178 #pragma omp target teams map(mvla[:1][:][0]) // correct if the size of dimension 2 is 1. 179 {} 180 #pragma omp target teams map(mvla[:2][:arg][:]) // correct if arg is the size of dimension 2. 181 {} 182 #pragma omp target teams map(mvla[:1][:2][0]) // expected-error {{array section does not specify contiguous storage}} 183 {} 184 #pragma omp target teams map(mvla[1][2:arg][:]) 185 {} 186 #pragma omp target teams map(mvla[:1][:][:]) 187 {} 188 #pragma omp target teams map(mvla2[:1][:2][:11]) 189 {} 190 #pragma omp target teams map(mvla2[:1][:2][:10]) // expected-error {{array section does not specify contiguous storage}} 191 {} 192 193 #pragma omp target teams map(mptr[:2][2+2-4:1][0:5+5]) // expected-error {{array section does not specify contiguous storage}} 194 {} 195 #pragma omp target teams map(mptr[:1][:2-1][2:4-3]) 196 {} 197 #pragma omp target teams map(mptr[:1][:arg][2:4-3]) // correct if arg is 1. 198 {} 199 #pragma omp target teams map(mptr[:1][:2-1][0:2]) 200 {} 201 #pragma omp target teams map(mptr[:1][:2][0:2]) // expected-error {{array section does not specify contiguous storage}} 202 {} 203 #pragma omp target teams map(mptr[:1][:][0:2]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} 204 {} 205 #pragma omp target teams map(mptr[:2][:1][0:2]) // expected-error {{array section does not specify contiguous storage}} 206 {} 207 208 #pragma omp target teams map(r.ArrS[0].B) 209 {} 210 #pragma omp target teams map(r.ArrS[:1].B) // expected-error {{OpenMP array section is not allowed here}} 211 {} 212 #pragma omp target teams map(r.ArrS[:arg].B) // expected-error {{OpenMP array section is not allowed here}} 213 {} 214 #pragma omp target teams map(r.ArrS[0].Arr[1:23]) 215 {} 216 #pragma omp target teams map(r.ArrS[0].Arr[1:arg]) 217 {} 218 #pragma omp target teams map(r.ArrS[0].Arr[arg:23]) 219 {} 220 #pragma omp target teams map(r.ArrS[0].Error) // expected-error {{no member named 'Error' in 'SB'}} 221 {} 222 #pragma omp target teams map(r.ArrS[0].A, r.ArrS[1].A) // expected-error {{multiple array elements associated with the same variable are not allowed in map clauses of the same construct}} expected-note {{used here}} 223 {} 224 #pragma omp target teams map(r.ArrS[0].A, t.ArrS[1].A) 225 {} 226 #pragma omp target teams map(r.PtrS[0], r.PtrS->B) // expected-error {{same pointer derreferenced in multiple different ways in map clause expressions}} expected-note {{used here}} 227 {} 228 #pragma omp target teams map(r.RPtrS[0], r.RPtrS->B) // expected-error {{same pointer derreferenced in multiple different ways in map clause expressions}} expected-note {{used here}} 229 {} 230 #pragma omp target teams map(r.S.Arr[:12]) 231 {} 232 #pragma omp target teams map(r.S.foo()[:12]) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}} 233 {} 234 #pragma omp target teams map(r.C, r.D) 235 {} 236 #pragma omp target teams map(r.C, r.C) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 237 {} 238 #pragma omp target teams map(r.C) map(r.C) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 239 {} 240 #pragma omp target teams map(r.C, r.S) // this would be an error only caught at runtime - Sema would have to make sure there is not way for the missing data between fields to be mapped somewhere else. 241 {} 242 #pragma omp target teams map(r, r.S) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 243 {} 244 #pragma omp target teams map(r.C, t.C) 245 {} 246 #pragma omp target teams map(r.A) // expected-error {{bit fields cannot be used to specify storage in a 'map' clause}} 247 {} 248 #pragma omp target teams map(r.Arr) 249 {} 250 #pragma omp target teams map(r.Arr[3:5]) 251 {} 252 #pragma omp target teams map(r.Ptr[3:5]) 253 {} 254 #pragma omp target teams map(r.ArrS[3:5].A) // expected-error {{OpenMP array section is not allowed here}} 255 {} 256 #pragma omp target teams map(r.ArrS[3:5].Arr[6:7]) // expected-error {{OpenMP array section is not allowed here}} 257 {} 258 #pragma omp target teams map(r.ArrS[3].Arr[6:7]) 259 {} 260 #pragma omp target teams map(r.S.Arr[4:5]) 261 {} 262 #pragma omp target teams map(r.S.Ptr[4:5]) 263 {} 264 #pragma omp target teams map(r.S.Ptr[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} 265 {} 266 #pragma omp target teams map((p+1)->A) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}} 267 {} 268 #pragma omp target teams map(u.B) // expected-error {{mapped storage cannot be derived from a union}} 269 {} 270 271 #pragma omp target data map(to: r.C) //expected-note {{used here}} 272 { 273 #pragma omp target teams map(r.D) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}} 274 {} 275 } 276 277 #pragma omp target data map(to: t.Ptr) //expected-note {{used here}} 278 { 279 #pragma omp target teams map(t.Ptr[:23]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} 280 {} 281 } 282 283 #pragma omp target data map(to: t.C, t.D) 284 { 285 #pragma omp target data map(to: t.C) 286 { 287 #pragma omp target teams map(t.D) 288 {} 289 } 290 } 291 292 #pragma omp target data map(to: t) 293 { 294 #pragma omp target data map(to: t.C) 295 { 296 #pragma omp target teams map(t.D) 297 {} 298 } 299 } 300 } 301 void foo() { 302 } 303 304 bool foobool(int argc) { 305 return argc; 306 } 307 308 struct S1; // expected-note 2 {{declared here}} 309 extern S1 a; 310 class S2 { 311 mutable int a; 312 public: 313 S2():a(0) { } 314 S2(S2 &s2):a(s2.a) { } 315 static float S2s; // expected-note 4 {{mappable type cannot contain static members}} 316 static const float S2sc; // expected-note 4 {{mappable type cannot contain static members}} 317 }; 318 const float S2::S2sc = 0; 319 const S2 b; 320 const S2 ba[5]; 321 class S3 { 322 int a; 323 public: 324 S3():a(0) { } 325 S3(S3 &s3):a(s3.a) { } 326 }; 327 const S3 c; 328 const S3 ca[5]; 329 extern const int f; 330 class S4 { 331 int a; 332 S4(); 333 S4(const S4 &s4); 334 public: 335 S4(int v):a(v) { } 336 }; 337 class S5 { 338 int a; 339 S5():a(0) {} 340 S5(const S5 &s5):a(s5.a) { } 341 public: 342 S5(int v):a(v) { } 343 }; 344 345 template <class T> 346 struct S6; 347 348 template<> 349 struct S6<int> // expected-note {{mappable type cannot be polymorphic}} 350 { 351 virtual void foo(); 352 }; 353 354 S3 h; 355 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} 356 357 typedef int from; 358 359 template <typename T, int I> // expected-note {{declared here}} 360 T tmain(T argc) { 361 const T d = 5; 362 const T da[5] = { 0 }; 363 S4 e(4); 364 S5 g(5); 365 T i, t[20]; 366 T &j = i; 367 T *k = &j; 368 T x; 369 T y; 370 T to, tofrom, always; 371 const T (&l)[5] = da; 372 #pragma omp target teams map // expected-error {{expected '(' after 'map'}} 373 {} 374 #pragma omp target teams map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} 375 {} 376 #pragma omp target teams map() // expected-error {{expected expression}} 377 {} 378 #pragma omp target teams map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} 379 {} 380 #pragma omp target teams map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}} 381 {} 382 #pragma omp target teams map(to:) // expected-error {{expected expression}} 383 {} 384 #pragma omp target teams map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 385 {} 386 #pragma omp target teams map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} 387 {} 388 #pragma omp target teams map(x) 389 foo(); 390 #pragma omp target teams map(tofrom: t[:I]) 391 foo(); 392 #pragma omp target teams map(T: a) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} expected-error {{incomplete type 'S1' where a complete type is required}} 393 foo(); 394 #pragma omp target teams map(T) // expected-error {{'T' does not refer to a value}} 395 foo(); 396 #pragma omp target teams map(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} 397 foo(); 398 #pragma omp target teams map(S2::S2s) 399 foo(); 400 #pragma omp target teams map(S2::S2sc) 401 foo(); 402 #pragma omp target teams map(x) 403 foo(); 404 #pragma omp target teams map(to: x) 405 foo(); 406 #pragma omp target teams map(to: to) 407 foo(); 408 #pragma omp target teams map(to) 409 foo(); 410 #pragma omp target teams map(to, x) 411 foo(); 412 413 #pragma omp target data map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} 414 #pragma omp target data map(tofrom: argc > 0 ? x : y) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} 415 #pragma omp target data map(argc) 416 #pragma omp target data map(S1) // expected-error {{'S1' does not refer to a value}} 417 #pragma omp target data map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}} 418 #pragma omp target data map(ba) // expected-error 2 {{type 'S2' is not mappable to target}} 419 #pragma omp target data map(ca) 420 #pragma omp target data map(da) 421 #pragma omp target data map(S2::S2s) 422 #pragma omp target data map(S2::S2sc) 423 #pragma omp target data map(e, g) 424 #pragma omp target data map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}} 425 #pragma omp target data map(k) map(k) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} 426 #pragma omp target teams map(k), map(k[:5]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} expected-note 2 {{used here}} 427 foo(); 428 429 #pragma omp target data map(da) 430 #pragma omp target teams map(da[:4]) 431 foo(); 432 433 #pragma omp target data map(k, j, l) // expected-note 2 {{used here}} 434 #pragma omp target data map(k[:4]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} 435 #pragma omp target data map(j) 436 #pragma omp target teams map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} 437 foo(); 438 439 #pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}} 440 #pragma omp target data map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} 441 #pragma omp target data map(j) 442 #pragma omp target teams map(l) 443 foo(); 444 445 #pragma omp target data map(always, tofrom: x) 446 #pragma omp target data map(always: x) // expected-error {{missing map type}} 447 #pragma omp target data map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always'}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} 448 #pragma omp target data map(always, tofrom: always, tofrom, x) 449 #pragma omp target teams map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} 450 foo(); 451 return 0; 452 } 453 454 int main(int argc, char **argv) { 455 const int d = 5; 456 const int da[5] = { 0 }; 457 S4 e(4); 458 S5 g(5); 459 int i; 460 int &j = i; 461 int *k = &j; 462 S6<int> m; 463 int x; 464 int y; 465 int to, tofrom, always; 466 const int (&l)[5] = da; 467 #pragma omp target data map // expected-error {{expected '(' after 'map'}} expected-error {{expected at least one map clause for '#pragma omp target data'}} 468 #pragma omp target data map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} 469 #pragma omp target data map() // expected-error {{expected expression}} 470 #pragma omp target data map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} 471 #pragma omp target data map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}} 472 #pragma omp target data map(to:) // expected-error {{expected expression}} 473 #pragma omp target data map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 474 #pragma omp target data map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} 475 #pragma omp target teams map(x) 476 foo(); 477 478 #pragma omp target teams map(to: x) 479 foo(); 480 #pragma omp target teams map(to: to) 481 foo(); 482 #pragma omp target teams map(to) 483 foo(); 484 #pragma omp target teams map(to, x) 485 foo(); 486 487 #pragma omp target data map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} 488 #pragma omp target data map(tofrom: argc > 0 ? argv[1] : argv[2]) // expected-error {{xpected expression containing only member accesses and/or array sections based on named variables}} 489 #pragma omp target data map(argc) 490 #pragma omp target data map(S1) // expected-error {{'S1' does not refer to a value}} 491 #pragma omp target data map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}} 492 #pragma omp target data map(argv[1]) 493 #pragma omp target data map(ba) // expected-error 2 {{type 'S2' is not mappable to target}} 494 #pragma omp target data map(ca) 495 #pragma omp target data map(da) 496 #pragma omp target data map(S2::S2s) 497 #pragma omp target data map(S2::S2sc) 498 #pragma omp target data map(e, g) 499 #pragma omp target data map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}} 500 #pragma omp target data map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 501 #pragma omp target teams map(k), map(k[:5]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}} 502 foo(); 503 504 #pragma omp target data map(da) 505 #pragma omp target teams map(da[:4]) 506 foo(); 507 508 #pragma omp target data map(k, j, l) // expected-note {{used here}} 509 #pragma omp target data map(k[:4]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} 510 #pragma omp target data map(j) 511 #pragma omp target teams map(l) map(l[:5]) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 512 foo(); 513 514 #pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}} 515 #pragma omp target data map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}} 516 #pragma omp target data map(j) 517 #pragma omp target teams map(l) 518 foo(); 519 520 #pragma omp target data map(always, tofrom: x) 521 #pragma omp target data map(always: x) // expected-error {{missing map type}} 522 #pragma omp target data map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always'}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} 523 #pragma omp target data map(always, tofrom: always, tofrom, x) 524 #pragma omp target teams map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} 525 foo(); 526 527 #pragma omp target teams private(j) map(j) // expected-error {{private variable cannot be in a map clause in '#pragma omp target teams' directive}} expected-note {{defined as private}} 528 {} 529 530 #pragma omp target teams firstprivate(j) map(j) // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target teams' directive}} expected-note {{defined as firstprivate}} 531 {} 532 533 #pragma omp target teams map(m) // expected-error {{type 'S6<int>' is not mappable to target}} 534 {} 535 536 return tmain<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}} 537 } 538 #endif 539