1 | // RUN: %clang_cc1 -std=c++11 -verify -fopenmp %s |
2 | |
3 | // RUN: %clang_cc1 -std=c++11 -verify -fopenmp-simd %s |
4 | |
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++) |
25 | ; |
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++) |
28 | ; |
29 | #pragma omp target simd is_device_ptr() // expected-error {{expected expression}} |
30 | for (int ii=0; ii<10; ii++) |
31 | ; |
32 | #pragma omp target simd is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}} |
33 | for (int ii=0; ii<10; ii++) |
34 | ; |
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++) |
37 | ; |
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++) |
40 | ; |
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++) |
43 | ; |
44 | #pragma omp target simd is_device_ptr(k) // OK |
45 | for (int ii=0; ii<10; ii++) |
46 | ; |
47 | #pragma omp target simd is_device_ptr(z) // OK |
48 | for (int ii=0; ii<10; ii++) |
49 | ; |
50 | #pragma omp target simd is_device_ptr(aa) // OK |
51 | for (int ii=0; ii<10; ii++) |
52 | ; |
53 | #pragma omp target simd is_device_ptr(raa) // OK |
54 | for (int ii=0; ii<10; ii++) |
55 | ; |
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++) |
58 | ; |
59 | #pragma omp target simd is_device_ptr(g) // OK |
60 | for (int ii=0; ii<10; ii++) |
61 | ; |
62 | #pragma omp target simd is_device_ptr(rg) // OK |
63 | for (int ii=0; ii<10; ii++) |
64 | ; |
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++) |
67 | ; |
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++) |
70 | ; |
71 | #pragma omp target simd is_device_ptr(da) // OK |
72 | for (int ii=0; ii<10; ii++) |
73 | ; |
74 | return; |
75 | } |
76 | }; |
77 | struct SB { |
78 | unsigned A; |
79 | unsigned B; |
80 | float Arr[100]; |
81 | float *Ptr; |
82 | float *foo() { |
83 | return &Arr[0]; |
84 | } |
85 | }; |
86 | |
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; |
98 | |
99 | SC(SB *&_RPtrS) : RPtrS(_RPtrS) {} |
100 | }; |
101 | |
102 | union SD { |
103 | unsigned A; |
104 | float B; |
105 | }; |
106 | |
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; |
116 | }; |
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) { } |
125 | }; |
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) { } |
135 | }; |
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) { } |
142 | }; |
143 | |
144 | S3 h; |
145 | #pragma omp threadprivate(h) |
146 | |
147 | typedef struct { |
148 | int a; |
149 | } S6; |
150 | |
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++) |
167 | ; |
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++) |
170 | ; |
171 | #pragma omp target simd is_device_ptr() // expected-error {{expected expression}} |
172 | for (int kk=0; kk<20; kk++) |
173 | ; |
174 | #pragma omp target simd is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}} |
175 | for (int kk=0; kk<20; kk++) |
176 | ; |
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++) |
179 | ; |
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++) |
182 | ; |
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++) |
185 | ; |
186 | #pragma omp target simd is_device_ptr(k) // OK |
187 | for (int kk=0; kk<20; kk++) |
188 | ; |
189 | #pragma omp target simd is_device_ptr(z) // OK |
190 | for (int kk=0; kk<20; kk++) |
191 | ; |
192 | #pragma omp target simd is_device_ptr(aa) // OK |
193 | for (int kk=0; kk<20; kk++) |
194 | ; |
195 | #pragma omp target simd is_device_ptr(raa) // OK |
196 | for (int kk=0; kk<20; kk++) |
197 | ; |
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++) |
200 | ; |
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++) |
203 | ; |
204 | #pragma omp target simd is_device_ptr(h) // OK |
205 | for (int kk=0; kk<20; kk++) |
206 | ; |
207 | #pragma omp target simd is_device_ptr(rh) // OK |
208 | for (int kk=0; kk<20; kk++) |
209 | ; |
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++) |
212 | ; |
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++) |
215 | ; |
216 | #pragma omp target simd is_device_ptr(da) // OK |
217 | for (int kk=0; kk<20; kk++) |
218 | ; |
219 | return 0; |
220 | } |
221 | |
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++) |
237 | ; |
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++) |
240 | ; |
241 | #pragma omp target simd is_device_ptr() // expected-error {{expected expression}} |
242 | for (int kk=0; kk<20; kk++) |
243 | ; |
244 | #pragma omp target simd is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}} |
245 | for (int kk=0; kk<20; kk++) |
246 | ; |
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++) |
249 | ; |
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++) |
252 | ; |
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++) |
255 | ; |
256 | #pragma omp target simd is_device_ptr(k) // OK |
257 | for (int kk=0; kk<20; kk++) |
258 | ; |
259 | #pragma omp target simd is_device_ptr(z) // OK |
260 | for (int kk=0; kk<20; kk++) |
261 | ; |
262 | #pragma omp target simd is_device_ptr(aa) // OK |
263 | for (int kk=0; kk<20; kk++) |
264 | ; |
265 | #pragma omp target simd is_device_ptr(raa) // OK |
266 | for (int kk=0; kk<20; kk++) |
267 | ; |
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++) |
270 | ; |
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++) |
273 | ; |
274 | #pragma omp target simd is_device_ptr(h) // OK |
275 | for (int kk=0; kk<20; kk++) |
276 | ; |
277 | #pragma omp target simd is_device_ptr(rh) // OK |
278 | for (int kk=0; kk<20; kk++) |
279 | ; |
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++) |
282 | ; |
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++) |
285 | ; |
286 | #pragma omp target simd is_device_ptr(da) // OK |
287 | for (int kk=0; kk<20; kk++) |
288 | ; |
289 | return tmain<int, 3>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} |
290 | } |
291 | |