Clang Project

clang_source_code/test/OpenMP/target_teams_distribute_simd_is_device_ptr_messages.cpp
1// RUN: %clang_cc1 -std=c++11 -verify -fopenmp %s
2
3// RUN: %clang_cc1 -std=c++11 -verify -fopenmp-simd %s
4struct ST {
5  int *a;
6};
7typedef int arr[10];
8typedef ST STarr[10];
9struct 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;
21  void func(int arg) {
22#pragma omp target teams distribute 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 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 simd is_device_ptr() // expected-error {{expected expression}}
29  for (int i=0; i<100; i++)
30    ;
31#pragma omp target teams distribute 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 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 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 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 simd is_device_ptr(k) // OK
44  for (int i=0; i<100; i++)
45    ;
46#pragma omp target teams distribute simd is_device_ptr(z) // OK
47  for (int i=0; i<100; i++)
48    ;
49#pragma omp target teams distribute simd is_device_ptr(aa) // OK
50  for (int i=0; i<100; i++)
51    ;
52#pragma omp target teams distribute simd is_device_ptr(raa) // OK
53  for (int i=0; i<100; i++)
54    ;
55#pragma omp target teams distribute 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 simd is_device_ptr(g) // OK
59  for (int i=0; i<100; i++)
60    ;
61#pragma omp target teams distribute simd is_device_ptr(rg) // OK
62  for (int i=0; i<100; i++)
63    ;
64#pragma omp target teams distribute 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 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 simd is_device_ptr(da) // OK
71  for (int i=0; i<100; i++)
72    ;
73  return;
74 }
75};
76struct SB {
77  unsigned A;
78  unsigned B;
79  float Arr[100];
80  float *Ptr;
81  float *foo() {
82    return &Arr[0];
83  }
84};
85
86struct 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
98  SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
99};
100
101union SD {
102  unsigned A;
103  float B;
104};
105
106struct S1;
107extern S1 a;
108class S2 {
109  mutable int a;
110public:
111  S2():a(0) { }
112  S2(S2 &s2):a(s2.a) { }
113  static float S2s;
114  static const float S2sc;
115};
116const float S2::S2sc = 0;
117const S2 b;
118const S2 ba[5];
119class S3 {
120  int a;
121public:
122  S3():a(0) { }
123  S3(S3 &s3):a(s3.a) { }
124};
125const S3 c;
126const S3 ca[5];
127extern const int f;
128class S4 {
129  int a;
130  S4();
131  S4(const S4 &s4);
132public:
133  S4(int v):a(v) { }
134};
135class S5 {
136  int a;
137  S5():a(0) {}
138  S5(const S5 &s5):a(s5.a) { }
139public:
140  S5(int v):a(v) { }
141};
142
143S3 h;
144#pragma omp threadprivate(h)
145
146typedef struct {
147  int a;
148} S6;
149
150template <typename T, int I>
151T 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 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 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 simd is_device_ptr() // expected-error {{expected expression}}
172  for (int i=0; i<100; i++)
173    ;
174#pragma omp target teams distribute 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 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 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 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 simd is_device_ptr(k) // OK
187  for (int i=0; i<100; i++)
188    ;
189#pragma omp target teams distribute simd is_device_ptr(z) // OK
190  for (int i=0; i<100; i++)
191    ;
192#pragma omp target teams distribute simd is_device_ptr(aa) // OK
193  for (int i=0; i<100; i++)
194    ;
195#pragma omp target teams distribute simd is_device_ptr(raa) // OK
196  for (int i=0; i<100; i++)
197    ;
198#pragma omp target teams distribute 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 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 simd is_device_ptr(h) // OK
205  for (int i=0; i<100; i++)
206    ;
207#pragma omp target teams distribute simd is_device_ptr(rh) // OK
208  for (int i=0; i<100; i++)
209    ;
210#pragma omp target teams distribute 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 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 simd is_device_ptr(da) // OK
217  for (int i=0; i<100; i++)
218    ;
219#pragma omp target teams distribute 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 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 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 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 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 simd' directive}}
232  for (int i=0; i<100; i++)
233    ;
234#pragma omp target teams distribute 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 simd' directive}} expected-note{{defined as firstprivate}}
235  for (int i=0; i<100; i++)
236    ;
237#pragma omp target teams distribute 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 simd' directive}}
238  for (int i=0; i<100; i++)
239    ;
240#pragma omp target teams distribute 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 simd' directive}} expected-note{{defined as private}}
241  for (int i=0; i<100; i++)
242    ;
243  return 0;
244}
245
246int 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 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 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 simd is_device_ptr() // expected-error {{expected expression}}
267  for (int i=0; i<100; i++)
268    ;
269#pragma omp target teams distribute 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 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 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 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 simd is_device_ptr(k) // OK
282  for (int i=0; i<100; i++)
283    ;
284#pragma omp target teams distribute simd is_device_ptr(z) // OK
285  for (int i=0; i<100; i++)
286    ;
287#pragma omp target teams distribute simd is_device_ptr(aa) // OK
288  for (int i=0; i<100; i++)
289    ;
290#pragma omp target teams distribute simd is_device_ptr(raa) // OK
291  for (int i=0; i<100; i++)
292    ;
293#pragma omp target teams distribute 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 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 simd is_device_ptr(h) // OK
300  for (int i=0; i<100; i++)
301    ;
302#pragma omp target teams distribute simd is_device_ptr(rh) // OK
303  for (int i=0; i<100; i++)
304    ;
305#pragma omp target teams distribute 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 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 simd is_device_ptr(da) // OK
312  for (int i=0; i<100; i++)
313    ;
314#pragma omp target teams distribute 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 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 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 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 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 simd' directive}}
327  for (int i=0; i<100; i++)
328    ;
329#pragma omp target teams distribute 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 simd' directive}} expected-note{{defined as firstprivate}}
330  for (int i=0; i<100; i++)
331    ;
332#pragma omp target teams distribute 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 simd' directive}}
333  for (int i=0; i<100; i++)
334    ;
335#pragma omp target teams distribute 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 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