1 // RUN: %clang_cc1 -verify=expected,le50 -fopenmp -ferror-limit 200 %s -Wno-openmp-target -Wuninitialized 2 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=40 -ferror-limit 200 %s -Wno-openmp-target -Wuninitialized 3 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp -fopenmp-version=45 -ferror-limit 200 %s -Wno-openmp-target -Wuninitialized 4 // RUN: %clang_cc1 -verify=expected,le50 -fopenmp -fopenmp-version=50 -ferror-limit 200 %s -Wno-openmp-target -Wuninitialized 5 // RUN: %clang_cc1 -DCCODE -verify -fopenmp -ferror-limit 200 -x c %s -Wno-openmp -Wuninitialized 6 7 // RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -ferror-limit 200 %s -Wno-openmp-target -Wuninitialized 8 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=40 -ferror-limit 200 %s -Wno-openmp-target -Wuninitialized 9 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 200 %s -Wno-openmp-target -Wuninitialized 10 // RUN: %clang_cc1 -verify=expected,le50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 200 %s -Wno-openmp-target -Wuninitialized 11 // RUN: %clang_cc1 -DCCODE -verify -fopenmp-simd -ferror-limit 200 -x c %s -Wno-openmp-mapping -Wuninitialized 12 #ifdef CCODE 13 void foo(int arg) { 14 const int n = 0; 15 16 double marr[10][10][10]; 17 18 #pragma omp target map(marr[2][0:2][0:2]) // expected-error {{array section does not specify contiguous storage}} 19 {} 20 #pragma omp target map(marr[:][0:][:]) 21 {} 22 #pragma omp target map(marr[:][1:][:]) // expected-error {{array section does not specify contiguous storage}} 23 {} 24 #pragma omp target map(marr[:][n:][:]) 25 {} 26 } 27 #else 28 29 void xxx(int argc) { 30 int map; // expected-note {{initialize the variable 'map' to silence this warning}} 31 #pragma omp target map(tofrom: map) // expected-warning {{variable 'map' is uninitialized when used here}} 32 for (int i = 0; i < 10; ++i) 33 ; 34 } 35 36 37 struct SREF { 38 int &a; 39 int b; 40 SREF(int &a) : a(a) {} 41 }; 42 43 template <typename T, int I> 44 struct SA { 45 static int ss; 46 #pragma omp threadprivate(ss) // expected-note {{defined as threadprivate or thread local}} 47 float a; 48 int b[12]; 49 float *c; 50 T d; 51 float e[I]; 52 T *f; 53 int bf : 20; 54 void func(int arg) { 55 SREF sref(arg); 56 #pragma omp target 57 { 58 a = 0.0; 59 func(arg); 60 bf = 20; 61 } 62 #pragma omp target map(arg,a,d,sref.b) 63 {} 64 #pragma omp target map(arg[2:2],a,d) // expected-error {{subscripted value is not an array or pointer}} 65 {} 66 #pragma omp target map(arg,a*2) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le50-error {{expected addressable lvalue in 'map' clause}} 67 {} 68 #pragma omp target map(arg,(c+1)[2]) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} 69 {} 70 #pragma omp target map(arg,a[:2],d) // expected-error {{subscripted value is not an array or pointer}} 71 {} 72 #pragma omp target map(arg,a,d[:2]) // expected-error {{subscripted value is not an array or pointer}} 73 {} 74 75 #pragma omp target map(to:ss) // expected-error {{threadprivate variables are not allowed in 'map' clause}} 76 {} 77 78 #pragma omp target map(to:b,e) 79 {} 80 #pragma omp target map(to:b,e) map(to:b) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 81 {} 82 #pragma omp target map(to:b[:2],e) 83 {} 84 #pragma omp target map(to:b,e[:]) 85 {} 86 #pragma omp target map(b[-1:]) // expected-error {{array section must be a subset of the original array}} 87 {} 88 #pragma omp target map(b[:-1]) // expected-error {{section length is evaluated to a negative value -1}} 89 {} 90 #pragma omp target map(b[true:true]) 91 {} 92 93 #pragma omp target map(: c,f) // expected-error {{missing map type}} 94 {} 95 #pragma omp target map(always, tofrom: c,f) 96 {} 97 #pragma omp target map(always, tofrom: c[1:2],f) 98 {} 99 #pragma omp target map(always, tofrom: c,f[1:2]) 100 {} 101 #pragma omp target map(always, tofrom: c[:],f) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} 102 {} 103 #pragma omp target map(always, tofrom: c,f[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} 104 {} 105 #pragma omp target map(always) // expected-error {{use of undeclared identifier 'always'}} 106 {} 107 #pragma omp target map(close, tofrom: c,f) 108 {} 109 #pragma omp target map(close, tofrom: c[1:2],f) 110 {} 111 #pragma omp target map(close, tofrom: c,f[1:2]) 112 {} 113 #pragma omp target map(close, tofrom: c[:],f) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} 114 {} 115 #pragma omp target map(close, tofrom: c,f[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} 116 {} 117 #pragma omp target map(close) // expected-error {{use of undeclared identifier 'close'}} 118 {} 119 #pragma omp target map(close, close, tofrom: a) // expected-error {{same map type modifier has been specified more than once}} 120 {} 121 #pragma omp target map(always, close, always, close, tofrom: a) // expected-error {{same map type modifier has been specified more than once}} expected-error {{same map type modifier has been specified more than once}} 122 {} 123 #pragma omp target map( , tofrom: a) // expected-error {{missing map type modifier}} 124 {} 125 #pragma omp target map( , , tofrom: a) // expected-error {{missing map type modifier}} expected-error {{missing map type modifier}} 126 {} 127 #pragma omp target map( , , : a) // expected-error {{missing map type modifier}} expected-error {{missing map type modifier}} expected-error {{missing map type}} 128 {} 129 #pragma omp target map( d, f, bf: a) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} 130 {} 131 #pragma omp target map( , f, : a) // expected-error {{missing map type modifier}} expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}} 132 {} 133 #pragma omp target map(always close: a) // expected-error {{missing map type}} 134 {} 135 #pragma omp target map(always close bf: a) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} 136 {} 137 #pragma omp target map(always tofrom close: a) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}} 138 {} 139 #pragma omp target map(tofrom from: a) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} 140 {} 141 #pragma omp target map(close bf: a) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} 142 {} 143 #pragma omp target map(([b[I]][bf])f) // le45-error {{expected ',' or ']' in lambda capture list}} le45-error {{expected ')'}} le45-note {{to match this '('}} 144 {} 145 return; 146 } 147 }; 148 149 struct SB { 150 unsigned A; 151 unsigned B; 152 float Arr[100]; 153 float *Ptr; 154 float *foo() { 155 return &Arr[0]; 156 } 157 }; 158 159 struct SC { 160 unsigned A : 2; 161 unsigned B : 3; 162 unsigned C; 163 unsigned D; 164 float Arr[100]; 165 SB S; 166 SB ArrS[100]; 167 SB *PtrS; 168 SB *&RPtrS; 169 float *Ptr; 170 171 SC(SB *&_RPtrS) : RPtrS(_RPtrS) {} 172 }; 173 174 union SD { 175 unsigned A; 176 float B; 177 }; 178 179 void SAclient(int arg) { 180 SA<int,123> s; 181 s.func(arg); // expected-note {{in instantiation of member function}} 182 double marr[10][10][10]; 183 double marr2[5][10][1]; 184 double mvla[5][arg][10]; 185 double ***mptr; 186 const int n = 0; 187 const int m = 1; 188 double mvla2[5][arg][m+n+10]; 189 190 SB *p; 191 192 SD u; 193 SC r(p),t(p); 194 #pragma omp target map(r) 195 {} 196 #pragma omp target map(marr[2] [0:2] [0:2]) // expected-error {{array section does not specify contiguous storage}} 197 {} 198 #pragma omp target map(marr[:] [0:2] [0:2]) // expected-error {{array section does not specify contiguous storage}} 199 {} 200 #pragma omp target map(marr[2][3] [0:2]) 201 {} 202 #pragma omp target map(marr[:][:][:]) 203 {} 204 #pragma omp target map(marr[:2][:][:]) 205 {} 206 #pragma omp target map(marr [arg:][:][:]) 207 {} 208 #pragma omp target map(marr [arg:]) 209 {} 210 #pragma omp target map(marr [arg:][:arg][:]) // correct if arg is the size of dimension 2 211 {} 212 #pragma omp target map(marr[:arg][:]) 213 {} 214 #pragma omp target map(marr[:arg] [n:]) 215 {} 216 #pragma omp target map(marr[:][:arg] [n:]) // correct if arg is the size of dimension 2 217 {} 218 #pragma omp target map(marr[:][:m] [n:]) // expected-error {{array section does not specify contiguous storage}} 219 {} 220 #pragma omp target map(marr [n:m][:arg] [n:]) 221 {} 222 #pragma omp target map(marr[:2][:1][:]) // expected-error {{array section does not specify contiguous storage}} 223 {} 224 #pragma omp target map(marr[:2] [1:][:]) // expected-error {{array section does not specify contiguous storage}} 225 {} 226 #pragma omp target map(marr[:2][:][:1]) // expected-error {{array section does not specify contiguous storage}} 227 {} 228 #pragma omp target map(marr[:2][:] [1:]) // expected-error {{array section does not specify contiguous storage}} 229 {} 230 #pragma omp target map(marr[:1][:2][:]) 231 {} 232 #pragma omp target map(marr[:1][0][:]) 233 {} 234 #pragma omp target map(marr[:arg][:2][:]) // correct if arg is 1 235 {} 236 #pragma omp target map(marr[:1] [3:1][:2]) 237 {} 238 #pragma omp target map(marr[:1] [3:arg][:2]) // correct if arg is 1 239 {} 240 #pragma omp target map(marr[:1] [3:2][:2]) // expected-error {{array section does not specify contiguous storage}} 241 {} 242 #pragma omp target map(marr[:2][:10][:]) 243 {} 244 #pragma omp target map(marr[:2][:][:5 + 5]) 245 {} 246 #pragma omp target map(marr[:2] [2 + 2 - 4:] [0:5 + 5]) 247 {} 248 249 #pragma omp target map(marr[:1][:2][0]) // expected-error {{array section does not specify contiguous storage}} 250 {} 251 #pragma omp target map(marr2[:1][:2][0]) 252 {} 253 254 #pragma omp target map(mvla[:1][:][0]) // correct if the size of dimension 2 is 1. 255 {} 256 #pragma omp target map(mvla[:2][:arg][:]) // correct if arg is the size of dimension 2. 257 {} 258 #pragma omp target map(mvla[:1][:2][0]) // expected-error {{array section does not specify contiguous storage}} 259 {} 260 #pragma omp target map(mvla[1] [2:arg][:]) 261 {} 262 #pragma omp target map(mvla[:1][:][:]) 263 {} 264 #pragma omp target map(mvla2[:1][:2][:11]) 265 {} 266 #pragma omp target map(mvla2[:1][:2][:10]) // expected-error {{array section does not specify contiguous storage}} 267 {} 268 269 #pragma omp target map(mptr[:2] [2 + 2 - 4:1] [0:5 + 5]) // expected-error {{array section does not specify contiguous storage}} 270 {} 271 #pragma omp target map(mptr[:1][:2 - 1] [2:4 - 3]) 272 {} 273 #pragma omp target map(mptr[:1][:arg] [2:4 - 3]) // correct if arg is 1. 274 {} 275 #pragma omp target map(mptr[:1][:2 - 1] [0:2]) 276 {} 277 #pragma omp target map(mptr[:1][:2] [0:2]) // expected-error {{array section does not specify contiguous storage}} 278 {} 279 #pragma omp target map(mptr[:1][:] [0:2]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} 280 {} 281 #pragma omp target map(mptr[:2][:1] [0:2]) // expected-error {{array section does not specify contiguous storage}} 282 {} 283 284 #pragma omp target map(r.ArrS[0].B) 285 {} 286 #pragma omp target map(r.ArrS[:1].B) // expected-error {{OpenMP array section is not allowed here}} 287 {} 288 #pragma omp target map(r.ArrS[:arg].B) // expected-error {{OpenMP array section is not allowed here}} 289 {} 290 #pragma omp target map(r.ArrS[0].Arr [1:23]) 291 {} 292 #pragma omp target map(r.ArrS[0].Arr [1:arg]) 293 {} 294 #pragma omp target map(r.ArrS[0].Arr [arg:23]) 295 {} 296 #pragma omp target map(r.ArrS[0].Error) // expected-error {{no member named 'Error' in 'SB'}} 297 {} 298 #pragma omp target 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}} 299 {} 300 #pragma omp target map(r.ArrS[0].A, t.ArrS[1].A) 301 {} 302 #pragma omp target map(r.PtrS[0], r.PtrS->B) // expected-error {{same pointer dereferenced in multiple different ways in map clause expressions}} expected-note {{used here}} 303 {} 304 #pragma omp target map(r.PtrS, r.PtrS->B) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}} 305 {} 306 #pragma omp target map(r.PtrS->A, r.PtrS->B) 307 {} 308 #pragma omp target map(r.RPtrS[0], r.RPtrS->B) // expected-error {{same pointer dereferenced in multiple different ways in map clause expressions}} expected-note {{used here}} 309 {} 310 #pragma omp target map(r.RPtrS, r.RPtrS->B) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}} 311 {} 312 #pragma omp target map(r.RPtrS->A, r.RPtrS->B) 313 {} 314 #pragma omp target map(r.S.Arr[:12]) 315 {} 316 #pragma omp target map(r.S.foo() [:12]) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le50-error {{expected addressable lvalue in 'map' clause}} 317 {} 318 #pragma omp target map(r.C, r.D) 319 {} 320 #pragma omp target map(r.C, r.C) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 321 {} 322 #pragma omp target map(r.C) map(r.C) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 323 {} 324 #pragma omp target 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. 325 {} 326 #pragma omp target map(r, r.S) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 327 {} 328 #pragma omp target map(r.C, t.C) 329 {} 330 #pragma omp target map(r.A) // expected-error {{bit fields cannot be used to specify storage in a 'map' clause}} 331 {} 332 #pragma omp target map(r.Arr) 333 {} 334 #pragma omp target map(r.Arr [3:5]) 335 {} 336 #pragma omp target map(r.Ptr [3:5]) 337 {} 338 #pragma omp target map(r.ArrS [3:5].A) // expected-error {{OpenMP array section is not allowed here}} 339 {} 340 #pragma omp target map(r.ArrS [3:5].Arr [6:7]) // expected-error {{OpenMP array section is not allowed here}} 341 {} 342 #pragma omp target map(r.ArrS[3].Arr [6:7]) 343 {} 344 #pragma omp target map(r.S.Arr [4:5]) 345 {} 346 #pragma omp target map(r.S.Ptr [4:5]) 347 {} 348 #pragma omp target map(r.S.Ptr[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} 349 {} 350 #pragma omp target map((p + 1)->A) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} 351 {} 352 #pragma omp target map(u.B) // expected-error {{mapping of union members is not allowed}} 353 {} 354 #pragma omp target 355 { 356 u.B = 0; 357 r.S.foo(); 358 } 359 360 #pragma omp target data map(to \ 361 : r.C) //expected-note {{used here}} 362 { 363 #pragma omp target map(r.D) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}} 364 {} 365 } 366 367 #pragma omp target data map(to \ 368 : t.Ptr) //expected-note {{used here}} 369 { 370 #pragma omp target map(t.Ptr[:23]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} 371 {} 372 } 373 374 #pragma omp target data map(to \ 375 : t.C, t.D) 376 { 377 #pragma omp target data map(to \ 378 : t.C) 379 { 380 #pragma omp target map(t.D) 381 {} 382 } 383 } 384 #pragma omp target data map(marr[:][:][:]) 385 { 386 #pragma omp target data map(marr) 387 {} 388 } 389 390 #pragma omp target data map(to \ 391 : t) 392 { 393 #pragma omp target data map(to \ 394 : t.C) 395 { 396 #pragma omp target map(t.D) 397 {} 398 } 399 } 400 } 401 void foo() { 402 } 403 404 bool foobool(int argc) { 405 return argc; 406 } 407 408 struct S1; // expected-note 2 {{declared here}} 409 extern S1 a; 410 class S2 { 411 mutable int a; 412 public: 413 S2():a(0) { } 414 S2(S2 &s2):a(s2.a) { } 415 static float S2s; 416 static const float S2sc; 417 }; 418 const float S2::S2sc = 0; 419 const S2 b; 420 const S2 ba[5]; 421 class S3 { 422 int a; 423 public: 424 S3():a(0) { } 425 S3(S3 &s3):a(s3.a) { } 426 }; 427 const S3 c; 428 const S3 ca[5]; 429 extern const int f; 430 class S4 { 431 int a; 432 S4(); 433 S4(const S4 &s4); 434 public: 435 S4(int v):a(v) { } 436 }; 437 class S5 { 438 int a; 439 S5():a(0) {} 440 S5(const S5 &s5):a(s5.a) { } 441 public: 442 S5(int v):a(v) { } 443 }; 444 445 template <class T> 446 struct S6; 447 448 template<> 449 struct S6<int> 450 { 451 virtual void foo(); 452 }; 453 454 S3 h; 455 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} 456 457 typedef int from; 458 459 template <typename T, int I> // expected-note {{declared here}} 460 T tmain(T argc) { 461 const T d = 5; 462 const T da[5] = { 0 }; 463 S4 e(4); 464 S5 g(5); 465 T i, t[20]; 466 T &j = i; 467 T *k = &j; 468 T x; 469 T y; 470 T to, tofrom, always, close; 471 const T (&l)[5] = da; 472 #pragma omp target map // expected-error {{expected '(' after 'map'}} 473 {} 474 #pragma omp target map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} 475 {} 476 #pragma omp target map() // expected-error {{expected expression}} 477 {} 478 #pragma omp target map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} 479 {} 480 #pragma omp target map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}} 481 {} 482 #pragma omp target map(to:) // expected-error {{expected expression}} 483 {} 484 #pragma omp target map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 485 {} 486 #pragma omp target map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} 487 {} 488 #pragma omp target map(x) 489 foo(); 490 #pragma omp target map(tofrom: t[:I]) 491 foo(); 492 #pragma omp target 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}} 493 foo(); 494 #pragma omp target map(T) // expected-error {{'T' does not refer to a value}} 495 foo(); 496 #pragma omp target map(I) // le45-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} le50-error 2 {{expected addressable lvalue in 'map' clause}} 497 foo(); 498 #pragma omp target map(S2::S2s) 499 foo(); 500 #pragma omp target map(S2::S2sc) 501 foo(); 502 #pragma omp target map(x) 503 foo(); 504 #pragma omp target map(to: x) 505 foo(); 506 #pragma omp target map(to: to) 507 foo(); 508 #pragma omp target map(to) 509 foo(); 510 #pragma omp target map(to, x) 511 foo(); 512 #pragma omp target data map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} 513 #pragma omp target data map(tofrom: argc > 0 ? x : y) // le45-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} le50-error 2 {{expected addressable lvalue in 'map' clause}} 514 #pragma omp target data map(argc) 515 #pragma omp target data map(S1) // expected-error {{'S1' does not refer to a value}} 516 #pragma omp target data map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} warn-warning 2 {{Type 'const S2' is not trivially copyable and not guaranteed to be mapped correctly}} warn-warning 2 {{Type 'const S3' is not trivially copyable and not guaranteed to be mapped correctly}} 517 #pragma omp target data map(ba) // warn-warning 2 {{Type 'const S2 [5]' is not trivially copyable and not guaranteed to be mapped correctly}} 518 #pragma omp target data map(ca) // warn-warning 2 {{Type 'const S3 [5]' is not trivially copyable and not guaranteed to be mapped correctly}} 519 #pragma omp target data map(da) 520 #pragma omp target data map(S2::S2s) 521 #pragma omp target data map(S2::S2sc) 522 #pragma omp target data map(e, g) // warn-warning 2 {{Type 'S4' is not trivially copyable and not guaranteed to be mapped correctly}} warn-warning 2 {{Type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}} 523 #pragma omp target data map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}} 524 #pragma omp target data map(k) map(k) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} 525 #pragma omp target map(k), map(k[:5]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} expected-note 2 {{used here}} 526 foo(); 527 #pragma omp target data map(da) 528 #pragma omp target map(da[:4]) 529 foo(); 530 #pragma omp target data map(k, j, l) // expected-note 2 {{used here}} 531 #pragma omp target data map(k[:4]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} 532 #pragma omp target data map(j) 533 #pragma omp target map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} 534 foo(); 535 #pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}} 536 #pragma omp target data map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} 537 #pragma omp target data map(j) 538 #pragma omp target map(l) 539 foo(); 540 541 #pragma omp target data map(always, tofrom: x) 542 #pragma omp target data map(always: x) // expected-error {{missing map type}} 543 #pragma omp target data map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}} 544 #pragma omp target data map(always, tofrom: always, tofrom, x) 545 #pragma omp target map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} 546 foo(); 547 548 #pragma omp target data map(close, tofrom: x) 549 #pragma omp target data map(close: x) // expected-error {{missing map type}} 550 #pragma omp target data map(tofrom, close: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}} 551 #pragma omp target data map(close, tofrom: close, tofrom, x) 552 foo(); 553 554 T marr[10][10], iarr[5]; 555 #pragma omp target data map(marr[10][0:2:2]) // expected-error {{expected ']'}} expected-note {{to match this '['}} 556 {} 557 #pragma omp target data map(iarr[:2:d]) // expected-error {{expected ']'}} expected-note {{to match this '['}} 558 {} 559 return 0; 560 } 561 562 struct SA1{ 563 int a; 564 struct SA1 *p; 565 int b[10]; 566 }; 567 struct SB1{ 568 int a; 569 struct SA1 s; 570 struct SA1 sa[10]; 571 struct SA1 *sp[10]; 572 struct SA1 *p; 573 }; 574 struct SC1{ 575 int a; 576 struct SB1 s; 577 struct SB1 *p; 578 int b[10]; 579 }; 580 581 class S8 { 582 public: 583 virtual void foo() = 0; 584 } *s8; 585 586 class S9 { 587 public: 588 virtual void foo() {} 589 } s9; 590 591 592 int main(int argc, char **argv) { 593 const int d = 5; 594 const int da[5] = { 0 }; 595 S4 e(4); 596 S5 g(5); 597 int i; 598 int &j = i; 599 int *k = &j; 600 S6<int> m; 601 int x; 602 int y; 603 int to, tofrom, always, close; 604 const int (&l)[5] = da; 605 SC1 s; 606 SC1 *p; 607 #pragma omp target data map // expected-error {{expected '(' after 'map'}} le45-error {{expected at least one 'map' or 'use_device_ptr' clause for '#pragma omp target data'}} le50-error {{expected at least one 'map', 'use_device_ptr', or 'use_device_addr' clause for '#pragma omp target data'}} 608 #pragma omp target data map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} 609 #pragma omp target data map() // expected-error {{expected expression}} 610 #pragma omp target data map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} 611 #pragma omp target data map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}} 612 #pragma omp target data map(to:) // expected-error {{expected expression}} 613 #pragma omp target data map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 614 #pragma omp target data map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} 615 #pragma omp target map(x) 616 foo(); 617 #pragma omp target map(to: x) 618 foo(); 619 #pragma omp target map(to: to) 620 foo(); 621 #pragma omp target map(to) 622 foo(); 623 #pragma omp target map(to, x) 624 foo(); 625 #pragma omp target data map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} 626 #pragma omp target data map(tofrom: argc > 0 ? argv[1] : argv[2]) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} le50-error {{expected addressable lvalue in 'map' clause}} 627 #pragma omp target data map(argc) 628 #pragma omp target data map(S1) // expected-error {{'S1' does not refer to a value}} 629 #pragma omp target data map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} warn-warning {{Type 'const S2' is not trivially copyable and not guaranteed to be mapped correctly}} warn-warning {{Type 'const S3' is not trivially copyable and not guaranteed to be mapped correctly}} 630 #pragma omp target data map(argv[1]) 631 #pragma omp target data map(ba) // warn-warning {{Type 'const S2 [5]' is not trivially copyable and not guaranteed to be mapped correctly}} 632 #pragma omp target data map(ca) // warn-warning {{Type 'const S3 [5]' is not trivially copyable and not guaranteed to be mapped correctly}} 633 #pragma omp target data map(da) 634 #pragma omp target data map(S2::S2s) 635 #pragma omp target data map(S2::S2sc) 636 #pragma omp target data map(e, g) // warn-warning {{Type 'S4' is not trivially copyable and not guaranteed to be mapped correctly}} warn-warning {{Type 'S5' is not trivially copyable and not guaranteed to be mapped correctly}} 637 #pragma omp target data map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}} 638 #pragma omp target data map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 639 #pragma omp target map(k), map(k[:5]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}} 640 foo(); 641 #pragma omp target data map(da) 642 #pragma omp target map(da[:4]) 643 foo(); 644 #pragma omp target data map(k, j, l) // expected-note {{used here}} 645 #pragma omp target data map(k[:4]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} 646 #pragma omp target data map(j) 647 #pragma omp target map(l) map(l[:5]) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 648 foo(); 649 #pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}} 650 #pragma omp target data map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}} 651 #pragma omp target data map(j) 652 #pragma omp target map(l) 653 foo(); 654 655 #pragma omp target data map(always, tofrom: x) 656 #pragma omp target data map(always: x) // expected-error {{missing map type}} 657 #pragma omp target data map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}} 658 #pragma omp target data map(always, tofrom: always, tofrom, x) 659 #pragma omp target map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} 660 foo(); 661 #pragma omp target data map(close, tofrom: x) 662 #pragma omp target data map(close: x) // expected-error {{missing map type}} 663 #pragma omp target data map(tofrom, close: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}} 664 foo(); 665 #pragma omp target private(j) map(j) // expected-error {{private variable cannot be in a map clause in '#pragma omp target' directive}} expected-note {{defined as private}} 666 {} 667 #pragma omp target firstprivate(j) map(j) // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target' directive}} expected-note {{defined as firstprivate}} 668 {} 669 #pragma omp target map(m) // warn-warning {{Type 'S6<int>' is not trivially copyable and not guaranteed to be mapped correctly}} 670 {} 671 // expected-note@+1 {{used here}} 672 #pragma omp target map(s.s.s) 673 // expected-error@+1 {{variable already marked as mapped in current construct}} 674 { s.a++; } 675 // expected-note@+1 {{used here}} 676 #pragma omp target map(s.s.s.a) 677 // expected-error@+1 {{variable already marked as mapped in current construct}} 678 { s.a++; } 679 // expected-note@+1 {{used here}} 680 #pragma omp target map(s.b[:5]) 681 // expected-error@+1 {{variable already marked as mapped in current construct}} 682 { s.a++; } 683 #pragma omp target map(s.p[:5]) 684 { s.a++; } 685 // expected-note@+1 {{used here}} 686 #pragma omp target map(s.s.sa[3].a) 687 // expected-error@+1 {{variable already marked as mapped in current construct}} 688 { s.a++; } 689 // expected-note@+1 {{used here}} 690 #pragma omp target map(s.s.sp[3]->a) 691 // expected-error@+1 {{variable already marked as mapped in current construct}} 692 { s.a++; } 693 // expected-note@+1 {{used here}} 694 #pragma omp target map(s.p->a) 695 // expected-error@+1 {{variable already marked as mapped in current construct}} 696 { s.a++; } 697 // expected-note@+1 {{used here}} 698 #pragma omp target map(s.s.p->a) 699 // expected-error@+1 {{variable already marked as mapped in current construct}} 700 { s.a++; } 701 // expected-note@+1 {{used here}} 702 #pragma omp target map(s.s.s.b[:2]) 703 // expected-error@+1 {{variable already marked as mapped in current construct}} 704 { s.a++; } 705 // expected-note@+1 {{used here}} 706 #pragma omp target map(s.s.p->b[:2]) 707 // expected-error@+1 {{variable already marked as mapped in current construct}} 708 { s.a++; } 709 // expected-note@+1 {{used here}} 710 #pragma omp target map(s.p->p->p->a) 711 // expected-error@+1 {{variable already marked as mapped in current construct}} 712 { s.a++; } 713 #pragma omp target map(s.s.s.b[:2]) 714 { s.s.s.b[0]++; } 715 #pragma omp target map(s8[0:1], s9) // warn-warning {{Type 'class S8' is not trivially copyable and not guaranteed to be mapped correctly}} warn-warning {{Type 'class S9' is not trivially copyable and not guaranteed to be mapped correctly}} 716 {} 717 718 int **BB, *offset, *a; 719 720 #pragma omp target map(**(BB+*offset)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} 721 {} 722 #pragma omp target map(**(BB+y)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} 723 {} 724 #pragma omp target map(*(a+*offset)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} 725 {} 726 #pragma omp target map(**(*offset+BB)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} 727 {} 728 #pragma omp target map(**(y+BB)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} 729 {} 730 #pragma omp target map(*(*offset+a)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} 731 {} 732 #pragma omp target map(**(*offset+BB+*a)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} 733 {} 734 #pragma omp target map(**(*(*(&offset))+BB+*a)) // le45-error {{expected expression containing only member accesses and/or array sections based on named variables}} 735 {} 736 #pragma omp target map(*(a+(a))) // expected-error {{invalid operands to binary expression ('int *' and 'int *')}} 737 {} 738 #pragma omp target map(*(1+*a+*a)) // expected-error {{indirection requires pointer operand ('int' invalid)}} 739 {} 740 741 #pragma omp target map(delete: a) // expected-error {{map type 'delete' is not allowed for '#pragma omp target'}} 742 {} 743 #pragma omp target map(release: a) // expected-error {{map type 'release' is not allowed for '#pragma omp target'}} 744 {} 745 746 int marr[10][10], iarr[5]; 747 748 #pragma omp target map(marr[10][0:2:2]) // expected-error {{expected ']'}} expected-note {{to match this '['}} 749 {} 750 #pragma omp target map(iarr[:2:d]) // expected-error {{expected ']'}} expected-note {{to match this '['}} 751 {} 752 753 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}} 754 } 755 #endif 756