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