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