[libc][test] Adjust header paths in tests (#119623)
[llvm-project.git] / clang / test / OpenMP / target_parallel_map_messages.cpp
blobfa0ee01265b64af9e073084360c1e718826c4887
1 // RUN: %clang_cc1 -verify=expected,lt50,lt51 -fopenmp -fno-openmp-extensions -fopenmp-version=45 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,ge50,lt51 -fopenmp -fno-openmp-extensions -fopenmp-version=50 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
3 // RUN: %clang_cc1 -verify=expected,ge50,ge51 -fopenmp -fno-openmp-extensions -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
4 // RUN: %clang_cc1 -verify=expected,ge50,lt51,omp52 -fopenmp -fno-openmp-extensions -fopenmp-version=52 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
6 // RUN: %clang_cc1 -verify=expected,lt50,lt51 -fopenmp-simd -fno-openmp-extensions -fopenmp-version=45 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
7 // RUN: %clang_cc1 -verify=expected,ge50,lt51 -fopenmp-simd -fno-openmp-extensions -fopenmp-version=50 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
8 // RUN: %clang_cc1 -verify=expected,ge50,ge51 -fopenmp-simd -fno-openmp-extensions -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
9 // RUN: %clang_cc1 -verify=expected,ge50,lt51,omp52 -fopenmp-simd -fno-openmp-extensions -fopenmp-version=52 -ferror-limit 100 %s -Wno-openmp-mapping -Wuninitialized
11 void foo() {
14 bool foobool(int argc) {
15 return argc;
18 void xxx(int argc) {
19 int map; // expected-note {{initialize the variable 'map' to silence this warning}}
20 #pragma omp target parallel map(tofrom: map) // expected-warning {{variable 'map' is uninitialized when used here}}
21 for (int i = 0; i < 10; ++i)
25 struct S1; // expected-note 2 {{declared here}} // expected-note 3 {{forward declaration of 'S1'}}
26 extern S1 a;
27 class S2 {
28 mutable int a;
29 public:
30 S2():a(0) { }
31 S2(S2 &s2):a(s2.a) { }
32 static float S2s;
33 static const float S2sc;
35 const float S2::S2sc = 0;
36 const S2 b;
37 const S2 ba[5];
38 class S3 {
39 int a;
40 public:
41 S3():a(0) { }
42 S3(S3 &s3):a(s3.a) { }
44 const S3 c;
45 const S3 ca[5];
46 extern const int f;
47 class S4 {
48 int a;
49 S4();
50 S4(const S4 &s4);
51 public:
52 S4(int v):a(v) { }
54 class S5 {
55 int a;
56 S5():a(0) {}
57 S5(const S5 &s5):a(s5.a) { }
58 public:
59 S5(int v):a(v) { }
62 S3 h;
63 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
65 typedef int from;
67 template <typename T, int I> // expected-note {{declared here}}
68 T tmain(T argc) {
69 const T d = 5;
70 const T da[5] = { 0 };
71 S4 e(4);
72 S5 g(5);
73 T i, t[20];
74 T &j = i;
75 T *k = &j;
76 T x;
77 T y, z;
78 T to, tofrom, always;
79 const T (&l)[5] = da;
82 #pragma omp target parallel map // expected-error {{expected '(' after 'map'}}
83 foo();
84 #pragma omp target parallel map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
85 foo();
86 #pragma omp target parallel map() // expected-error {{expected expression}}
87 foo();
88 #pragma omp target parallel map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
89 foo();
90 #pragma omp target parallel map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
91 foo();
92 #pragma omp target parallel map(to:) // expected-error {{expected expression}}
93 foo();
94 #pragma omp target parallel map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
95 foo();
96 #pragma omp target parallel map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
97 foo();
98 #pragma omp target parallel map(l[-1:]) // expected-error 2 {{array section must be a subset of the original array}}
99 foo();
100 #pragma omp target parallel map(l[:-1]) // expected-error 2 {{section length is evaluated to a negative value -1}}
101 foo();
102 #pragma omp target parallel map(l[true:true])
103 foo();
104 #pragma omp target parallel map(x, z)
105 foo();
106 #pragma omp target parallel map(tofrom: t[:I])
107 foo();
108 #pragma omp target parallel map(T: a) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} expected-error {{incomplete type 'S1' where a complete type is required}}
109 foo();
110 #pragma omp target parallel map(T) // expected-error {{'T' does not refer to a value}}
111 foo();
112 // ge50-error@+2 2 {{expected addressable lvalue in 'map' clause}}
113 // lt50-error@+1 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
114 #pragma omp target parallel map(I)
115 foo();
116 #pragma omp target parallel map(S2::S2s)
117 foo();
118 #pragma omp target parallel map(S2::S2sc)
119 foo();
120 #pragma omp target parallel map(x)
121 foo();
122 #pragma omp target parallel map(to: x)
123 foo();
124 #pragma omp target parallel map(to: to)
125 foo();
126 #pragma omp target parallel map(to)
127 foo();
128 #pragma omp target parallel map(to, x)
129 foo();
130 #pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
131 foo();
132 // ge50-error@+3 2 {{expected addressable lvalue in 'map' clause}}
133 // lt50-error@+2 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
134 #pragma omp target parallel map(tofrom \
135 : argc > 0 ? x : y)
136 foo();
137 #pragma omp target parallel map(argc)
138 foo();
139 #pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}}
140 foo();
141 #pragma omp target parallel map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
142 foo();
143 #pragma omp target parallel map(ba)
144 foo();
145 #pragma omp target parallel map(ca)
146 foo();
147 #pragma omp target parallel map(da)
148 foo();
149 #pragma omp target parallel map(S2::S2s)
150 foo();
151 #pragma omp target parallel map(S2::S2sc)
152 foo();
153 #pragma omp target parallel map(e, g)
154 foo();
155 #pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
156 foo();
157 #pragma omp target parallel map(k), map(k) // lt50-error 2 {{variable already marked as mapped in current construct}} lt50-note 2 {{used here}}
158 foo();
159 #pragma omp target parallel map(k), map(k[:5]) // lt50-error 2 {{pointer cannot be mapped along with a section derived from itself}} lt50-note 2 {{used here}}
160 foo();
161 #pragma omp target parallel map(da)
162 foo();
163 #pragma omp target parallel map(da[:4])
164 foo();
165 #pragma omp target data map(k, j, l) // lt50-note 2 {{used here}}
166 #pragma omp target parallel map(k[:4]) // lt50-error 2 {{pointer cannot be mapped along with a section derived from itself}}
167 foo();
168 #pragma omp target parallel map(j)
169 foo();
170 #pragma omp target parallel map(l) map(l[:5]) // lt50-error 2 {{variable already marked as mapped in current construct}} lt50-note 2 {{used here}}
171 foo();
172 #pragma omp target data map(k[:4], j, l[:5]) // lt50-note 2 {{used here}}
174 #pragma omp target parallel map(k) // lt50-error 2 {{pointer cannot be mapped along with a section derived from itself}}
175 foo();
176 #pragma omp target parallel map(j)
177 foo();
178 #pragma omp target parallel map(l)
179 foo();
182 #pragma omp target parallel map(always, tofrom: x)
183 foo();
184 #pragma omp target parallel map(always: x) // expected-error {{missing map type}}
185 foo();
186 // ge51-error@+3 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present'}}
187 // lt51-error@+2 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper'}}
188 // expected-error@+1 {{missing map type}}
189 #pragma omp target parallel map(tofrom, always: x)
190 foo();
191 #pragma omp target parallel map(always, tofrom: always, tofrom, x)
192 foo();
193 #pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
194 foo();
196 return 0;
199 int main(int argc, char **argv) {
200 const int d = 5;
201 const int da[5] = { 0 };
202 S4 e(4);
203 S5 g(5);
204 int i;
205 int &j = i;
206 int *k = &j;
207 int x;
208 int y;
209 int to, tofrom, always;
210 const int (&l)[5] = da;
211 #pragma omp target parallel map // expected-error {{expected '(' after 'map'}}
212 foo();
213 #pragma omp target parallel map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
214 foo();
215 #pragma omp target parallel map() // expected-error {{expected expression}}
216 foo();
217 #pragma omp target parallel map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
218 foo();
219 #pragma omp target parallel map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
220 foo();
221 #pragma omp target parallel map(to:) // expected-error {{expected expression}}
222 foo();
223 #pragma omp target parallel map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
224 foo();
225 #pragma omp target parallel map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
226 foo();
227 #pragma omp target parallel map(l[-1:]) // expected-error {{array section must be a subset of the original array}}
228 foo();
229 #pragma omp target parallel map(l[:-1]) // expected-error {{section length is evaluated to a negative value -1}}
230 foo();
231 #pragma omp target parallel map(l[true:true])
232 foo();
233 #pragma omp target parallel map(x)
234 foo();
235 #pragma omp target parallel map(to: x)
236 foo();
237 #pragma omp target parallel map(to: to)
238 foo();
239 #pragma omp target parallel map(to)
240 foo();
241 #pragma omp target parallel map(to, x)
242 foo();
243 #pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
244 foo();
245 // ge50-error@+3 {{expected addressable lvalue in 'map' clause}}
246 // lt50-error@+2 {{expected expression containing only member accesses and/or array sections based on named variables}}
247 #pragma omp target parallel map(tofrom \
248 : argc > 0 ? argv[1] : argv[2])
249 foo();
250 #pragma omp target parallel map(argc)
251 foo();
252 #pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}}
253 foo();
254 #pragma omp target parallel map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
255 foo();
256 #pragma omp target parallel map(argv[1])
257 foo();
258 #pragma omp target parallel map(ba)
259 foo();
260 #pragma omp target parallel map(ca)
261 foo();
262 #pragma omp target parallel map(da)
263 foo();
264 #pragma omp target parallel map(S2::S2s)
265 foo();
266 #pragma omp target parallel map(S2::S2sc)
267 foo();
268 #pragma omp target parallel map(e, g)
269 foo();
270 #pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
271 foo();
272 #pragma omp target parallel map(k), map(k) // lt50-error {{variable already marked as mapped in current construct}} lt50-note {{used here}}
273 foo();
274 #pragma omp target parallel map(k), map(k[:5]) // lt50-error {{pointer cannot be mapped along with a section derived from itself}} lt50-note {{used here}}
275 foo();
276 #pragma omp target parallel map(da)
277 foo();
278 #pragma omp target parallel map(da[:4])
279 foo();
280 #pragma omp target data map(k, j, l) // lt50-note {{used here}}
281 #pragma omp target parallel map(k[:4]) // lt50-error {{pointer cannot be mapped along with a section derived from itself}}
282 foo();
283 #pragma omp target parallel map(j)
284 foo();
285 #pragma omp target parallel map(l) map(l[:5]) // lt50-error {{variable already marked as mapped in current construct}} lt50-note {{used here}}
286 foo();
287 #pragma omp target data map(k[:4], j, l[:5]) // lt50-note {{used here}}
289 #pragma omp target parallel map(k) // lt50-error {{pointer cannot be mapped along with a section derived from itself}}
290 foo();
291 #pragma omp target parallel map(j)
292 foo();
293 #pragma omp target parallel map(l)
294 foo();
297 #pragma omp target parallel map(always, tofrom: x)
298 foo();
299 #pragma omp target parallel map(always: x) // expected-error {{missing map type}}
300 foo();
301 // ge51-error@+3 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present'}}
302 // lt51-error@+2 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper'}}
303 // expected-error@+1 {{missing map type}}
304 #pragma omp target parallel map(tofrom, always: x)
305 foo();
306 #pragma omp target parallel map(always, tofrom: always, tofrom, x)
307 foo();
308 #pragma omp target parallel map(always tofrom: x) // omp52-error {{missing ',' after map type modifier}}
309 foo();
310 #pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
311 foo();
312 #pragma omp target parallel map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target parallel'}}
313 foo();
314 #pragma omp target parallel map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target parallel'}}
315 foo();
317 return tmain<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}}