]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/OpenMP/target_parallel_for_simd_map_messages.cpp
Vendor import of clang trunk r290819:
[FreeBSD/FreeBSD.git] / test / OpenMP / target_parallel_for_simd_map_messages.cpp
1 // RUN: %clang_cc1 -verify -fopenmp %s
2
3 void foo() {
4 }
5
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:
15   S2():a(0) { }
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:
26   S3():a(0) { }
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:
37   S4(int v):a(v) { }
38 };
39 class S5 {
40   int a;
41   S5():a(0) {}
42   S5(const S5 &s5):a(s5.a) { }
43 public:
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}}
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(l[-1:]) // expected-error 2 {{array section must be a subset of the original array}}
84   for (i = 0; i < argc; ++i) foo();
85 #pragma omp target parallel for simd map(l[:-1]) // expected-error 2 {{section length is evaluated to a negative value -1}}
86   for (i = 0; i < argc; ++i) foo();
87 #pragma omp target parallel for simd map(x)
88   for (i = 0; i < argc; ++i) foo();
89 #pragma omp target parallel for simd map(tofrom: t[:I])
90   for (i = 0; i < argc; ++i) foo();
91 #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}}
92   for (i = 0; i < argc; ++i) foo();
93 #pragma omp target parallel for simd map(T) // expected-error {{'T' does not refer to a value}}
94   for (i = 0; i < argc; ++i) foo();
95 #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}}
96   for (i = 0; i < argc; ++i) foo();
97 #pragma omp target parallel for simd map(S2::S2s)
98   for (i = 0; i < argc; ++i) foo();
99 #pragma omp target parallel for simd map(S2::S2sc)
100   for (i = 0; i < argc; ++i) foo();
101 #pragma omp target parallel for simd map(x)
102   for (i = 0; i < argc; ++i) foo();
103 #pragma omp target parallel for simd map(to: x)
104   for (i = 0; i < argc; ++i) foo();
105 #pragma omp target parallel for simd map(to: to)
106   for (i = 0; i < argc; ++i) foo();
107 #pragma omp target parallel for simd map(to)
108   for (i = 0; i < argc; ++i) foo();
109 #pragma omp target parallel for simd map(to, x)
110   for (i = 0; i < argc; ++i) foo();
111 #pragma omp target parallel for simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
112   for (i = 0; i < argc; ++i) foo();
113 #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}} 
114   for (i = 0; i < argc; ++i) foo();
115 #pragma omp target parallel for simd map(argc)
116   for (i = 0; i < argc; ++i) foo();
117 #pragma omp target parallel for simd map(S1) // expected-error {{'S1' does not refer to a value}}
118   for (i = 0; i < argc; ++i) foo();
119 #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}}
120   for (i = 0; i < argc; ++i) foo();
121 #pragma omp target parallel for simd map(ba) // expected-error 2 {{type 'S2' is not mappable to target}}
122   for (i = 0; i < argc; ++i) foo();
123 #pragma omp target parallel for simd map(ca)
124   for (i = 0; i < argc; ++i) foo();
125 #pragma omp target parallel for simd map(da)
126   for (i = 0; i < argc; ++i) foo();
127 #pragma omp target parallel for simd map(S2::S2s)
128   for (i = 0; i < argc; ++i) foo();
129 #pragma omp target parallel for simd map(S2::S2sc)
130   for (i = 0; i < argc; ++i) foo();
131 #pragma omp target parallel for simd map(e, g)
132   for (i = 0; i < argc; ++i) foo();
133 #pragma omp target parallel for simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
134   for (i = 0; i < argc; ++i) foo();
135 #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}}
136   for (i = 0; i < argc; ++i) foo();
137 #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}}
138   for (i = 0; i < argc; ++i) foo();
139 #pragma omp target parallel for simd map(da)
140   for (i = 0; i < argc; ++i) foo();
141 #pragma omp target parallel for simd map(da[:4])
142   for (i = 0; i < argc; ++i) foo();
143 #pragma omp target data map(k, j, l) // expected-note 2 {{used here}}
144 #pragma omp target parallel for simd map(k[:4]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
145   for (i = 0; i < argc; ++i) foo();
146 #pragma omp target parallel for simd map(j)
147   for (i = 0; i < argc; ++i) foo();
148 #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}}
149   for (i = 0; i < argc; ++i) foo();
150 #pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
151 {
152 #pragma omp target parallel for simd map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
153   for (i = 0; i < argc; ++i) foo();
154 #pragma omp target parallel for simd map(j)
155   for (i = 0; i < argc; ++i) foo();
156 #pragma omp target parallel for simd map(l)
157   for (i = 0; i < argc; ++i) foo();
158 }
159
160 #pragma omp target parallel for simd map(always, tofrom: x)
161   for (i = 0; i < argc; ++i) foo();
162 #pragma omp target parallel for simd map(always: x) // expected-error {{missing map type}}
163   for (i = 0; i < argc; ++i) foo();
164 #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'}}
165   for (i = 0; i < argc; ++i) foo();
166 #pragma omp target parallel for simd map(always, tofrom: always, tofrom, x)
167   for (i = 0; i < argc; ++i) foo();
168 #pragma omp target parallel for simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
169   for (i = 0; i < argc; ++i) foo();
170
171   return 0;
172 }
173
174 int main(int argc, char **argv) {
175   const int d = 5;
176   const int da[5] = { 0 };
177   S4 e(4);
178   S5 g(5);
179   int i;
180   int &j = i;
181   int *k = &j;
182   int x;
183   int y;
184   int to, tofrom, always;
185   const int (&l)[5] = da;
186
187 #pragma omp target parallel for simd map // expected-error {{expected '(' after 'map'}}
188   for (i = 0; i < argc; ++i) foo();
189 #pragma omp target parallel for simd map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
190   for (i = 0; i < argc; ++i) foo();
191 #pragma omp target parallel for simd map() // expected-error {{expected expression}}
192   for (i = 0; i < argc; ++i) foo();
193 #pragma omp target parallel for simd map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
194   for (i = 0; i < argc; ++i) foo();
195 #pragma omp target parallel for simd map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
196   for (i = 0; i < argc; ++i) foo();
197 #pragma omp target parallel for simd map(to:) // expected-error {{expected expression}}
198   for (i = 0; i < argc; ++i) foo();
199 #pragma omp target parallel for simd map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
200   for (i = 0; i < argc; ++i) foo();
201 #pragma omp target parallel for simd map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
202   for (i = 0; i < argc; ++i) foo();
203 #pragma omp target parallel map(l[-1:]) // expected-error {{array section must be a subset of the original array}}
204   for (i = 0; i < argc; ++i) foo();
205 #pragma omp target parallel map(l[:-1]) // expected-error {{section length is evaluated to a negative value -1}}
206   for (i = 0; i < argc; ++i) foo();
207 #pragma omp target parallel for simd map(x)
208   for (i = 0; i < argc; ++i) foo();
209 #pragma omp target parallel for simd map(to: x)
210   for (i = 0; i < argc; ++i) foo();
211 #pragma omp target parallel for simd map(to: to)
212   for (i = 0; i < argc; ++i) foo();
213 #pragma omp target parallel for simd map(to)
214   for (i = 0; i < argc; ++i) foo();
215 #pragma omp target parallel for simd map(to, x)
216   for (i = 0; i < argc; ++i) foo();
217 #pragma omp target parallel for simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
218   for (i = 0; i < argc; ++i) foo();
219 #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}}
220   for (i = 0; i < argc; ++i) foo();
221 #pragma omp target parallel for simd map(argc)
222   for (i = 0; i < argc; ++i) foo();
223 #pragma omp target parallel for simd map(S1) // expected-error {{'S1' does not refer to a value}}
224   for (i = 0; i < argc; ++i) foo();
225 #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}}
226   for (i = 0; i < argc; ++i) foo();
227 #pragma omp target parallel for simd map(argv[1])
228   for (i = 0; i < argc; ++i) foo();
229 #pragma omp target parallel for simd map(ba) // expected-error 2 {{type 'S2' is not mappable to target}}
230   for (i = 0; i < argc; ++i) foo();
231 #pragma omp target parallel for simd map(ca)
232   for (i = 0; i < argc; ++i) foo();
233 #pragma omp target parallel for simd map(da)
234   for (i = 0; i < argc; ++i) foo();
235 #pragma omp target parallel for simd map(S2::S2s)
236   for (i = 0; i < argc; ++i) foo();
237 #pragma omp target parallel for simd map(S2::S2sc)
238   for (i = 0; i < argc; ++i) foo();
239 #pragma omp target parallel for simd map(e, g)
240   for (i = 0; i < argc; ++i) foo();
241 #pragma omp target parallel for simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
242   for (i = 0; i < argc; ++i) foo();
243 #pragma omp target parallel for simd map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
244   for (i = 0; i < argc; ++i) foo();
245 #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}}
246   for (i = 0; i < argc; ++i) foo();
247 #pragma omp target parallel for simd map(da)
248   for (i = 0; i < argc; ++i) foo();
249 #pragma omp target parallel for simd map(da[:4])
250   for (i = 0; i < argc; ++i) foo();
251 #pragma omp target data map(k, j, l) // expected-note {{used here}}
252 #pragma omp target parallel for simd map(k[:4]) // 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) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}}
257   for (i = 0; i < argc; ++i) foo();
258 #pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}}
259 {
260 #pragma omp target parallel for simd map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
261   for (i = 0; i < argc; ++i) foo();
262 #pragma omp target parallel for simd map(j)
263   for (i = 0; i < argc; ++i) foo();
264 #pragma omp target parallel for simd map(l)
265   for (i = 0; i < argc; ++i) foo();
266 }
267
268 #pragma omp target parallel for simd map(always, tofrom: x)
269   for (i = 0; i < argc; ++i) foo();
270 #pragma omp target parallel for simd map(always: x) // expected-error {{missing map type}}
271   for (i = 0; i < argc; ++i) foo();
272 #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'}}
273   for (i = 0; i < argc; ++i) foo();
274 #pragma omp target parallel for simd map(always, tofrom: always, tofrom, x)
275   for (i = 0; i < argc; ++i) foo();
276 #pragma omp target parallel for simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
277   for (i = 0; i < argc; ++i) foo();
278
279   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}}
280 }
281