[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / target_simd_is_device_ptr_messages.cpp
blob1d8c90632fd2018034f4b1e4779ba8d153804dcf
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 struct SA {
11 const int d = 5;
12 const int da[5] = { 0 };
13 ST e;
14 ST g[10];
15 STarr &rg = g;
16 int i;
17 int &j = i;
18 int *k = &j;
19 int *&z = k;
20 int aa[10];
21 arr &raa = aa;
22 void func(int arg) {
23 #pragma omp target simd is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
24 for (int ii=0; ii<10; ii++)
26 #pragma omp target simd is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
27 for (int ii=0; ii<10; ii++)
29 #pragma omp target simd is_device_ptr() // expected-error {{expected expression}}
30 for (int ii=0; ii<10; ii++)
32 #pragma omp target simd is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
33 for (int ii=0; ii<10; ii++)
35 #pragma omp target simd 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'}}
36 for (int ii=0; ii<10; ii++)
38 #pragma omp target simd is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
39 for (int ii=0; ii<10; ii++)
41 #pragma omp target simd is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
42 for (int ii=0; ii<10; ii++)
44 #pragma omp target simd is_device_ptr(k) // OK
45 for (int ii=0; ii<10; ii++)
47 #pragma omp target simd is_device_ptr(z) // OK
48 for (int ii=0; ii<10; ii++)
50 #pragma omp target simd is_device_ptr(aa) // OK
51 for (int ii=0; ii<10; ii++)
53 #pragma omp target simd is_device_ptr(raa) // OK
54 for (int ii=0; ii<10; ii++)
56 #pragma omp target simd is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
57 for (int ii=0; ii<10; ii++)
59 #pragma omp target simd is_device_ptr(g) // OK
60 for (int ii=0; ii<10; ii++)
62 #pragma omp target simd is_device_ptr(rg) // OK
63 for (int ii=0; ii<10; ii++)
65 #pragma omp target simd is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
66 for (int ii=0; ii<10; ii++)
68 #pragma omp target simd is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
69 for (int ii=0; ii<10; ii++)
71 #pragma omp target simd is_device_ptr(da) // OK
72 for (int ii=0; ii<10; ii++)
74 return;
77 struct SB {
78 unsigned A;
79 unsigned B;
80 float Arr[100];
81 float *Ptr;
82 float *foo() {
83 return &Arr[0];
87 struct SC {
88 unsigned A : 2;
89 unsigned B : 3;
90 unsigned C;
91 unsigned D;
92 float Arr[100];
93 SB S;
94 SB ArrS[100];
95 SB *PtrS;
96 SB *&RPtrS;
97 float *Ptr;
99 SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
102 union SD {
103 unsigned A;
104 float B;
107 struct S1;
108 extern S1 a;
109 class S2 {
110 mutable int a;
111 public:
112 S2():a(0) { }
113 S2(S2 &s2):a(s2.a) { }
114 static float S2s;
115 static const float S2sc;
117 const float S2::S2sc = 0;
118 const S2 b;
119 const S2 ba[5];
120 class S3 {
121 int a;
122 public:
123 S3():a(0) { }
124 S3(S3 &s3):a(s3.a) { }
126 const S3 c;
127 const S3 ca[5];
128 extern const int f;
129 class S4 {
130 int a;
131 S4();
132 S4(const S4 &s4);
133 public:
134 S4(int v):a(v) { }
136 class S5 {
137 int a;
138 S5():a(0) {}
139 S5(const S5 &s5):a(s5.a) { }
140 public:
141 S5(int v):a(v) { }
144 S3 h;
145 #pragma omp threadprivate(h)
147 typedef struct {
148 int a;
149 } S6;
151 template <typename T, int I>
152 T tmain(T argc) {
153 const T d = 5;
154 const T da[5] = { 0 };
155 S4 e(4);
156 S5 g(5);
157 S6 h[10];
158 auto &rh = h;
159 T i;
160 T &j = i;
161 T *k = &j;
162 T *&z = k;
163 T aa[10];
164 auto &raa = aa;
165 #pragma omp target simd is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
166 for (int kk=0; kk<20; kk++)
168 #pragma omp target simd is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
169 for (int kk=0; kk<20; kk++)
171 #pragma omp target simd is_device_ptr() // expected-error {{expected expression}}
172 for (int kk=0; kk<20; kk++)
174 #pragma omp target simd is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
175 for (int kk=0; kk<20; kk++)
177 #pragma omp target simd 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'}}
178 for (int kk=0; kk<20; kk++)
180 #pragma omp target simd is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
181 for (int kk=0; kk<20; kk++)
183 #pragma omp target simd is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
184 for (int kk=0; kk<20; kk++)
186 #pragma omp target simd is_device_ptr(k) // OK
187 for (int kk=0; kk<20; kk++)
189 #pragma omp target simd is_device_ptr(z) // OK
190 for (int kk=0; kk<20; kk++)
192 #pragma omp target simd is_device_ptr(aa) // OK
193 for (int kk=0; kk<20; kk++)
195 #pragma omp target simd is_device_ptr(raa) // OK
196 for (int kk=0; kk<20; kk++)
198 #pragma omp target simd is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
199 for (int kk=0; kk<20; kk++)
201 #pragma omp target simd is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
202 for (int kk=0; kk<20; kk++)
204 #pragma omp target simd is_device_ptr(h) // OK
205 for (int kk=0; kk<20; kk++)
207 #pragma omp target simd is_device_ptr(rh) // OK
208 for (int kk=0; kk<20; kk++)
210 #pragma omp target simd is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
211 for (int kk=0; kk<20; kk++)
213 #pragma omp target simd is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
214 for (int kk=0; kk<20; kk++)
216 #pragma omp target simd is_device_ptr(da) // OK
217 for (int kk=0; kk<20; kk++)
219 return 0;
222 int main(int argc, char **argv) {
223 const int d = 5;
224 const int da[5] = { 0 };
225 S4 e(4);
226 S5 g(5);
227 S6 h[10];
228 auto &rh = h;
229 int i;
230 int &j = i;
231 int *k = &j;
232 int *&z = k;
233 int aa[10];
234 auto &raa = aa;
235 #pragma omp target simd is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
236 for (int kk=0; kk<20; kk++)
238 #pragma omp target simd is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
239 for (int kk=0; kk<20; kk++)
241 #pragma omp target simd is_device_ptr() // expected-error {{expected expression}}
242 for (int kk=0; kk<20; kk++)
244 #pragma omp target simd is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
245 for (int kk=0; kk<20; kk++)
247 #pragma omp target simd 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'}}
248 for (int kk=0; kk<20; kk++)
250 #pragma omp target simd is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
251 for (int kk=0; kk<20; kk++)
253 #pragma omp target simd is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
254 for (int kk=0; kk<20; kk++)
256 #pragma omp target simd is_device_ptr(k) // OK
257 for (int kk=0; kk<20; kk++)
259 #pragma omp target simd is_device_ptr(z) // OK
260 for (int kk=0; kk<20; kk++)
262 #pragma omp target simd is_device_ptr(aa) // OK
263 for (int kk=0; kk<20; kk++)
265 #pragma omp target simd is_device_ptr(raa) // OK
266 for (int kk=0; kk<20; kk++)
268 #pragma omp target simd is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
269 for (int kk=0; kk<20; kk++)
271 #pragma omp target simd is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
272 for (int kk=0; kk<20; kk++)
274 #pragma omp target simd is_device_ptr(h) // OK
275 for (int kk=0; kk<20; kk++)
277 #pragma omp target simd is_device_ptr(rh) // OK
278 for (int kk=0; kk<20; kk++)
280 #pragma omp target simd is_device_ptr(k,i,j) // expected-error2 {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
281 for (int kk=0; kk<20; kk++)
283 #pragma omp target simd is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
284 for (int kk=0; kk<20; kk++)
286 #pragma omp target simd is_device_ptr(da) // OK
287 for (int kk=0; kk<20; kk++)
289 return tmain<int, 3>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}}