• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %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 map // expected-error {{expected '(' after 'map'}}
68   foo();
69 #pragma omp target parallel map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
70   foo();
71 #pragma omp target parallel map() // expected-error {{expected expression}}
72   foo();
73 #pragma omp target parallel map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
74   foo();
75 #pragma omp target parallel map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
76   foo();
77 #pragma omp target parallel map(to:) // expected-error {{expected expression}}
78   foo();
79 #pragma omp target parallel map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
80   foo();
81 #pragma omp target parallel map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
82   foo();
83 #pragma omp target parallel map(x)
84   foo();
85 #pragma omp target parallel map(tofrom: t[:I])
86   foo();
87 #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}}
88   foo();
89 #pragma omp target parallel map(T) // expected-error {{'T' does not refer to a value}}
90   foo();
91 #pragma omp target parallel map(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
92   foo();
93 #pragma omp target parallel map(S2::S2s)
94   foo();
95 #pragma omp target parallel map(S2::S2sc)
96   foo();
97 #pragma omp target parallel map(x)
98   foo();
99 #pragma omp target parallel map(to: x)
100   foo();
101 #pragma omp target parallel map(to: to)
102   foo();
103 #pragma omp target parallel map(to)
104   foo();
105 #pragma omp target parallel map(to, x)
106   foo();
107 #pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
108   foo();
109 #pragma omp target parallel map(tofrom: argc > 0 ? x : y) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
110   foo();
111 #pragma omp target parallel map(argc)
112   foo();
113 #pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}}
114   foo();
115 #pragma omp target parallel 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   foo();
117 #pragma omp target parallel map(ba) // expected-error 2 {{type 'S2' is not mappable to target}}
118   foo();
119 #pragma omp target parallel map(ca)
120   foo();
121 #pragma omp target parallel map(da)
122   foo();
123 #pragma omp target parallel map(S2::S2s)
124   foo();
125 #pragma omp target parallel map(S2::S2sc)
126   foo();
127 #pragma omp target parallel map(e, g)
128   foo();
129 #pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
130   foo();
131 #pragma omp target parallel map(k), map(k) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
132   foo();
133 #pragma omp target parallel 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   foo();
135 #pragma omp target parallel map(da)
136   foo();
137 #pragma omp target parallel map(da[:4])
138   foo();
139 #pragma omp target data map(k, j, l) // expected-note 2 {{used here}}
140 #pragma omp target parallel map(k[:4]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
141   foo();
142 #pragma omp target parallel map(j)
143   foo();
144 #pragma omp target parallel map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
145   foo();
146 #pragma omp target data map(k[:4], j, l[:5]) // expected-note 4 {{used here}}
147 {
148 #pragma omp target parallel map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
149   foo();
150 #pragma omp target parallel map(j)
151   foo();
152 #pragma omp target parallel 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   foo();
154 }
155 
156 #pragma omp target parallel map(always, tofrom: x)
157   foo();
158 #pragma omp target parallel map(always: x) // expected-error {{missing map type}}
159   foo();
160 #pragma omp target parallel 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   foo();
162 #pragma omp target parallel map(always, tofrom: always, tofrom, x)
163   foo();
164 #pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
165   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 #pragma omp target parallel map // expected-error {{expected '(' after 'map'}}
183   foo();
184 #pragma omp target parallel map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
185   foo();
186 #pragma omp target parallel map() // expected-error {{expected expression}}
187   foo();
188 #pragma omp target parallel map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
189   foo();
190 #pragma omp target parallel map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
191   foo();
192 #pragma omp target parallel map(to:) // expected-error {{expected expression}}
193   foo();
194 #pragma omp target parallel map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
195   foo();
196 #pragma omp target parallel map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
197   foo();
198 #pragma omp target parallel map(x)
199   foo();
200 #pragma omp target parallel map(to: x)
201   foo();
202 #pragma omp target parallel map(to: to)
203   foo();
204 #pragma omp target parallel map(to)
205   foo();
206 #pragma omp target parallel map(to, x)
207   foo();
208 #pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
209   foo();
210 #pragma omp target parallel map(tofrom: argc > 0 ? argv[1] : argv[2]) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}}
211   foo();
212 #pragma omp target parallel map(argc)
213   foo();
214 #pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}}
215   foo();
216 #pragma omp target parallel 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}}
217   foo();
218 #pragma omp target parallel map(argv[1])
219   foo();
220 #pragma omp target parallel map(ba) // expected-error 2 {{type 'S2' is not mappable to target}}
221   foo();
222 #pragma omp target parallel map(ca)
223   foo();
224 #pragma omp target parallel map(da)
225   foo();
226 #pragma omp target parallel map(S2::S2s)
227   foo();
228 #pragma omp target parallel map(S2::S2sc)
229   foo();
230 #pragma omp target parallel map(e, g)
231   foo();
232 #pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
233   foo();
234 #pragma omp target parallel map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
235   foo();
236 #pragma omp target parallel map(k), map(k[:5]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}}
237   foo();
238 #pragma omp target parallel map(da)
239   foo();
240 #pragma omp target parallel map(da[:4])
241   foo();
242 #pragma omp target data map(k, j, l) // expected-note {{used here}}
243 #pragma omp target parallel map(k[:4]) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
244   foo();
245 #pragma omp target parallel map(j)
246   foo();
247 #pragma omp target parallel map(l) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}}
248   foo();
249 #pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
250 {
251 #pragma omp target parallel map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
252   foo();
253 #pragma omp target parallel map(j)
254   foo();
255 #pragma omp target parallel map(l) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
256   foo();
257 }
258 
259 #pragma omp target parallel map(always, tofrom: x)
260   foo();
261 #pragma omp target parallel map(always: x) // expected-error {{missing map type}}
262   foo();
263 #pragma omp target parallel 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'}}
264   foo();
265 #pragma omp target parallel map(always, tofrom: always, tofrom, x)
266   foo();
267 #pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
268   foo();
269 
270   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}}
271 }
272 
273