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