1 // RUN: %clang_cc1 -verify -fopenmp %s
2
foo()3 void foo() {
4 }
5
foobool(int argc)6 bool foobool(int argc) {
7 return argc;
8 }
9
10 struct S1; // expected-note 2 {{declared here}}
11 extern S1 a;
12 class S2 {
13 mutable int a;
14 public:
S2()15 S2():a(0) { }
S2(S2 & s2)16 S2(S2 &s2):a(s2.a) { }
17 static float S2s; // expected-note 4 {{mappable type cannot contain static members}}
18 static const float S2sc; // expected-note 4 {{mappable type cannot contain static members}}
19 };
20 const float S2::S2sc = 0;
21 const S2 b;
22 const S2 ba[5];
23 class S3 {
24 int a;
25 public:
S3()26 S3():a(0) { }
S3(S3 & s3)27 S3(S3 &s3):a(s3.a) { }
28 };
29 const S3 c;
30 const S3 ca[5];
31 extern const int f;
32 class S4 {
33 int a;
34 S4();
35 S4(const S4 &s4);
36 public:
S4(int v)37 S4(int v):a(v) { }
38 };
39 class S5 {
40 int a;
S5()41 S5():a(0) {}
S5(const S5 & s5)42 S5(const S5 &s5):a(s5.a) { }
43 public:
S5(int v)44 S5(int v):a(v) { }
45 };
46
47 S3 h;
48 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
49
50 typedef int from;
51
52 template <typename T, int I> // expected-note {{declared here}}
tmain(T argc)53 T tmain(T argc) {
54 const T d = 5;
55 const T da[5] = { 0 };
56 S4 e(4);
57 S5 g(5);
58 T i, t[20];
59 T &j = i;
60 T *k = &j;
61 T x;
62 T y;
63 T to, tofrom, always;
64 const T (&l)[5] = da;
65
66
67 #pragma omp target parallel for simd map // expected-error {{expected '(' after 'map'}}
68 for (i = 0; i < argc; ++i) foo();
69 #pragma omp target parallel for simd map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
70 for (i = 0; i < argc; ++i) foo();
71 #pragma omp target parallel for simd map() // expected-error {{expected expression}}
72 for (i = 0; i < argc; ++i) foo();
73 #pragma omp target parallel for simd map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
74 for (i = 0; i < argc; ++i) foo();
75 #pragma omp target parallel for simd map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
76 for (i = 0; i < argc; ++i) foo();
77 #pragma omp target parallel for simd map(to:) // expected-error {{expected expression}}
78 for (i = 0; i < argc; ++i) foo();
79 #pragma omp target parallel for simd map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
80 for (i = 0; i < argc; ++i) foo();
81 #pragma omp target parallel for simd map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
82 for (i = 0; i < argc; ++i) foo();
83 #pragma omp target parallel for simd map(x)
84 for (i = 0; i < argc; ++i) foo();
85 #pragma omp target parallel for simd map(tofrom: t[:I])
86 for (i = 0; i < argc; ++i) foo();
87 #pragma omp target parallel for 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}}
88 for (i = 0; i < argc; ++i) foo();
89 #pragma omp target parallel for simd map(T) // expected-error {{'T' does not refer to a value}}
90 for (i = 0; i < argc; ++i) foo();
91 #pragma omp target parallel for simd map(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
92 for (i = 0; i < argc; ++i) foo();
93 #pragma omp target parallel for simd map(S2::S2s)
94 for (i = 0; i < argc; ++i) foo();
95 #pragma omp target parallel for simd map(S2::S2sc)
96 for (i = 0; i < argc; ++i) foo();
97 #pragma omp target parallel for simd map(x)
98 for (i = 0; i < argc; ++i) foo();
99 #pragma omp target parallel for simd map(to: x)
100 for (i = 0; i < argc; ++i) foo();
101 #pragma omp target parallel for simd map(to: to)
102 for (i = 0; i < argc; ++i) foo();
103 #pragma omp target parallel for simd map(to)
104 for (i = 0; i < argc; ++i) foo();
105 #pragma omp target parallel for simd map(to, x)
106 for (i = 0; i < argc; ++i) foo();
107 #pragma omp target parallel for simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
108 for (i = 0; i < argc; ++i) foo();
109 #pragma omp target parallel for simd map(tofrom: argc > 0 ? x : y) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
110 for (i = 0; i < argc; ++i) foo();
111 #pragma omp target parallel for simd map(argc)
112 for (i = 0; i < argc; ++i) foo();
113 #pragma omp target parallel for simd map(S1) // expected-error {{'S1' does not refer to a value}}
114 for (i = 0; i < argc; ++i) foo();
115 #pragma omp target parallel for simd map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}}
116 for (i = 0; i < argc; ++i) foo();
117 #pragma omp target parallel for simd map(ba) // expected-error 2 {{type 'S2' is not mappable to target}}
118 for (i = 0; i < argc; ++i) foo();
119 #pragma omp target parallel for simd map(ca)
120 for (i = 0; i < argc; ++i) foo();
121 #pragma omp target parallel for simd map(da)
122 for (i = 0; i < argc; ++i) foo();
123 #pragma omp target parallel for simd map(S2::S2s)
124 for (i = 0; i < argc; ++i) foo();
125 #pragma omp target parallel for simd map(S2::S2sc)
126 for (i = 0; i < argc; ++i) foo();
127 #pragma omp target parallel for simd map(e, g)
128 for (i = 0; i < argc; ++i) foo();
129 #pragma omp target parallel for simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
130 for (i = 0; i < argc; ++i) foo();
131 #pragma omp target parallel for simd map(k), map(k) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
132 for (i = 0; i < argc; ++i) foo();
133 #pragma omp target parallel for simd map(k), map(k[:5]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} expected-note 2 {{used here}}
134 for (i = 0; i < argc; ++i) foo();
135 #pragma omp target parallel for simd map(da)
136 for (i = 0; i < argc; ++i) foo();
137 #pragma omp target parallel for simd map(da[:4])
138 for (i = 0; i < argc; ++i) foo();
139 #pragma omp target data map(k, j, l) // expected-note 2 {{used here}}
140 #pragma omp target parallel for simd map(k[:4]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
141 for (i = 0; i < argc; ++i) foo();
142 #pragma omp target parallel for simd map(j)
143 for (i = 0; i < argc; ++i) foo();
144 #pragma omp target parallel for simd map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
145 for (i = 0; i < argc; ++i) foo();
146 #pragma omp target data map(k[:4], j, l[:5]) // expected-note 4 {{used here}}
147 {
148 #pragma omp target parallel for simd map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
149 for (i = 0; i < argc; ++i) foo();
150 #pragma omp target parallel for simd map(j)
151 for (i = 0; i < argc; ++i) foo();
152 #pragma omp target parallel for simd map(l) // expected-error 2 {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
153 for (i = 0; i < argc; ++i) foo();
154 }
155
156 #pragma omp target parallel for simd map(always, tofrom: x)
157 for (i = 0; i < argc; ++i) foo();
158 #pragma omp target parallel for simd map(always: x) // expected-error {{missing map type}}
159 for (i = 0; i < argc; ++i) foo();
160 #pragma omp target parallel for simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always'}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
161 for (i = 0; i < argc; ++i) foo();
162 #pragma omp target parallel for simd map(always, tofrom: always, tofrom, x)
163 for (i = 0; i < argc; ++i) foo();
164 #pragma omp target parallel for simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
165 for (i = 0; i < argc; ++i) foo();
166
167 return 0;
168 }
169
main(int argc,char ** argv)170 int main(int argc, char **argv) {
171 const int d = 5;
172 const int da[5] = { 0 };
173 S4 e(4);
174 S5 g(5);
175 int i;
176 int &j = i;
177 int *k = &j;
178 int x;
179 int y;
180 int to, tofrom, always;
181 const int (&l)[5] = da;
182
183 #pragma omp target parallel for simd map // expected-error {{expected '(' after 'map'}}
184 for (i = 0; i < argc; ++i) foo();
185 #pragma omp target parallel for simd map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
186 for (i = 0; i < argc; ++i) foo();
187 #pragma omp target parallel for simd map() // expected-error {{expected expression}}
188 for (i = 0; i < argc; ++i) foo();
189 #pragma omp target parallel for simd map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
190 for (i = 0; i < argc; ++i) foo();
191 #pragma omp target parallel for simd map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
192 for (i = 0; i < argc; ++i) foo();
193 #pragma omp target parallel for simd map(to:) // expected-error {{expected expression}}
194 for (i = 0; i < argc; ++i) foo();
195 #pragma omp target parallel for simd map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
196 for (i = 0; i < argc; ++i) foo();
197 #pragma omp target parallel for simd map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
198 for (i = 0; i < argc; ++i) foo();
199 #pragma omp target parallel for simd map(x)
200 for (i = 0; i < argc; ++i) foo();
201 #pragma omp target parallel for simd map(to: x)
202 for (i = 0; i < argc; ++i) foo();
203 #pragma omp target parallel for simd map(to: to)
204 for (i = 0; i < argc; ++i) foo();
205 #pragma omp target parallel for simd map(to)
206 for (i = 0; i < argc; ++i) foo();
207 #pragma omp target parallel for simd map(to, x)
208 for (i = 0; i < argc; ++i) foo();
209 #pragma omp target parallel for simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
210 for (i = 0; i < argc; ++i) foo();
211 #pragma omp target parallel for simd map(tofrom: argc > 0 ? argv[1] : argv[2]) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}}
212 for (i = 0; i < argc; ++i) foo();
213 #pragma omp target parallel for simd map(argc)
214 for (i = 0; i < argc; ++i) foo();
215 #pragma omp target parallel for simd map(S1) // expected-error {{'S1' does not refer to a value}}
216 for (i = 0; i < argc; ++i) foo();
217 #pragma omp target parallel for simd map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}}
218 for (i = 0; i < argc; ++i) foo();
219 #pragma omp target parallel for simd map(argv[1])
220 for (i = 0; i < argc; ++i) foo();
221 #pragma omp target parallel for simd map(ba) // expected-error 2 {{type 'S2' is not mappable to target}}
222 for (i = 0; i < argc; ++i) foo();
223 #pragma omp target parallel for simd map(ca)
224 for (i = 0; i < argc; ++i) foo();
225 #pragma omp target parallel for simd map(da)
226 for (i = 0; i < argc; ++i) foo();
227 #pragma omp target parallel for simd map(S2::S2s)
228 for (i = 0; i < argc; ++i) foo();
229 #pragma omp target parallel for simd map(S2::S2sc)
230 for (i = 0; i < argc; ++i) foo();
231 #pragma omp target parallel for simd map(e, g)
232 for (i = 0; i < argc; ++i) foo();
233 #pragma omp target parallel for simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
234 for (i = 0; i < argc; ++i) foo();
235 #pragma omp target parallel for simd map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
236 for (i = 0; i < argc; ++i) foo();
237 #pragma omp target parallel for simd map(k), map(k[:5]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}}
238 for (i = 0; i < argc; ++i) foo();
239 #pragma omp target parallel for simd map(da)
240 for (i = 0; i < argc; ++i) foo();
241 #pragma omp target parallel for simd map(da[:4])
242 for (i = 0; i < argc; ++i) foo();
243 #pragma omp target data map(k, j, l) // expected-note {{used here}}
244 #pragma omp target parallel for simd map(k[:4]) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
245 for (i = 0; i < argc; ++i) foo();
246 #pragma omp target parallel for simd map(j)
247 for (i = 0; i < argc; ++i) foo();
248 #pragma omp target parallel for simd map(l) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}}
249 for (i = 0; i < argc; ++i) foo();
250 #pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
251 {
252 #pragma omp target parallel for simd map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
253 for (i = 0; i < argc; ++i) foo();
254 #pragma omp target parallel for simd map(j)
255 for (i = 0; i < argc; ++i) foo();
256 #pragma omp target parallel for simd map(l) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
257 for (i = 0; i < argc; ++i) foo();
258 }
259
260 #pragma omp target parallel for simd map(always, tofrom: x)
261 for (i = 0; i < argc; ++i) foo();
262 #pragma omp target parallel for simd map(always: x) // expected-error {{missing map type}}
263 for (i = 0; i < argc; ++i) foo();
264 #pragma omp target parallel for simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always'}} expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
265 for (i = 0; i < argc; ++i) foo();
266 #pragma omp target parallel for simd map(always, tofrom: always, tofrom, x)
267 for (i = 0; i < argc; ++i) foo();
268 #pragma omp target parallel for simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
269 for (i = 0; i < argc; ++i) foo();
270
271 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}}
272 }
273
274