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 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 map // expected-error {{expected '(' after 'map'}}
84 #pragma omp target parallel map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
86 #pragma omp target parallel map() // expected-error {{expected expression}}
88 #pragma omp target parallel map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
90 #pragma omp target parallel map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
92 #pragma omp target parallel map(to:) // expected-error {{expected expression}}
94 #pragma omp target parallel map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
96 #pragma omp target parallel map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
98 #pragma omp target parallel map(l[-1:]) // expected-error 2 {{array section must be a subset of the original array}}
100 #pragma omp target parallel map(l[:-1]) // expected-error 2 {{section length is evaluated to a negative value -1}}
102 #pragma omp target parallel map(l[true:true])
104 #pragma omp target parallel map(x, z)
106 #pragma omp target parallel map(tofrom: t[:I])
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}}
110 #pragma omp target parallel map(T) // expected-error {{'T' does not refer to a value}}
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)
116 #pragma omp target parallel map(S2::S2s)
118 #pragma omp target parallel map(S2::S2sc)
120 #pragma omp target parallel map(x)
122 #pragma omp target parallel map(to: x)
124 #pragma omp target parallel map(to: to)
126 #pragma omp target parallel map(to)
128 #pragma omp target parallel map(to, x)
130 #pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
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 \
137 #pragma omp target parallel map(argc)
139 #pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}}
141 #pragma omp target parallel map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
143 #pragma omp target parallel map(ba)
145 #pragma omp target parallel map(ca)
147 #pragma omp target parallel map(da)
149 #pragma omp target parallel map(S2::S2s)
151 #pragma omp target parallel map(S2::S2sc)
153 #pragma omp target parallel map(e, g)
155 #pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
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}}
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}}
161 #pragma omp target parallel map(da)
163 #pragma omp target parallel map(da[:4])
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}}
168 #pragma omp target parallel map(j)
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}}
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}}
176 #pragma omp target parallel map(j)
178 #pragma omp target parallel map(l)
182 #pragma omp target parallel map(always, tofrom: x)
184 #pragma omp target parallel map(always: x) // expected-error {{missing map type}}
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)
191 #pragma omp target parallel map(always, tofrom: always, tofrom, x)
193 #pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
199 int main(int argc
, char **argv
) {
201 const int da
[5] = { 0 };
209 int to
, tofrom
, always
;
210 const int (&l
)[5] = da
;
211 #pragma omp target parallel map // expected-error {{expected '(' after 'map'}}
213 #pragma omp target parallel map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
215 #pragma omp target parallel map() // expected-error {{expected expression}}
217 #pragma omp target parallel map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
219 #pragma omp target parallel map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
221 #pragma omp target parallel map(to:) // expected-error {{expected expression}}
223 #pragma omp target parallel map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
225 #pragma omp target parallel map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
227 #pragma omp target parallel map(l[-1:]) // expected-error {{array section must be a subset of the original array}}
229 #pragma omp target parallel map(l[:-1]) // expected-error {{section length is evaluated to a negative value -1}}
231 #pragma omp target parallel map(l[true:true])
233 #pragma omp target parallel map(x)
235 #pragma omp target parallel map(to: x)
237 #pragma omp target parallel map(to: to)
239 #pragma omp target parallel map(to)
241 #pragma omp target parallel map(to, x)
243 #pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
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])
250 #pragma omp target parallel map(argc)
252 #pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}}
254 #pragma omp target parallel map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
256 #pragma omp target parallel map(argv[1])
258 #pragma omp target parallel map(ba)
260 #pragma omp target parallel map(ca)
262 #pragma omp target parallel map(da)
264 #pragma omp target parallel map(S2::S2s)
266 #pragma omp target parallel map(S2::S2sc)
268 #pragma omp target parallel map(e, g)
270 #pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
272 #pragma omp target parallel map(k), map(k) // lt50-error {{variable already marked as mapped in current construct}} lt50-note {{used here}}
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}}
276 #pragma omp target parallel map(da)
278 #pragma omp target parallel map(da[:4])
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}}
283 #pragma omp target parallel map(j)
285 #pragma omp target parallel map(l) map(l[:5]) // lt50-error {{variable already marked as mapped in current construct}} lt50-note {{used here}}
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}}
291 #pragma omp target parallel map(j)
293 #pragma omp target parallel map(l)
297 #pragma omp target parallel map(always, tofrom: x)
299 #pragma omp target parallel map(always: x) // expected-error {{missing map type}}
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)
306 #pragma omp target parallel map(always, tofrom: always, tofrom, x)
308 #pragma omp target parallel map(always tofrom: x) // omp52-error {{missing ',' after map type modifier}}
310 #pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
312 #pragma omp target parallel map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target parallel'}}
314 #pragma omp target parallel map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target parallel'}}
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}}