Debian Codegraph @

clang/test/OpenMP/target_has_device_addr_messages.cpp

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