[libc][test] Adjust header paths in tests (#119623)
[llvm-project.git] / clang / test / OpenMP / target_has_device_addr_messages.cpp
blob532ace5caf0a0f02e9b0daea61f601da52723c65
1 // RUN: %clang_cc1 -std=c++11 -verify \
2 // RUN: -fopenmp -ferror-limit 200 %s -Wuninitialized
4 // RUN: %clang_cc1 -std=c++11 -verify \
5 // RUN: -fopenmp-simd -ferror-limit 200 %s -Wuninitialized
7 struct ST {
8 int *a;
9 };
10 typedef int arr[10];
11 typedef ST STarr[10];
12 struct SA {
13 const int d = 5;
14 const int da[5] = { 0 };
15 ST e;
16 ST g[10];
17 STarr &rg = g;
18 int i;
19 int &j = i;
20 int *k = &j;
21 int *&z = k;
22 int aa[10];
23 arr &raa = aa;
24 void func(int arg) {
25 #pragma omp target has_device_addr // expected-error {{expected '(' after 'has_device_addr'}}
27 #pragma omp target has_device_addr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
29 #pragma omp target has_device_addr() // expected-error {{expected expression}}
31 #pragma omp target has_device_addr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
33 #pragma omp target has_device_addr(arg // expected-error {{expected ')'}} expected-note {{to match this '('}}
35 #pragma omp target has_device_addr(i) // OK
37 #pragma omp target has_device_addr(j) // OK
39 #pragma omp target has_device_addr(k) // OK
41 #pragma omp target has_device_addr(z) // OK
43 #pragma omp target has_device_addr(aa) // OK
45 #pragma omp target has_device_addr(raa) // OK
47 #pragma omp target has_device_addr(e) // OK
49 #pragma omp target has_device_addr(g) // OK
51 #pragma omp target has_device_addr(rg) // OK
53 #pragma omp target has_device_addr(k,i,j) // OK
55 #pragma omp target has_device_addr(d) // OK
57 #pragma omp target has_device_addr(da) // OK
59 return;
62 struct SB {
63 unsigned A;
64 unsigned B;
65 float Arr[100];
66 float *Ptr;
67 float *foo() {
68 return &Arr[0];
72 struct SC {
73 unsigned A : 2;
74 unsigned B : 3;
75 unsigned C;
76 unsigned D;
77 float Arr[100];
78 SB S;
79 SB ArrS[100];
80 SB *PtrS;
81 SB *&RPtrS;
82 float *Ptr;
84 SC(SB *&_RPtrS) : RPtrS(_RPtrS) {}
87 union SD {
88 unsigned A;
89 float B;
92 struct S1;
93 extern S1 a;
94 class S2 {
95 mutable int a;
96 public:
97 S2():a(0) { }
98 S2(S2 &s2):a(s2.a) { }
99 static float S2s;
100 static const float S2sc;
102 const float S2::S2sc = 0;
103 const S2 b;
104 const S2 ba[5];
105 class S3 {
106 int a;
107 public:
108 S3():a(0) { }
109 S3(S3 &s3):a(s3.a) { }
111 const S3 c;
112 const S3 ca[5];
113 extern const int f;
114 class S4 {
115 int a;
116 S4();
117 S4(const S4 &s4);
118 public:
119 S4(int v):a(v) { }
121 class S5 {
122 int a;
123 S5():a(0) {}
124 S5(const S5 &s5):a(s5.a) { }
125 public:
126 S5(int v):a(v) { }
129 S3 h;
130 #pragma omp threadprivate(h)
132 typedef struct {
133 int a;
134 } S6;
136 template <typename T, int I>
137 T tmain(T argc) {
138 const T d = 5;
139 const T da[5] = { 0 };
140 S4 e(4);
141 S5 g(5);
142 S6 h[10];
143 auto &rh = h;
144 T i;
145 T &j = i;
146 T *k = &j;
147 T *&z = k;
148 T aa[10];
149 auto &raa = aa;
150 S6 *ps;
151 #pragma omp target has_device_addr // expected-error {{expected '(' after 'has_device_addr'}}
153 #pragma omp target has_device_addr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
155 #pragma omp target has_device_addr() // expected-error {{expected expression}}
157 #pragma omp target has_device_addr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
159 #pragma omp target has_device_addr(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
161 #pragma omp target has_device_addr(i) // OK
163 #pragma omp target has_device_addr(j) // OK
165 #pragma omp target has_device_addr(k) // OK
167 #pragma omp target has_device_addr(z) // OK
169 #pragma omp target has_device_addr(aa) // OK
171 #pragma omp target has_device_addr(raa) // OK
173 #pragma omp target has_device_addr(e) // OK
175 #pragma omp target has_device_addr(g) // OK
177 #pragma omp target has_device_addr(h) // OK
179 #pragma omp target has_device_addr(rh) // OK
181 #pragma omp target has_device_addr(k,i,j) // OK
183 #pragma omp target has_device_addr(d) // OK
185 #pragma omp target has_device_addr(da) // OK
187 #pragma omp target map(ps) has_device_addr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
189 #pragma omp target has_device_addr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
191 #pragma omp target map(ps->a) has_device_addr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
193 #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}}
195 #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}}
197 #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}}
199 #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}}
201 #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}}
203 return 0;
206 int main(int argc, char **argv) {
207 const int d = 5;
208 const int da[5] = { 0 };
209 S4 e(4);
210 S5 g(5);
211 S6 h[10];
212 auto &rh = h;
213 int i;
214 int &j = i;
215 int *k = &j;
216 int *&z = k;
217 int aa[10];
218 auto &raa = aa;
219 S6 *ps;
220 #pragma omp target has_device_addr // expected-error {{expected '(' after 'has_device_addr'}}
222 #pragma omp target has_device_addr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
224 #pragma omp target has_device_addr() // expected-error {{expected expression}}
226 #pragma omp target has_device_addr(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
228 #pragma omp target has_device_addr(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
230 #pragma omp target has_device_addr(i) // OK
232 #pragma omp target has_device_addr(j) // OK
234 #pragma omp target has_device_addr(k) // OK
236 #pragma omp target has_device_addr(z) // OK
238 #pragma omp target has_device_addr(aa) // OK
240 #pragma omp target has_device_addr(raa) // OK
242 #pragma omp target has_device_addr(e) // OK
244 #pragma omp target has_device_addr(g) // OK
246 #pragma omp target has_device_addr(h) // OK
248 #pragma omp target has_device_addr(rh) // OK
250 #pragma omp target has_device_addr(k,i,j) // OK
252 #pragma omp target has_device_addr(d) // OK
254 #pragma omp target has_device_addr(da) // OK
256 #pragma omp target map(ps) has_device_addr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
258 #pragma omp target has_device_addr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
260 #pragma omp target map(ps->a) has_device_addr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
262 #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}}
264 #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}}
266 #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}}
268 #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}}
270 #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}}
272 return tmain<int, 3>(argc);