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