Clang Project

clang_source_code/test/OpenMP/target_teams_is_device_ptr_messages.cpp
1// RUN: %clang_cc1 -std=c++11 -verify -fopenmp -ferror-limit 200 %s
2
3// RUN: %clang_cc1 -std=c++11 -verify -fopenmp-simd -ferror-limit 200 %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 is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
23    {}
24#pragma omp target teams is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
25    {}
26#pragma omp target teams is_device_ptr() // expected-error {{expected expression}}
27    {}
28#pragma omp target teams is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
29    {}
30#pragma omp target teams 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 teams 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 teams 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 teams is_device_ptr(k) // OK
37    {}
38#pragma omp target teams is_device_ptr(z) // OK
39    {}
40#pragma omp target teams is_device_ptr(aa) // OK
41    {}
42#pragma omp target teams is_device_ptr(raa) // OK
43    {}    
44#pragma omp target teams 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 teams is_device_ptr(g) // OK
47    {}
48#pragma omp target teams is_device_ptr(rg) // OK
49    {}
50#pragma omp target teams 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 teams 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 teams is_device_ptr(da) // OK
55    {}
56  return;
57 }
58};
59struct SB {
60  unsigned A;
61  unsigned B;
62  float Arr[100];
63  float *Ptr;
64  float *foo() {
65    return &Arr[0];
66  }
67};
68
69struct 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
81  SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
82};
83
84union SD {
85  unsigned A;
86  float B;
87};
88
89struct S1;
90extern S1 a;
91class S2 {
92  mutable int a;
93public:
94  S2():a(0) { }
95  S2(S2 &s2):a(s2.a) { }
96  static float S2s;
97  static const float S2sc;
98};
99const float S2::S2sc = 0;
100const S2 b;
101const S2 ba[5];
102class S3 {
103  int a;
104public:
105  S3():a(0) { }
106  S3(S3 &s3):a(s3.a) { }
107};
108const S3 c;
109const S3 ca[5];
110extern const int f;
111class S4 {
112  int a;
113  S4();
114  S4(const S4 &s4);
115public:
116  S4(int v):a(v) { }
117};
118class S5 {
119  int a;
120  S5():a(0) {}
121  S5(const S5 &s5):a(s5.a) { }
122public:
123  S5(int v):a(v) { }
124};
125
126S3 h;
127#pragma omp threadprivate(h)
128
129typedef struct {
130  int a;
131} S6;
132
133template <typename T, int I>
134T 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 teams is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
149  {}
150#pragma omp target teams is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
151  {}
152#pragma omp target teams is_device_ptr() // expected-error {{expected expression}}
153  {}
154#pragma omp target teams is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
155  {}
156#pragma omp target teams 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 teams 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 teams 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 teams is_device_ptr(k) // OK
163  {}
164#pragma omp target teams is_device_ptr(z) // OK
165  {}
166#pragma omp target teams is_device_ptr(aa) // OK
167  {}
168#pragma omp target teams is_device_ptr(raa) // OK
169  {}
170#pragma omp target teams 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 teams 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 teams is_device_ptr(h) // OK
175  {}
176#pragma omp target teams is_device_ptr(rh) // OK
177  {}
178#pragma omp target teams 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 teams 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 teams is_device_ptr(da) // OK
183  {}
184#pragma omp target teams 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 teams 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 teams 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 teams 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 teams is_device_ptr(ps) firstprivate(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}}
193  {}
194#pragma omp target teams firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}} expected-note{{defined as firstprivate}}
195  {}
196#pragma omp target teams is_device_ptr(ps) private(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}}
197  {}
198#pragma omp target teams private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}} expected-note{{defined as private}}
199  {}
200  return 0;
201}
202
203int 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 teams is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
218  {}
219#pragma omp target teams is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
220  {}
221#pragma omp target teams is_device_ptr() // expected-error {{expected expression}}
222  {}
223#pragma omp target teams is_device_ptr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
224  {}
225#pragma omp target teams 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 teams 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 teams 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 teams is_device_ptr(k) // OK
232  {}
233#pragma omp target teams is_device_ptr(z) // OK
234  {}
235#pragma omp target teams is_device_ptr(aa) // OK
236  {}
237#pragma omp target teams is_device_ptr(raa) // OK
238  {}
239#pragma omp target teams 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 teams 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 teams is_device_ptr(h) // OK
244  {}
245#pragma omp target teams is_device_ptr(rh) // OK
246  {}
247#pragma omp target teams 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 teams 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 teams is_device_ptr(da) // OK
252  {}
253#pragma omp target teams 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 teams 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 teams 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 teams 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 teams is_device_ptr(ps) firstprivate(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}}
262  {}
263#pragma omp target teams firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}} expected-note{{defined as firstprivate}}
264  {}
265#pragma omp target teams is_device_ptr(ps) private(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams' directive}}
266  {}
267#pragma omp target teams private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target teams' 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