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