Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / target_simd_map_messages.cpp
blob4e0f569b1f1c4dde6e1bf5b1c49070176f306476
1 // RUN: %clang_cc1 -verify=expected,lt50,lt51 -fopenmp -fopenmp-version=45 %s -Wno-openmp-mapping -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,ge50,lt51 -fopenmp -fopenmp-version=50 %s -Wno-openmp-mapping -Wuninitialized
3 // RUN: %clang_cc1 -verify=expected,ge50,ge51 -fopenmp %s -Wno-openmp-mapping -Wuninitialized
4 // RUN: %clang_cc1 -verify=expected,ge50,lt51,omp52 -fopenmp -fopenmp-version=52 %s -Wno-openmp-mapping -Wuninitialized
6 // RUN: %clang_cc1 -verify=expected,lt50,lt51 -fopenmp-simd -fopenmp-version=45 %s -Wno-openmp-mapping -Wuninitialized
7 // RUN: %clang_cc1 -verify=expected,ge50,lt51 -fopenmp-simd -fopenmp-version=50 %s -Wno-openmp-mapping -Wuninitialized
8 // RUN: %clang_cc1 -verify=expected,ge50,ge51 -fopenmp-simd %s -Wno-openmp-mapping -Wuninitialized
9 // RUN: %clang_cc1 -verify=expected,ge50,lt51,omp52 -fopenmp-simd -fopenmp-version=52 %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 simd map(to: 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;
78 T to, tofrom, always;
79 const T (&l)[5] = da;
82 #pragma omp target simd map // expected-error {{expected '(' after 'map'}}
83 for (i = 0; i < argc; ++i) foo();
84 #pragma omp target simd map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
85 for (i = 0; i < argc; ++i) foo();
86 #pragma omp target simd map() // expected-error {{expected expression}}
87 for (i = 0; i < argc; ++i) foo();
88 #pragma omp target simd map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
89 for (i = 0; i < argc; ++i) foo();
90 #pragma omp target simd map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
91 for (i = 0; i < argc; ++i) foo();
92 #pragma omp target simd map(to:) // expected-error {{expected expression}}
93 for (i = 0; i < argc; ++i) foo();
94 #pragma omp target simd map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
95 for (i = 0; i < argc; ++i) foo();
96 #pragma omp target simd map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
97 for (i = 0; i < argc; ++i) foo();
98 #pragma omp target simd map(x)
99 for (i = 0; i < argc; ++i) foo();
100 #pragma omp target simd map(tofrom: t[:I])
101 for (i = 0; i < argc; ++i) foo();
102 #pragma omp target simd 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}}
103 for (i = 0; i < argc; ++i) foo();
104 #pragma omp target simd map(T) // expected-error {{'T' does not refer to a value}}
105 for (i = 0; i < argc; ++i) foo();
106 // ge50-error@+2 2 {{expected addressable lvalue in 'map' clause}}
107 // lt50-error@+1 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
108 #pragma omp target simd map(I)
109 for (i = 0; i < argc; ++i) foo();
110 #pragma omp target simd map(S2::S2s)
111 for (i = 0; i < argc; ++i) foo();
112 #pragma omp target simd map(S2::S2sc)
113 for (i = 0; i < argc; ++i) foo();
114 #pragma omp target simd map(x)
115 for (i = 0; i < argc; ++i) foo();
116 #pragma omp target simd map(to: x)
117 for (i = 0; i < argc; ++i) foo();
118 #pragma omp target simd map(to: to)
119 for (i = 0; i < argc; ++i) foo();
120 #pragma omp target simd map(to)
121 for (i = 0; i < argc; ++i) foo();
122 #pragma omp target simd map(to, x)
123 for (i = 0; i < argc; ++i) foo();
124 #pragma omp target simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
125 for (i = 0; i < argc; ++i) foo();
126 // ge50-error@+3 2 {{expected addressable lvalue in 'map' clause}}
127 // lt50-error@+2 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
128 #pragma omp target simd map(tofrom \
129 : argc > 0 ? x : y)
130 for (i = 0; i < argc; ++i) foo();
131 #pragma omp target simd map(argc)
132 for (i = 0; i < argc; ++i) foo();
133 #pragma omp target simd map(S1) // expected-error {{'S1' does not refer to a value}}
134 for (i = 0; i < argc; ++i) foo();
135 #pragma omp target simd map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
136 for (i = 0; i < argc; ++i) foo();
137 #pragma omp target simd map(ba)
138 for (i = 0; i < argc; ++i) foo();
139 #pragma omp target simd map(ca)
140 for (i = 0; i < argc; ++i) foo();
141 #pragma omp target simd map(da)
142 for (i = 0; i < argc; ++i) foo();
143 #pragma omp target simd map(S2::S2s)
144 for (i = 0; i < argc; ++i) foo();
145 #pragma omp target simd map(S2::S2sc)
146 for (i = 0; i < argc; ++i) foo();
147 #pragma omp target simd map(e, g)
148 for (i = 0; i < argc; ++i) foo();
149 #pragma omp target simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
150 for (i = 0; i < argc; ++i) foo();
151 #pragma omp target simd map(k), map(k) // lt50-error 2 {{variable already marked as mapped in current construct}} lt50-note 2 {{used here}}
152 for (i = 0; i < argc; ++i) foo();
153 #pragma omp target simd map(k), map(k[:5]) // lt50-error 2 {{pointer cannot be mapped along with a section derived from itself}} lt50-note 2 {{used here}}
154 for (i = 0; i < argc; ++i) foo();
155 #pragma omp target simd map(da)
156 for (i = 0; i < argc; ++i) foo();
157 #pragma omp target simd map(da[:4])
158 for (i = 0; i < argc; ++i) foo();
159 #pragma omp target data map(k, j, l) // lt50-note 2 {{used here}}
160 #pragma omp target simd map(k[:4]) // lt50-error 2 {{pointer cannot be mapped along with a section derived from itself}}
161 for (i = 0; i < argc; ++i) foo();
162 #pragma omp target simd map(j)
163 for (i = 0; i < argc; ++i) foo();
164 #pragma omp target simd map(l) map(l[:5]) // lt50-error 2 {{variable already marked as mapped in current construct}} lt50-note 2 {{used here}}
165 for (i = 0; i < argc; ++i) foo();
166 #pragma omp target data map(k[:4], j, l[:5]) // lt50-note 2 {{used here}}
168 #pragma omp target simd map(k) // lt50-error 2 {{pointer cannot be mapped along with a section derived from itself}}
169 for (i = 0; i < argc; ++i)
170 foo();
171 #pragma omp target simd map(j)
172 for (i = 0; i < argc; ++i) foo();
173 #pragma omp target simd map(l) // OK
174 for (i = 0; i < argc; ++i) foo();
177 #pragma omp target simd map(always, tofrom: x)
178 for (i = 0; i < argc; ++i) foo();
179 #pragma omp target simd map(always: x) // expected-error {{missing map type}}
180 for (i = 0; i < argc; ++i) foo();
181 // ge51-error@+3 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present'}}
182 // lt51-error@+2 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper'}}
183 // expected-error@+1 {{missing map type}}
184 #pragma omp target simd map(tofrom, always: x)
185 for (i = 0; i < argc; ++i) foo();
186 #pragma omp target simd map(always, tofrom: always, tofrom, x)
187 for (i = 0; i < argc; ++i) foo();
188 #pragma omp target simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
189 for (i = 0; i < argc; ++i) foo();
191 return 0;
194 int main(int argc, char **argv) {
195 const int d = 5;
196 const int da[5] = { 0 };
197 S4 e(4);
198 S5 g(5);
199 int i;
200 int &j = i;
201 int *k = &j;
202 int x;
203 int y;
204 int to, tofrom, always;
205 const int (&l)[5] = da;
207 #pragma omp target simd map // expected-error {{expected '(' after 'map'}}
208 for (i = 0; i < argc; ++i) foo();
209 #pragma omp target simd map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
210 for (i = 0; i < argc; ++i) foo();
211 #pragma omp target simd map() // expected-error {{expected expression}}
212 for (i = 0; i < argc; ++i) foo();
213 #pragma omp target simd map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
214 for (i = 0; i < argc; ++i) foo();
215 #pragma omp target simd map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
216 for (i = 0; i < argc; ++i) foo();
217 #pragma omp target simd map(to:) // expected-error {{expected expression}}
218 for (i = 0; i < argc; ++i) foo();
219 #pragma omp target simd map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
220 for (i = 0; i < argc; ++i) foo();
221 #pragma omp target simd map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
222 for (i = 0; i < argc; ++i) foo();
223 #pragma omp target simd map(x)
224 for (i = 0; i < argc; ++i) foo();
225 #pragma omp target simd map(to: x)
226 for (i = 0; i < argc; ++i) foo();
227 #pragma omp target simd map(to: to)
228 for (i = 0; i < argc; ++i) foo();
229 #pragma omp target simd map(to)
230 for (i = 0; i < argc; ++i) foo();
231 #pragma omp target simd map(to, x)
232 for (i = 0; i < argc; ++i) foo();
233 #pragma omp target simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
234 for (i = 0; i < argc; ++i)
235 foo();
236 // ge50-error@+3 {{expected addressable lvalue in 'map' clause}}
237 // lt50-error@+2 {{expected expression containing only member accesses and/or array sections based on named variables}}
238 #pragma omp target simd map(tofrom \
239 : argc > 0 ? argv[1] : argv[2])
240 for (i = 0; i < argc; ++i) foo();
241 #pragma omp target simd map(argc)
242 for (i = 0; i < argc; ++i) foo();
243 #pragma omp target simd map(S1) // expected-error {{'S1' does not refer to a value}}
244 for (i = 0; i < argc; ++i) foo();
245 #pragma omp target simd map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
246 for (i = 0; i < argc; ++i) foo();
247 #pragma omp target simd map(argv[1])
248 for (i = 0; i < argc; ++i) foo();
249 #pragma omp target simd map(ba)
250 for (i = 0; i < argc; ++i) foo();
251 #pragma omp target simd map(ca)
252 for (i = 0; i < argc; ++i) foo();
253 #pragma omp target simd map(da)
254 for (i = 0; i < argc; ++i) foo();
255 #pragma omp target simd map(S2::S2s)
256 for (i = 0; i < argc; ++i) foo();
257 #pragma omp target simd map(S2::S2sc)
258 for (i = 0; i < argc; ++i) foo();
259 #pragma omp target simd map(e, g)
260 for (i = 0; i < argc; ++i) foo();
261 #pragma omp target simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
262 for (i = 0; i < argc; ++i)
263 foo();
264 #pragma omp target simd map(k), map(k) // lt50-error {{variable already marked as mapped in current construct}} lt50-note {{used here}}
265 for (i = 0; i < argc; ++i)
266 foo();
267 #pragma omp target simd map(k), map(k[:5]) // lt50-error {{pointer cannot be mapped along with a section derived from itself}} lt50-note {{used here}}
268 for (i = 0; i < argc; ++i) foo();
269 #pragma omp target simd map(da)
270 for (i = 0; i < argc; ++i) foo();
271 #pragma omp target simd map(da[:4])
272 for (i = 0; i < argc; ++i)
273 foo();
274 #pragma omp target data map(k, j, l) // lt50-note {{used here}}
275 #pragma omp target simd map(k[:4]) // lt50-error {{pointer cannot be mapped along with a section derived from itself}}
276 for (i = 0; i < argc; ++i) foo();
277 #pragma omp target simd map(j)
278 for (i = 0; i < argc; ++i)
279 foo();
280 #pragma omp target simd map(l) map(l[:5]) // lt50-error {{variable already marked as mapped in current construct}} lt50-note {{used here}}
281 for (i = 0; i < argc; ++i)
282 foo();
283 #pragma omp target data map(k[:4], j, l[:5]) // lt50-note {{used here}}
285 #pragma omp target simd map(k) // lt50-error {{pointer cannot be mapped along with a section derived from itself}}
286 for (i = 0; i < argc; ++i)
287 foo();
288 #pragma omp target simd map(j)
289 for (i = 0; i < argc; ++i) foo();
290 #pragma omp target simd map(l) //
291 for (i = 0; i < argc; ++i) foo();
294 #pragma omp target simd map(always, tofrom: x)
295 for (i = 0; i < argc; ++i) foo();
296 #pragma omp target simd map(always: x) // expected-error {{missing map type}}
297 for (i = 0; i < argc; ++i) foo();
298 // ge51-error@+3 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present'}}
299 // lt51-error@+2 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper'}}
300 // expected-error@+1 {{missing map type}}
301 #pragma omp target simd map(tofrom, always: x)
302 for (i = 0; i < argc; ++i) foo();
303 #pragma omp target simd map(always, tofrom: always, tofrom, x)
304 for (i = 0; i < argc; ++i) foo();
305 #pragma omp target simd map(always tofrom: x) // omp52-error {{missing ',' after map type modifier}}
306 for (i = 0; i < argc; ++i) foo();
307 #pragma omp target simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
308 for (i = 0; i < argc; ++i) foo();
309 #pragma omp target simd map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target simd'}}
310 for (i = 0; i < argc; ++i)
311 foo();
312 #pragma omp target simd map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target simd'}}
313 for (i = 0; i < argc; ++i)
314 foo();
316 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}}