[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / target_parallel_for_is_device_ptr_messages.cpp
blobdb3aa32edfbff0a37aad56f12aced009343d3085
1 // RUN: %clang_cc1 -std=c++11 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -std=c++11 -verify -fopenmp-simd %s -Wuninitialized
5 struct ST {
6 int *a;
7 };
8 typedef int arr[10];
9 typedef ST STarr[10];
10 typedef struct {
11 int a;
12 } S;
13 struct SA {
14 const int d = 5;
15 const int da[5] = { 0 };
16 ST e;
17 ST g[10];
18 STarr &rg = g;
19 int i;
20 int &j = i;
21 int *k = &j;
22 int *&z = k;
23 int aa[10];
24 arr &raa = aa;
25 S *ps;
26 void func(int arg) {
27 #pragma omp target parallel for is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
28 for (int ii=0; ii<10; ii++)
30 #pragma omp target parallel for is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
31 for (int ii=0; ii<10; ii++)
33 #pragma omp target parallel for is_device_ptr() // expected-error {{expected expression}}
34 for (int ii=0; ii<10; ii++)
36 #pragma omp target parallel for is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
37 for (int ii=0; ii<10; ii++)
39 #pragma omp target parallel for 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'}}
40 for (int ii=0; ii<10; ii++)
42 #pragma omp target parallel for is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
43 for (int ii=0; ii<10; ii++)
45 #pragma omp target parallel for is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
46 for (int ii=0; ii<10; ii++)
48 #pragma omp target parallel for is_device_ptr(k) // OK
49 for (int ii=0; ii<10; ii++)
51 #pragma omp target parallel for is_device_ptr(z) // OK
52 for (int ii=0; ii<10; ii++)
54 #pragma omp target parallel for is_device_ptr(aa) // OK
55 for (int ii=0; ii<10; ii++)
57 #pragma omp target parallel for is_device_ptr(raa) // OK
58 for (int ii=0; ii<10; ii++)
60 #pragma omp target parallel for is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
61 for (int ii=0; ii<10; ii++)
63 #pragma omp target parallel for is_device_ptr(g) // OK
64 for (int ii=0; ii<10; ii++)
66 #pragma omp target parallel for is_device_ptr(rg) // OK
67 for (int ii=0; ii<10; ii++)
69 #pragma omp target parallel for is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
70 for (int ii=0; ii<10; ii++)
72 #pragma omp target parallel for is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
73 for (int ii=0; ii<10; ii++)
75 #pragma omp target parallel for is_device_ptr(da) // OK
76 for (int ii=0; ii<10; ii++)
78 #pragma omp target parallel for map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
79 for (int ii=0; ii<10; ii++)
81 #pragma omp target parallel for is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
82 for (int ii=0; ii<10; ii++)
84 #pragma omp target parallel for map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
85 for (int ii=0; ii<10; ii++)
87 #pragma omp target parallel for is_device_ptr(ps) map(ps->a) // expected-error{{pointer cannot be mapped along with a section derived from itself}} expected-note{{used here}}
88 for (int ii=0; ii<10; ii++)
90 #pragma omp target parallel for firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target parallel for' directive}} expected-note{{defined as firstprivate}}
91 for (int ii=0; ii<10; ii++)
93 #pragma omp target parallel for private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target parallel for' directive}} expected-note{{defined as private}}
94 for (int ii=0; ii<10; ii++)
97 return;
100 struct SB {
101 unsigned A;
102 unsigned B;
103 float Arr[100];
104 float *Ptr;
105 float *foo() {
106 return &Arr[0];
110 struct SC {
111 unsigned A : 2;
112 unsigned B : 3;
113 unsigned C;
114 unsigned D;
115 float Arr[100];
116 SB S;
117 SB ArrS[100];
118 SB *PtrS;
119 SB *&RPtrS;
120 float *Ptr;
122 SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
125 union SD {
126 unsigned A;
127 float B;
130 struct S1;
131 extern S1 a;
132 class S2 {
133 mutable int a;
134 public:
135 S2():a(0) { }
136 S2(S2 &s2):a(s2.a) { }
137 static float S2s;
138 static const float S2sc;
140 const float S2::S2sc = 0;
141 const S2 b;
142 const S2 ba[5];
143 class S3 {
144 int a;
145 public:
146 S3():a(0) { }
147 S3(S3 &s3):a(s3.a) { }
149 const S3 c;
150 const S3 ca[5];
151 extern const int f;
152 class S4 {
153 int a;
154 S4();
155 S4(const S4 &s4);
156 public:
157 S4(int v):a(v) { }
159 class S5 {
160 int a;
161 S5():a(0) {}
162 S5(const S5 &s5):a(s5.a) { }
163 public:
164 S5(int v):a(v) { }
167 S3 h;
168 #pragma omp threadprivate(h)
170 typedef struct {
171 int a;
172 } S6;
174 template <typename T, int I>
175 T tmain(T argc) {
176 const T d = 5;
177 const T da[5] = { 0 };
178 S4 e(4);
179 S5 g(5);
180 S6 h[10];
181 auto &rh = h;
182 T i;
183 T &j = i;
184 T *k = &j;
185 T *&z = k;
186 T aa[10];
187 auto &raa = aa;
188 #pragma omp target parallel for is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
189 for (int kk=0; kk<20; kk++)
191 #pragma omp target parallel for is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
192 for (int kk=0; kk<20; kk++)
194 #pragma omp target parallel for is_device_ptr() // expected-error {{expected expression}}
195 for (int kk=0; kk<20; kk++)
197 #pragma omp target parallel for is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
198 for (int kk=0; kk<20; kk++)
200 #pragma omp target parallel for 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'}}
201 for (int kk=0; kk<20; kk++)
203 #pragma omp target parallel for is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
204 for (int kk=0; kk<20; kk++)
206 #pragma omp target parallel for is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
207 for (int kk=0; kk<20; kk++)
209 #pragma omp target parallel for is_device_ptr(k) // OK
210 for (int kk=0; kk<20; kk++)
212 #pragma omp target parallel for is_device_ptr(z) // OK
213 for (int kk=0; kk<20; kk++)
215 #pragma omp target parallel for is_device_ptr(aa) // OK
216 for (int kk=0; kk<20; kk++)
218 #pragma omp target parallel for is_device_ptr(raa) // OK
219 for (int kk=0; kk<20; kk++)
221 #pragma omp target parallel for is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
222 for (int kk=0; kk<20; kk++)
224 #pragma omp target parallel for is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
225 for (int kk=0; kk<20; kk++)
227 #pragma omp target parallel for is_device_ptr(h) // OK
228 for (int kk=0; kk<20; kk++)
230 #pragma omp target parallel for is_device_ptr(rh) // OK
231 for (int kk=0; kk<20; kk++)
233 #pragma omp target parallel for is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
234 for (int kk=0; kk<20; kk++)
236 #pragma omp target parallel for is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
237 for (int kk=0; kk<20; kk++)
239 #pragma omp target parallel for is_device_ptr(da) // OK
240 for (int kk=0; kk<20; kk++)
242 return 0;
245 int main(int argc, char **argv) {
246 const int d = 5;
247 const int da[5] = { 0 };
248 S4 e(4);
249 S5 g(5);
250 S6 h[10];
251 auto &rh = h;
252 int i;
253 int &j = i;
254 int *k = &j;
255 int *&z = k;
256 int aa[10];
257 auto &raa = aa;
258 #pragma omp target parallel for is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
259 for (int kk=0; kk<20; kk++)
261 #pragma omp target parallel for is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
262 for (int kk=0; kk<20; kk++)
264 #pragma omp target parallel for is_device_ptr() // expected-error {{expected expression}}
265 for (int kk=0; kk<20; kk++)
267 #pragma omp target parallel for is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
268 for (int kk=0; kk<20; kk++)
270 #pragma omp target parallel for 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'}}
271 for (int kk=0; kk<20; kk++)
273 #pragma omp target parallel for is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
274 for (int kk=0; kk<20; kk++)
276 #pragma omp target parallel for is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
277 for (int kk=0; kk<20; kk++)
279 #pragma omp target parallel for is_device_ptr(k) // OK
280 for (int kk=0; kk<20; kk++)
282 #pragma omp target parallel for is_device_ptr(z) // OK
283 for (int kk=0; kk<20; kk++)
285 #pragma omp target parallel for is_device_ptr(aa) // OK
286 for (int kk=0; kk<20; kk++)
288 #pragma omp target parallel for is_device_ptr(raa) // OK
289 for (int kk=0; kk<20; kk++)
291 #pragma omp target parallel for is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
292 for (int kk=0; kk<20; kk++)
294 #pragma omp target parallel for is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
295 for (int kk=0; kk<20; kk++)
297 #pragma omp target parallel for is_device_ptr(h) // OK
298 for (int kk=0; kk<20; kk++)
300 #pragma omp target parallel for is_device_ptr(rh) // OK
301 for (int kk=0; kk<20; kk++)
303 #pragma omp target parallel for is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
304 for (int kk=0; kk<20; kk++)
306 #pragma omp target parallel for is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
307 for (int kk=0; kk<20; kk++)
309 #pragma omp target parallel for is_device_ptr(da) // OK
310 for (int kk=0; kk<20; kk++)
312 return tmain<int, 3>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}}