]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/OpenMP/target_teams_is_device_ptr_messages.cpp
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / OpenMP / target_teams_is_device_ptr_messages.cpp
1 // RUN: %clang_cc1 -std=c++11 -verify -fopenmp -ferror-limit 200 %s
2 struct ST {
3   int *a;
4 };
5 typedef int arr[10];
6 typedef ST STarr[10];
7 struct SA {
8   const int d = 5;
9   const int da[5] = { 0 };
10   ST e;
11   ST g[10];
12   STarr &rg = g;
13   int i;
14   int &j = i;
15   int *k = &j;
16   int *&z = k;
17   int aa[10];
18   arr &raa = aa;
19   void func(int arg) {
20 #pragma omp target teams is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
21     {}
22 #pragma omp target teams is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
23     {}
24 #pragma omp target teams is_device_ptr() // expected-error {{expected expression}}
25     {}
26 #pragma omp target teams is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
27     {}
28 #pragma omp target teams is_device_ptr(arg // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
29     {}
30 #pragma omp target teams is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
31     {}
32 #pragma omp target teams is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
33     {}
34 #pragma omp target teams is_device_ptr(k) // OK
35     {}
36 #pragma omp target teams is_device_ptr(z) // OK
37     {}
38 #pragma omp target teams is_device_ptr(aa) // OK
39     {}
40 #pragma omp target teams is_device_ptr(raa) // OK
41     {}    
42 #pragma omp target teams is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
43     {}
44 #pragma omp target teams is_device_ptr(g) // OK
45     {}
46 #pragma omp target teams is_device_ptr(rg) // OK
47     {}
48 #pragma omp target teams is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
49     {}
50 #pragma omp target teams is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
51     {}
52 #pragma omp target teams is_device_ptr(da) // OK
53     {}
54   return;
55  }
56 };
57 struct SB {
58   unsigned A;
59   unsigned B;
60   float Arr[100];
61   float *Ptr;
62   float *foo() {
63     return &Arr[0];
64   }
65 };
66
67 struct SC {
68   unsigned A : 2;
69   unsigned B : 3;
70   unsigned C;
71   unsigned D;
72   float Arr[100];
73   SB S;
74   SB ArrS[100];
75   SB *PtrS;
76   SB *&RPtrS;
77   float *Ptr;
78
79   SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
80 };
81
82 union SD {
83   unsigned A;
84   float B;
85 };
86
87 struct S1;
88 extern S1 a;
89 class S2 {
90   mutable int a;
91 public:
92   S2():a(0) { }
93   S2(S2 &s2):a(s2.a) { }
94   static float S2s;
95   static const float S2sc;
96 };
97 const float S2::S2sc = 0;
98 const S2 b;
99 const S2 ba[5];
100 class S3 {
101   int a;
102 public:
103   S3():a(0) { }
104   S3(S3 &s3):a(s3.a) { }
105 };
106 const S3 c;
107 const S3 ca[5];
108 extern const int f;
109 class S4 {
110   int a;
111   S4();
112   S4(const S4 &s4);
113 public:
114   S4(int v):a(v) { }
115 };
116 class S5 {
117   int a;
118   S5():a(0) {}
119   S5(const S5 &s5):a(s5.a) { }
120 public:
121   S5(int v):a(v) { }
122 };
123
124 S3 h;
125 #pragma omp threadprivate(h)
126
127 typedef struct {
128   int a;
129 } S6;
130
131 template <typename T, int I>
132 T tmain(T argc) {
133   const T d = 5;
134   const T da[5] = { 0 };
135   S4 e(4);
136   S5 g(5);
137   S6 h[10];
138   auto &rh = h;
139   T i;
140   T &j = i;
141   T *k = &j;
142   T *&z = k;
143   T aa[10];
144   auto &raa = aa;
145   S6 *ps;
146 #pragma omp target teams is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
147   {}
148 #pragma omp target teams is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
149   {}
150 #pragma omp target teams is_device_ptr() // expected-error {{expected expression}}
151   {}
152 #pragma omp target teams is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
153   {}
154 #pragma omp target teams is_device_ptr(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
155   {}
156 #pragma omp target teams is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
157   {}
158 #pragma omp target teams is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
159   {}
160 #pragma omp target teams is_device_ptr(k) // OK
161   {}
162 #pragma omp target teams is_device_ptr(z) // OK
163   {}
164 #pragma omp target teams is_device_ptr(aa) // OK
165   {}
166 #pragma omp target teams is_device_ptr(raa) // OK
167   {}
168 #pragma omp target teams is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
169   {}
170 #pragma omp target teams is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
171   {}
172 #pragma omp target teams is_device_ptr(h) // OK
173   {}
174 #pragma omp target teams is_device_ptr(rh) // OK
175   {}
176 #pragma omp target teams is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
177   {}
178 #pragma omp target teams is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
179   {}
180 #pragma omp target teams is_device_ptr(da) // OK
181   {}
182 #pragma omp target teams map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
183   {}
184 #pragma omp target teams is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
185   {}
186 #pragma omp target teams map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
187   {}
188 #pragma omp target teams is_device_ptr(ps) map(ps->a) // expected-error{{pointer cannot be mapped along with a section derived from itself}} expected-note{{used here}}
189   {}
190 #pragma omp target teams is_device_ptr(ps) firstprivate(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}}
191   {}
192 #pragma omp target teams firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}} expected-note{{defined as firstprivate}}
193   {}
194 #pragma omp target teams is_device_ptr(ps) private(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}}
195   {}
196 #pragma omp target teams private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}} expected-note{{defined as private}}
197   {}
198   return 0;
199 }
200
201 int main(int argc, char **argv) {
202   const int d = 5;
203   const int da[5] = { 0 };
204   S4 e(4);
205   S5 g(5);
206   S6 h[10];
207   auto &rh = h;
208   int i;
209   int &j = i;
210   int *k = &j;
211   int *&z = k;
212   int aa[10];
213   auto &raa = aa;
214   S6 *ps;
215 #pragma omp target teams is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
216   {}
217 #pragma omp target teams is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
218   {}
219 #pragma omp target teams is_device_ptr() // expected-error {{expected expression}}
220   {}
221 #pragma omp target teams is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
222   {}
223 #pragma omp target teams is_device_ptr(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
224   {}
225 #pragma omp target teams is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
226   {}
227 #pragma omp target teams is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
228   {}
229 #pragma omp target teams is_device_ptr(k) // OK
230   {}
231 #pragma omp target teams is_device_ptr(z) // OK
232   {}
233 #pragma omp target teams is_device_ptr(aa) // OK
234   {}
235 #pragma omp target teams is_device_ptr(raa) // OK
236   {}
237 #pragma omp target teams is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
238   {}
239 #pragma omp target teams is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
240   {}
241 #pragma omp target teams is_device_ptr(h) // OK
242   {}
243 #pragma omp target teams is_device_ptr(rh) // OK
244   {}
245 #pragma omp target teams is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
246   {}
247 #pragma omp target teams is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
248   {}
249 #pragma omp target teams is_device_ptr(da) // OK
250   {}
251 #pragma omp target teams map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
252   {}
253 #pragma omp target teams is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
254   {}
255 #pragma omp target teams map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
256   {}
257 #pragma omp target teams is_device_ptr(ps) map(ps->a) // expected-error{{pointer cannot be mapped along with a section derived from itself}} expected-note{{used here}}
258   {}
259 #pragma omp target teams is_device_ptr(ps) firstprivate(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}}
260   {}
261 #pragma omp target teams firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}} expected-note{{defined as firstprivate}}
262   {}
263 #pragma omp target teams is_device_ptr(ps) private(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}}
264   {}
265 #pragma omp target teams private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}} expected-note{{defined as private}}
266   {}
267   return tmain<int, 3>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}}
268 }