1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 200 %s -Wno-openmp-target
3 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 200 %s -Wno-openmp-target
4 // RUN: %clang_cc1 -DCCODE -verify -fopenmp -ferror-limit 200 -x c %s -Wno-openmp-target
9 double marr[10][10][10];
11 #pragma omp target teams map(marr[2][0:2][0:2]) // expected-error {{array section does not specify contiguous storage}}
13 #pragma omp target teams map(marr[:][0:][:])
15 #pragma omp target teams map(marr[:][1:][:]) // expected-error {{array section does not specify contiguous storage}}
17 #pragma omp target teams map(marr[:][n:][:])
21 template <typename T, int I>
24 #pragma omp threadprivate(ss) // expected-note {{defined as threadprivate or thread local}}
32 #pragma omp target teams map(arg,a,d)
34 #pragma omp target teams map(arg[2:2],a,d) // expected-error {{subscripted value is not an array or pointer}}
36 #pragma omp target teams map(arg,a*2) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}}
38 #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}}
40 #pragma omp target teams map(arg,a[:2],d) // expected-error {{subscripted value is not an array or pointer}}
42 #pragma omp target teams map(arg,a,d[:2]) // expected-error {{subscripted value is not an array or pointer}}
45 #pragma omp target teams map(to:ss) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
48 #pragma omp target teams map(to:b,e)
50 #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}}
52 #pragma omp target teams map(to:b[:2],e)
54 #pragma omp target teams map(to:b,e[:])
56 #pragma omp target teams map(b[-1:]) // expected-error {{array section must be a subset of the original array}}
58 #pragma omp target teams map(b[:-1]) // expected-error {{section length is evaluated to a negative value -1}}
61 #pragma omp target teams map(always, tofrom: c,f)
63 #pragma omp target teams map(always, tofrom: c[1:2],f)
65 #pragma omp target teams map(always, tofrom: c,f[1:2])
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}}
69 #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}}
97 SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
105 void SAclient(int arg) {
107 s.func(arg); // expected-note {{in instantiation of member function}}
108 double marr[10][10][10];
109 double marr2[5][10][1];
110 double mvla[5][arg][10];
114 double mvla2[5][arg][m+n+10];
120 #pragma omp target teams map(r)
122 #pragma omp target teams map(marr[2][0:2][0:2]) // expected-error {{array section does not specify contiguous storage}}
124 #pragma omp target teams map(marr[:][0:2][0:2]) // expected-error {{array section does not specify contiguous storage}}
126 #pragma omp target teams map(marr[2][3][0:2])
128 #pragma omp target teams map(marr[:][:][:])
130 #pragma omp target teams map(marr[:2][:][:])
132 #pragma omp target teams map(marr[arg:][:][:])
134 #pragma omp target teams map(marr[arg:])
136 #pragma omp target teams map(marr[arg:][:arg][:]) // correct if arg is the size of dimension 2
138 #pragma omp target teams map(marr[:arg][:])
140 #pragma omp target teams map(marr[:arg][n:])
142 #pragma omp target teams map(marr[:][:arg][n:]) // correct if arg is the size of dimension 2
144 #pragma omp target teams map(marr[:][:m][n:]) // expected-error {{array section does not specify contiguous storage}}
146 #pragma omp target teams map(marr[n:m][:arg][n:])
148 #pragma omp target teams map(marr[:2][:1][:]) // expected-error {{array section does not specify contiguous storage}}
150 #pragma omp target teams map(marr[:2][1:][:]) // expected-error {{array section does not specify contiguous storage}}
152 #pragma omp target teams map(marr[:2][:][:1]) // expected-error {{array section does not specify contiguous storage}}
154 #pragma omp target teams map(marr[:2][:][1:]) // expected-error {{array section does not specify contiguous storage}}
156 #pragma omp target teams map(marr[:1][:2][:])
158 #pragma omp target teams map(marr[:1][0][:])
160 #pragma omp target teams map(marr[:arg][:2][:]) // correct if arg is 1
162 #pragma omp target teams map(marr[:1][3:1][:2])
164 #pragma omp target teams map(marr[:1][3:arg][:2]) // correct if arg is 1
166 #pragma omp target teams map(marr[:1][3:2][:2]) // expected-error {{array section does not specify contiguous storage}}
168 #pragma omp target teams map(marr[:2][:10][:])
170 #pragma omp target teams map(marr[:2][:][:5+5])
172 #pragma omp target teams map(marr[:2][2+2-4:][0:5+5])
175 #pragma omp target teams map(marr[:1][:2][0]) // expected-error {{array section does not specify contiguous storage}}
177 #pragma omp target teams map(marr2[:1][:2][0])
180 #pragma omp target teams map(mvla[:1][:][0]) // correct if the size of dimension 2 is 1.
182 #pragma omp target teams map(mvla[:2][:arg][:]) // correct if arg is the size of dimension 2.
184 #pragma omp target teams map(mvla[:1][:2][0]) // expected-error {{array section does not specify contiguous storage}}
186 #pragma omp target teams map(mvla[1][2:arg][:])
188 #pragma omp target teams map(mvla[:1][:][:])
190 #pragma omp target teams map(mvla2[:1][:2][:11])
192 #pragma omp target teams map(mvla2[:1][:2][:10]) // expected-error {{array section does not specify contiguous storage}}
195 #pragma omp target teams map(mptr[:2][2+2-4:1][0:5+5]) // expected-error {{array section does not specify contiguous storage}}
197 #pragma omp target teams map(mptr[:1][:2-1][2:4-3])
199 #pragma omp target teams map(mptr[:1][:arg][2:4-3]) // correct if arg is 1.
201 #pragma omp target teams map(mptr[:1][:2-1][0:2])
203 #pragma omp target teams map(mptr[:1][:2][0:2]) // expected-error {{array section does not specify contiguous storage}}
205 #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}}
207 #pragma omp target teams map(mptr[:2][:1][0:2]) // expected-error {{array section does not specify contiguous storage}}
210 #pragma omp target teams map(r.ArrS[0].B)
212 #pragma omp target teams map(r.ArrS[:1].B) // expected-error {{OpenMP array section is not allowed here}}
214 #pragma omp target teams map(r.ArrS[:arg].B) // expected-error {{OpenMP array section is not allowed here}}
216 #pragma omp target teams map(r.ArrS[0].Arr[1:23])
218 #pragma omp target teams map(r.ArrS[0].Arr[1:arg])
220 #pragma omp target teams map(r.ArrS[0].Arr[arg:23])
222 #pragma omp target teams map(r.ArrS[0].Error) // expected-error {{no member named 'Error' in 'SB'}}
224 #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}}
226 #pragma omp target teams map(r.ArrS[0].A, t.ArrS[1].A)
228 #pragma omp target teams map(r.PtrS[0], r.PtrS->B) // expected-error {{same pointer dereferenced in multiple different ways in map clause expressions}} expected-note {{used here}}
230 #pragma omp target teams map(r.PtrS, r.PtrS->B) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}}
232 #pragma omp target teams map(r.PtrS->A, r.PtrS->B)
234 #pragma omp target teams map(r.RPtrS[0], r.RPtrS->B) // expected-error {{same pointer dereferenced in multiple different ways in map clause expressions}} expected-note {{used here}}
236 #pragma omp target teams map(r.RPtrS, r.RPtrS->B) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}}
238 #pragma omp target teams map(r.RPtrS->A, r.RPtrS->B)
240 #pragma omp target teams map(r.S.Arr[:12])
242 #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}}
244 #pragma omp target teams map(r.C, r.D)
246 #pragma omp target teams map(r.C, r.C) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
248 #pragma omp target teams map(r.C) map(r.C) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
250 #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.
252 #pragma omp target teams map(r, r.S) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
254 #pragma omp target teams map(r.C, t.C)
256 #pragma omp target teams map(r.A) // expected-error {{bit fields cannot be used to specify storage in a 'map' clause}}
258 #pragma omp target teams map(r.Arr)
260 #pragma omp target teams map(r.Arr[3:5])
262 #pragma omp target teams map(r.Ptr[3:5])
264 #pragma omp target teams map(r.ArrS[3:5].A) // expected-error {{OpenMP array section is not allowed here}}
266 #pragma omp target teams map(r.ArrS[3:5].Arr[6:7]) // expected-error {{OpenMP array section is not allowed here}}
268 #pragma omp target teams map(r.ArrS[3].Arr[6:7])
270 #pragma omp target teams map(r.S.Arr[4:5])
272 #pragma omp target teams map(r.S.Ptr[4:5])
274 #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}}
276 #pragma omp target teams map((p+1)->A) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}}
278 #pragma omp target teams map(u.B) // expected-error {{mapping of union members is not allowed}}
281 #pragma omp target data map(to: r.C) //expected-note {{used here}}
283 #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}}
287 #pragma omp target data map(to: t.Ptr) //expected-note {{used here}}
289 #pragma omp target teams map(t.Ptr[:23]) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
293 #pragma omp target data map(to: t.C, t.D)
295 #pragma omp target data map(to: t.C)
297 #pragma omp target teams map(t.D)
302 #pragma omp target data map(to: t)
304 #pragma omp target data map(to: t.C)
306 #pragma omp target teams map(t.D)
314 bool foobool(int argc) {
318 struct S1; // expected-note 2 {{declared here}}
324 S2(S2 &s2):a(s2.a) { }
326 static const float S2sc;
328 const float S2::S2sc = 0;
335 S3(S3 &s3):a(s3.a) { }
350 S5(const S5 &s5):a(s5.a) { }
365 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
369 template <typename T, int I> // expected-note {{declared here}}
372 const T da[5] = { 0 };
380 T to, tofrom, always;
381 const T (&l)[5] = da;
382 #pragma omp target teams map // expected-error {{expected '(' after 'map'}}
384 #pragma omp target teams map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
386 #pragma omp target teams map() // expected-error {{expected expression}}
388 #pragma omp target teams map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
390 #pragma omp target teams map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
392 #pragma omp target teams map(to:) // expected-error {{expected expression}}
394 #pragma omp target teams map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
396 #pragma omp target teams map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
398 #pragma omp target teams map(x)
400 #pragma omp target teams map(tofrom: t[:I])
402 #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}}
404 #pragma omp target teams map(T) // expected-error {{'T' does not refer to a value}}
406 #pragma omp target teams map(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
408 #pragma omp target teams map(S2::S2s)
410 #pragma omp target teams map(S2::S2sc)
412 #pragma omp target teams map(x)
414 #pragma omp target teams map(to: x)
416 #pragma omp target teams map(to: to)
418 #pragma omp target teams map(to)
420 #pragma omp target teams map(to, x)
423 #pragma omp target data map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
424 #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}}
425 #pragma omp target data map(argc)
426 #pragma omp target data map(S1) // expected-error {{'S1' does not refer to a value}}
427 #pragma omp target data map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
428 #pragma omp target data map(ba)
429 #pragma omp target data map(ca)
430 #pragma omp target data map(da)
431 #pragma omp target data map(S2::S2s)
432 #pragma omp target data map(S2::S2sc)
433 #pragma omp target data map(e, g)
434 #pragma omp target data map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
435 #pragma omp target data map(k) map(k) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
436 #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}}
439 #pragma omp target data map(da)
440 #pragma omp target teams map(da[:4])
443 #pragma omp target data map(k, j, l) // expected-note 2 {{used here}}
444 #pragma omp target data map(k[:4]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
445 #pragma omp target data map(j)
446 #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}}
449 #pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
450 #pragma omp target data map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
451 #pragma omp target data map(j)
452 #pragma omp target teams map(l)
455 #pragma omp target data map(always, tofrom: x)
456 #pragma omp target data map(always: x) // expected-error {{missing map type}}
457 #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'}}
458 #pragma omp target data map(always, tofrom: always, tofrom, x)
459 #pragma omp target teams map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
464 int main(int argc, char **argv) {
466 const int da[5] = { 0 };
475 int to, tofrom, always;
476 const int (&l)[5] = da;
477 #pragma omp target data map // expected-error {{expected '(' after 'map'}} expected-error {{expected at least one 'map' or 'use_device_ptr' clause for '#pragma omp target data'}}
478 #pragma omp target data map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
479 #pragma omp target data map() // expected-error {{expected expression}}
480 #pragma omp target data map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
481 #pragma omp target data map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
482 #pragma omp target data map(to:) // expected-error {{expected expression}}
483 #pragma omp target data map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
484 #pragma omp target data map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
485 #pragma omp target teams map(x)
488 #pragma omp target teams map(to: x)
490 #pragma omp target teams map(to: to)
492 #pragma omp target teams map(to)
494 #pragma omp target teams map(to, x)
497 #pragma omp target data map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
498 #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}}
499 #pragma omp target data map(argc)
500 #pragma omp target data map(S1) // expected-error {{'S1' does not refer to a value}}
501 #pragma omp target data map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
502 #pragma omp target data map(argv[1])
503 #pragma omp target data map(ba)
504 #pragma omp target data map(ca)
505 #pragma omp target data map(da)
506 #pragma omp target data map(S2::S2s)
507 #pragma omp target data map(S2::S2sc)
508 #pragma omp target data map(e, g)
509 #pragma omp target data map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
510 #pragma omp target data map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
511 #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}}
514 #pragma omp target data map(da)
515 #pragma omp target teams map(da[:4])
518 #pragma omp target data map(k, j, l) // expected-note {{used here}}
519 #pragma omp target data map(k[:4]) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
520 #pragma omp target data map(j)
521 #pragma omp target teams map(l) map(l[:5]) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
524 #pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}}
525 #pragma omp target data map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
526 #pragma omp target data map(j)
527 #pragma omp target teams map(l)
530 #pragma omp target data map(always, tofrom: x)
531 #pragma omp target data map(always: x) // expected-error {{missing map type}}
532 #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'}}
533 #pragma omp target data map(always, tofrom: always, tofrom, x)
534 #pragma omp target teams map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
537 #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}}
540 #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}}
543 #pragma omp target teams map(m)
546 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}}