1 // RUN: %clang_cc1 -std=c++11 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -std=c++11 -verify=expected,omp4 -fopenmp -fopenmp-version=45 %s -Wuninitialized
3
4 // RUN: %clang_cc1 -std=c++11 -verify -fopenmp-simd %s -Wuninitialized
5 // RUN: %clang_cc1 -std=c++11 -verify=expected,omp4 -fopenmp-simd -fopenmp-version=45 %s -Wuninitialized
6 struct ST {
7 int *a;
8 };
9 typedef int arr[10];
10 typedef ST STarr[10];
11 struct SA {
12 const int d = 5;
13 const int da[5] = { 0 };
14 ST e;
15 ST g[10];
16 STarr &rg = g;
17 int i;
18 int &j = i;
19 int *k = &j;
20 int *&z = k;
21 int aa[10];
22 arr &raa = aa;
funcSA23 void func(int arg) {
24 #pragma omp target teams distribute parallel for is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
25 for (int i=0; i<100; i++)
26 ;
27 #pragma omp target teams distribute parallel for is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
28 for (int i=0; i<100; i++)
29 ;
30 #pragma omp target teams distribute parallel for is_device_ptr() // expected-error {{expected expression}}
31 for (int i=0; i<100; i++)
32 ;
33 #pragma omp target teams distribute parallel for is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
34 for (int i=0; i<100; i++)
35 ;
36 #pragma omp target teams distribute 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'}}
37 for (int i=0; i<100; i++)
38 ;
39 #pragma omp target teams distribute parallel for is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
40 for (int i=0; i<100; i++)
41 ;
42 #pragma omp target teams distribute parallel for is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
43 for (int i=0; i<100; i++)
44 ;
45 #pragma omp target teams distribute parallel for is_device_ptr(k) // OK
46 for (int i=0; i<100; i++)
47 ;
48 #pragma omp target teams distribute parallel for is_device_ptr(z) // OK
49 for (int i=0; i<100; i++)
50 ;
51 #pragma omp target teams distribute parallel for is_device_ptr(aa) // OK
52 for (int i=0; i<100; i++)
53 ;
54 #pragma omp target teams distribute parallel for is_device_ptr(raa) // OK
55 for (int i=0; i<100; i++)
56 ;
57 #pragma omp target teams distribute parallel for is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
58 for (int i=0; i<100; i++)
59 ;
60 #pragma omp target teams distribute parallel for is_device_ptr(g) // OK
61 for (int i=0; i<100; i++)
62 ;
63 #pragma omp target teams distribute parallel for is_device_ptr(rg) // OK
64 for (int i=0; i<100; i++)
65 ;
66 #pragma omp target teams distribute 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'}}
67 for (int i=0; i<100; i++)
68 ;
69 #pragma omp target teams distribute parallel for is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
70 for (int i=0; i<100; i++)
71 ;
72 #pragma omp target teams distribute parallel for is_device_ptr(da) // OK
73 for (int i=0; i<100; i++)
74 ;
75 return;
76 }
77 };
78 struct SB {
79 unsigned A;
80 unsigned B;
81 float Arr[100];
82 float *Ptr;
fooSB83 float *foo() {
84 return &Arr[0];
85 }
86 };
87
88 struct SC {
89 unsigned A : 2;
90 unsigned B : 3;
91 unsigned C;
92 unsigned D;
93 float Arr[100];
94 SB S;
95 SB ArrS[100];
96 SB *PtrS;
97 SB *&RPtrS;
98 float *Ptr;
99
SCSC100 SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
101 };
102
103 union SD {
104 unsigned A;
105 float B;
106 };
107
108 struct S1;
109 extern S1 a;
110 class S2 {
111 mutable int a;
112 public:
S2()113 S2():a(0) { }
S2(S2 & s2)114 S2(S2 &s2):a(s2.a) { }
115 static float S2s;
116 static const float S2sc;
117 };
118 const float S2::S2sc = 0;
119 const S2 b;
120 const S2 ba[5];
121 class S3 {
122 int a;
123 public:
S3()124 S3():a(0) { }
S3(S3 & s3)125 S3(S3 &s3):a(s3.a) { }
126 };
127 const S3 c;
128 const S3 ca[5];
129 extern const int f;
130 class S4 {
131 int a;
132 S4();
133 S4(const S4 &s4);
134 public:
S4(int v)135 S4(int v):a(v) { }
136 };
137 class S5 {
138 int a;
S5()139 S5():a(0) {}
S5(const S5 & s5)140 S5(const S5 &s5):a(s5.a) { }
141 public:
S5(int v)142 S5(int v):a(v) { }
143 };
144
145 S3 h;
146 #pragma omp threadprivate(h)
147
148 typedef struct {
149 int a;
150 } S6;
151
152 template <typename T, int I>
153 T tmain(T argc) {
154 const T d = 5;
155 const T da[5] = { 0 };
156 S4 e(4);
157 S5 g(5);
158 S6 h[10];
159 auto &rh = h;
160 T i;
161 T &j = i;
162 T *k = &j;
163 T *&z = k;
164 T aa[10];
165 auto &raa = aa;
166 S6 *ps;
167 #pragma omp target teams distribute parallel for is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
168 for (int i=0; i<100; i++)
169 ;
170 #pragma omp target teams distribute parallel for is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
171 for (int i=0; i<100; i++)
172 ;
173 #pragma omp target teams distribute parallel for is_device_ptr() // expected-error {{expected expression}}
174 for (int i=0; i<100; i++)
175 ;
176 #pragma omp target teams distribute parallel for is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
177 for (int i=0; i<100; i++)
178 ;
179 #pragma omp target teams distribute 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'}}
180 for (int i=0; i<100; i++)
181 ;
182 #pragma omp target teams distribute parallel for is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
183 for (int i=0; i<100; i++)
184 ;
185 #pragma omp target teams distribute parallel for is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
186 for (int i=0; i<100; i++)
187 ;
188 #pragma omp target teams distribute parallel for is_device_ptr(k) // OK
189 for (int i=0; i<100; i++)
190 ;
191 #pragma omp target teams distribute parallel for is_device_ptr(z) // OK
192 for (int i=0; i<100; i++)
193 ;
194 #pragma omp target teams distribute parallel for is_device_ptr(aa) // OK
195 for (int i=0; i<100; i++)
196 ;
197 #pragma omp target teams distribute parallel for is_device_ptr(raa) // OK
198 for (int i=0; i<100; i++)
199 ;
200 #pragma omp target teams distribute parallel for is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
201 for (int i=0; i<100; i++)
202 ;
203 #pragma omp target teams distribute parallel for is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
204 for (int i=0; i<100; i++)
205 ;
206 #pragma omp target teams distribute parallel for is_device_ptr(h) // OK
207 for (int i=0; i<100; i++)
208 ;
209 #pragma omp target teams distribute parallel for is_device_ptr(rh) // OK
210 for (int i=0; i<100; i++)
211 ;
212 #pragma omp target teams distribute 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'}}
213 for (int i=0; i<100; i++)
214 ;
215 #pragma omp target teams distribute parallel for is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
216 for (int i=0; i<100; i++)
217 ;
218 #pragma omp target teams distribute parallel for is_device_ptr(da) // OK
219 for (int i=0; i<100; i++)
220 ;
221 #pragma omp target teams distribute parallel for map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
222 for (int i=0; i<100; i++)
223 ;
224 #pragma omp target teams distribute parallel for is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
225 for (int i=0; i<100; i++)
226 ;
227 #pragma omp target teams distribute parallel for map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
228 for (int i=0; i<100; i++)
229 ;
230 #pragma omp target teams distribute 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}}
231 for (int i=0; i<100; i++)
232 ;
233 #pragma omp target teams distribute parallel for is_device_ptr(ps) firstprivate(ps) // omp4-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for' directive}}
234 for (int i=0; i<100; i++)
235 ;
236 #pragma omp target teams distribute parallel for firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for' directive}} expected-note{{defined as firstprivate}}
237 for (int i=0; i<100; i++)
238 ;
239 #pragma omp target teams distribute parallel for is_device_ptr(ps) private(ps) // omp4-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for' directive}}
240 for (int i=0; i<100; i++)
241 ;
242 #pragma omp target teams distribute parallel for private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for' directive}} expected-note{{defined as private}}
243 for (int i=0; i<100; i++)
244 ;
245 return 0;
246 }
247
main(int argc,char ** argv)248 int main(int argc, char **argv) {
249 const int d = 5;
250 const int da[5] = { 0 };
251 S4 e(4);
252 S5 g(5);
253 S6 h[10];
254 auto &rh = h;
255 int i;
256 int &j = i;
257 int *k = &j;
258 int *&z = k;
259 int aa[10];
260 auto &raa = aa;
261 S6 *ps;
262 #pragma omp target teams distribute parallel for is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
263 for (int i=0; i<100; i++)
264 ;
265 #pragma omp target teams distribute parallel for is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
266 for (int i=0; i<100; i++)
267 ;
268 #pragma omp target teams distribute parallel for is_device_ptr() // expected-error {{expected expression}}
269 for (int i=0; i<100; i++)
270 ;
271 #pragma omp target teams distribute parallel for is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
272 for (int i=0; i<100; i++)
273 ;
274 #pragma omp target teams distribute 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'}}
275 for (int i=0; i<100; i++)
276 ;
277 #pragma omp target teams distribute parallel for is_device_ptr(i) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
278 for (int i=0; i<100; i++)
279 ;
280 #pragma omp target teams distribute parallel for is_device_ptr(j) // expected-error {{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
281 for (int i=0; i<100; i++)
282 ;
283 #pragma omp target teams distribute parallel for is_device_ptr(k) // OK
284 for (int i=0; i<100; i++)
285 ;
286 #pragma omp target teams distribute parallel for is_device_ptr(z) // OK
287 for (int i=0; i<100; i++)
288 ;
289 #pragma omp target teams distribute parallel for is_device_ptr(aa) // OK
290 for (int i=0; i<100; i++)
291 ;
292 #pragma omp target teams distribute parallel for is_device_ptr(raa) // OK
293 for (int i=0; i<100; i++)
294 ;
295 #pragma omp target teams distribute parallel for is_device_ptr(e) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
296 for (int i=0; i<100; i++)
297 ;
298 #pragma omp target teams distribute parallel for is_device_ptr(g) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
299 for (int i=0; i<100; i++)
300 ;
301 #pragma omp target teams distribute parallel for is_device_ptr(h) // OK
302 for (int i=0; i<100; i++)
303 ;
304 #pragma omp target teams distribute parallel for is_device_ptr(rh) // OK
305 for (int i=0; i<100; i++)
306 ;
307 #pragma omp target teams distribute 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'}}
308 for (int i=0; i<100; i++)
309 ;
310 #pragma omp target teams distribute parallel for is_device_ptr(d) // expected-error{{expected pointer, array, reference to pointer, or reference to array in 'is_device_ptr clause'}}
311 for (int i=0; i<100; i++)
312 ;
313 #pragma omp target teams distribute parallel for is_device_ptr(da) // OK
314 for (int i=0; i<100; i++)
315 ;
316 #pragma omp target teams distribute parallel for map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
317 for (int i=0; i<100; i++)
318 ;
319 #pragma omp target teams distribute parallel for is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
320 for (int i=0; i<100; i++)
321 ;
322 #pragma omp target teams distribute parallel for map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
323 for (int i=0; i<100; i++)
324 ;
325 #pragma omp target teams distribute 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}}
326 for (int i=0; i<100; i++)
327 ;
328 #pragma omp target teams distribute parallel for is_device_ptr(ps) firstprivate(ps) // omp4-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for' directive}}
329 for (int i=0; i<100; i++)
330 ;
331 #pragma omp target teams distribute parallel for firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for' directive}} expected-note{{defined as firstprivate}}
332 for (int i=0; i<100; i++)
333 ;
334 #pragma omp target teams distribute parallel for is_device_ptr(ps) private(ps) // omp4-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for' directive}}
335 for (int i=0; i<100; i++)
336 ;
337 #pragma omp target teams distribute parallel for private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams distribute parallel for' directive}} expected-note{{defined as private}}
338 for (int i=0; i<100; i++)
339 ;
340 return tmain<int, 3>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}}
341 }
342