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
14 bool foobool(int argc
) {
19 int map
; // expected-note {{initialize the variable 'map' to silence this warning}}
20 #pragma omp target parallel for 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'}}
31 S2(S2
&s2
):a(s2
.a
) { }
33 static const float S2sc
;
35 const float S2::S2sc
= 0;
42 S3(S3
&s3
):a(s3
.a
) { }
57 S5(const S5
&s5
):a(s5
.a
) { }
63 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
67 template <typename T
, int I
> // expected-note {{declared here}}
70 const T da
[5] = { 0 };
82 #pragma omp target parallel for map // expected-error {{expected '(' after 'map'}}
83 for (i
= 0; i
< argc
; ++i
) foo();
84 #pragma omp target parallel for 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 parallel for map() // expected-error {{expected expression}}
87 for (i
= 0; i
< argc
; ++i
) foo();
88 #pragma omp target parallel for map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
89 for (i
= 0; i
< argc
; ++i
) foo();
90 #pragma omp target parallel for 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 parallel for map(to:) // expected-error {{expected expression}}
93 for (i
= 0; i
< argc
; ++i
) foo();
94 #pragma omp target parallel for 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 parallel for 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 parallel for map(l[-1:]) // expected-error 2 {{array section must be a subset of the original array}}
99 for (i
= 0; i
< argc
; ++i
) foo();
100 #pragma omp target parallel for map(l[:-1]) // expected-error 2 {{section length is evaluated to a negative value -1}}
101 for (i
= 0; i
< argc
; ++i
) foo();
102 #pragma omp target parallel for map(l[true:true])
103 for (i
= 0; i
< argc
; ++i
) foo();
104 #pragma omp target parallel for map(x)
105 for (i
= 0; i
< argc
; ++i
) foo();
106 #pragma omp target parallel for map(tofrom: t[:I])
107 for (i
= 0; i
< argc
; ++i
) foo();
108 #pragma omp target 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}}
109 for (i
= 0; i
< argc
; ++i
) foo();
110 #pragma omp target parallel for map(T) // expected-error {{'T' does not refer to a value}}
111 for (i
= 0; i
< argc
; ++i
) 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 for map(I)
115 for (i
= 0; i
< argc
; ++i
) foo();
116 #pragma omp target parallel for map(S2::S2s)
117 for (i
= 0; i
< argc
; ++i
) foo();
118 #pragma omp target parallel for map(S2::S2sc)
119 for (i
= 0; i
< argc
; ++i
) foo();
120 #pragma omp target parallel for map(x)
121 for (i
= 0; i
< argc
; ++i
) foo();
122 #pragma omp target parallel for map(to: x)
123 for (i
= 0; i
< argc
; ++i
) foo();
124 #pragma omp target parallel for map(to: to)
125 for (i
= 0; i
< argc
; ++i
) foo();
126 #pragma omp target parallel for map(to)
127 for (i
= 0; i
< argc
; ++i
) foo();
128 #pragma omp target parallel for map(to, x)
129 for (i
= 0; i
< argc
; ++i
) foo();
130 #pragma omp target parallel for map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
131 for (i
= 0; i
< argc
; ++i
) 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 for map(tofrom \
136 for (i
= 0; i
< argc
; ++i
) foo();
137 #pragma omp target parallel for map(argc)
138 for (i
= 0; i
< argc
; ++i
) foo();
139 #pragma omp target parallel for map(S1) // expected-error {{'S1' does not refer to a value}}
140 for (i
= 0; i
< argc
; ++i
) foo();
141 #pragma omp target parallel for map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
142 for (i
= 0; i
< argc
; ++i
) foo();
143 #pragma omp target parallel for map(ba)
144 for (i
= 0; i
< argc
; ++i
) foo();
145 #pragma omp target parallel for map(ca)
146 for (i
= 0; i
< argc
; ++i
) foo();
147 #pragma omp target parallel for map(da)
148 for (i
= 0; i
< argc
; ++i
) foo();
149 #pragma omp target parallel for map(S2::S2s)
150 for (i
= 0; i
< argc
; ++i
) foo();
151 #pragma omp target parallel for map(S2::S2sc)
152 for (i
= 0; i
< argc
; ++i
) foo();
153 #pragma omp target parallel for map(e, g)
154 for (i
= 0; i
< argc
; ++i
) foo();
155 #pragma omp target parallel for map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
156 for (i
= 0; i
< argc
; ++i
) foo();
157 #pragma omp target parallel for map(k), map(k) // lt50-error 2 {{variable already marked as mapped in current construct}} lt50-note 2 {{used here}}
158 for (i
= 0; i
< argc
; ++i
) foo();
159 #pragma omp target 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}}
160 for (i
= 0; i
< argc
; ++i
) foo();
161 #pragma omp target parallel for map(da)
162 for (i
= 0; i
< argc
; ++i
) foo();
163 #pragma omp target parallel for map(da[:4])
164 for (i
= 0; i
< argc
; ++i
) foo();
165 #pragma omp target data map(k, j, l) // lt50-note 2 {{used here}}
166 #pragma omp target parallel for map(k[:4]) // lt50-error 2 {{pointer cannot be mapped along with a section derived from itself}}
167 for (i
= 0; i
< argc
; ++i
) foo();
168 #pragma omp target parallel for map(j)
169 for (i
= 0; i
< argc
; ++i
) foo();
170 #pragma omp target parallel for map(l) map(l[:5]) // lt50-error 2 {{variable already marked as mapped in current construct}} lt50-note 2 {{used here}}
171 for (i
= 0; i
< argc
; ++i
) foo();
172 #pragma omp target data map(k[:4], j, l[:5]) // lt50-note 2 {{used here}}
174 #pragma omp target parallel for map(k) // lt50-error 2 {{pointer cannot be mapped along with a section derived from itself}}
175 for (i
= 0; i
< argc
; ++i
)
177 #pragma omp target parallel for map(j)
178 for (i
= 0; i
< argc
; ++i
) foo();
179 #pragma omp target parallel for map(l)
180 for (i
= 0; i
< argc
; ++i
) foo();
183 #pragma omp target parallel for map(always, tofrom: x)
184 for (i
= 0; i
< argc
; ++i
) foo();
185 #pragma omp target parallel for map(always: x) // expected-error {{missing map type}}
186 for (i
= 0; i
< argc
; ++i
) foo();
187 // ge51-error@+3 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present'}}
188 // lt51-error@+2 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper'}}
189 // expected-error@+1 {{missing map type}}
190 #pragma omp target parallel for map(tofrom, always: x)
191 for (i
= 0; i
< argc
; ++i
) foo();
192 #pragma omp target parallel for map(always, tofrom: always, tofrom, x)
193 for (i
= 0; i
< argc
; ++i
) foo();
194 #pragma omp target parallel for map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
195 for (i
= 0; i
< argc
; ++i
) foo();
200 int main(int argc
, char **argv
) {
202 const int da
[5] = { 0 };
210 int to
, tofrom
, always
;
211 const int (&l
)[5] = da
;
213 #pragma omp target parallel for map // expected-error {{expected '(' after 'map'}}
214 for (i
= 0; i
< argc
; ++i
) foo();
215 #pragma omp target parallel for map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
216 for (i
= 0; i
< argc
; ++i
) foo();
217 #pragma omp target parallel for map() // expected-error {{expected expression}}
218 for (i
= 0; i
< argc
; ++i
) foo();
219 #pragma omp target parallel for map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
220 for (i
= 0; i
< argc
; ++i
) foo();
221 #pragma omp target parallel for map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
222 for (i
= 0; i
< argc
; ++i
) foo();
223 #pragma omp target parallel for map(to:) // expected-error {{expected expression}}
224 for (i
= 0; i
< argc
; ++i
) foo();
225 #pragma omp target parallel for map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
226 for (i
= 0; i
< argc
; ++i
) foo();
227 #pragma omp target parallel for map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
228 for (i
= 0; i
< argc
; ++i
) foo();
229 #pragma omp target parallel for map(l[-1:]) // expected-error {{array section must be a subset of the original array}}
230 for (i
= 0; i
< argc
; ++i
) foo();
231 #pragma omp target parallel for map(l[:-1]) // expected-error {{section length is evaluated to a negative value -1}}
232 for (i
= 0; i
< argc
; ++i
) foo();
233 #pragma omp target parallel for map(l[true:true])
234 for (i
= 0; i
< argc
; ++i
) foo();
235 #pragma omp target parallel for map(x)
236 for (i
= 0; i
< argc
; ++i
) foo();
237 #pragma omp target parallel for map(to: x)
238 for (i
= 0; i
< argc
; ++i
) foo();
239 #pragma omp target parallel for map(to: to)
240 for (i
= 0; i
< argc
; ++i
) foo();
241 #pragma omp target parallel for map(to)
242 for (i
= 0; i
< argc
; ++i
) foo();
243 #pragma omp target parallel for map(to, x)
244 for (i
= 0; i
< argc
; ++i
) foo();
245 #pragma omp target parallel for map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
246 for (i
= 0; i
< argc
; ++i
)
248 // ge50-error@+3 {{expected addressable lvalue in 'map' clause}}
249 // lt50-error@+2 {{expected expression containing only member accesses and/or array sections based on named variables}}
250 #pragma omp target parallel for map(tofrom \
251 : argc > 0 ? argv[1] : argv[2])
252 for (i
= 0; i
< argc
; ++i
) foo();
253 #pragma omp target parallel for map(argc)
254 for (i
= 0; i
< argc
; ++i
) foo();
255 #pragma omp target parallel for map(S1) // expected-error {{'S1' does not refer to a value}}
256 for (i
= 0; i
< argc
; ++i
) foo();
257 #pragma omp target parallel for map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
258 for (i
= 0; i
< argc
; ++i
) foo();
259 #pragma omp target parallel for map(argv[1])
260 for (i
= 0; i
< argc
; ++i
) foo();
261 #pragma omp target parallel for map(ba)
262 for (i
= 0; i
< argc
; ++i
) foo();
263 #pragma omp target parallel for map(ca)
264 for (i
= 0; i
< argc
; ++i
) foo();
265 #pragma omp target parallel for map(da)
266 for (i
= 0; i
< argc
; ++i
) foo();
267 #pragma omp target parallel for map(S2::S2s)
268 for (i
= 0; i
< argc
; ++i
) foo();
269 #pragma omp target parallel for map(S2::S2sc)
270 for (i
= 0; i
< argc
; ++i
) foo();
271 #pragma omp target parallel for map(e, g)
272 for (i
= 0; i
< argc
; ++i
) foo();
273 #pragma omp target parallel for map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
274 for (i
= 0; i
< argc
; ++i
) foo();
275 #pragma omp target parallel for map(k), map(k) // lt50-error {{variable already marked as mapped in current construct}} lt50-note {{used here}}
276 for (i
= 0; i
< argc
; ++i
) foo();
277 #pragma omp target parallel for map(k), map(k[:5]) // lt50-error {{pointer cannot be mapped along with a section derived from itself}} lt50-note {{used here}}
278 for (i
= 0; i
< argc
; ++i
) foo();
279 #pragma omp target parallel for map(da)
280 for (i
= 0; i
< argc
; ++i
) foo();
281 #pragma omp target parallel for map(da[:4])
282 for (i
= 0; i
< argc
; ++i
) foo();
283 #pragma omp target data map(k, j, l) // lt50-note {{used here}}
284 #pragma omp target parallel for map(k[:4]) // lt50-error {{pointer cannot be mapped along with a section derived from itself}}
285 for (i
= 0; i
< argc
; ++i
) foo();
286 #pragma omp target parallel for map(j)
287 for (i
= 0; i
< argc
; ++i
) foo();
288 #pragma omp target parallel for map(l) map(l[:5]) // lt50-error 1 {{variable already marked as mapped in current construct}} lt50-note 1 {{used here}}
289 for (i
= 0; i
< argc
; ++i
) foo();
290 #pragma omp target data map(k[:4], j, l[:5]) // lt50-note {{used here}}
292 #pragma omp target parallel for map(k) // lt50-error {{pointer cannot be mapped along with a section derived from itself}}
293 for (i
= 0; i
< argc
; ++i
)
295 #pragma omp target parallel for map(j)
296 for (i
= 0; i
< argc
; ++i
) foo();
297 #pragma omp target parallel for map(l)
298 for (i
= 0; i
< argc
; ++i
) foo();
301 #pragma omp target parallel for map(always, tofrom: x)
302 for (i
= 0; i
< argc
; ++i
) foo();
303 #pragma omp target parallel for map(always: x) // expected-error {{missing map type}}
304 for (i
= 0; i
< argc
; ++i
) foo();
305 // ge51-error@+3 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper', 'present'}}
306 // lt51-error@+2 {{incorrect map type modifier, expected one of: 'always', 'close', 'mapper'}}
307 // expected-error@+1 {{missing map type}}
308 #pragma omp target parallel for map(tofrom, always: x)
309 for (i
= 0; i
< argc
; ++i
) foo();
310 #pragma omp target parallel for map(always, tofrom: always, tofrom, x)
311 for (i
= 0; i
< argc
; ++i
) foo();
312 #pragma omp target parallel for map(always tofrom: x) // omp52-error {{missing ',' after map type modifier}}
313 for (i
= 0; i
< argc
; ++i
) foo();
314 #pragma omp target parallel for map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
315 for (i
= 0; i
< argc
; ++i
) foo();
316 #pragma omp target parallel for map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target parallel for'}}
317 for (i
= 0; i
< argc
; ++i
)
319 #pragma omp target parallel for map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target parallel for'}}
320 for (i
= 0; i
< argc
; ++i
)
323 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}}