• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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}} expected-note 2 {{forward declaration of 'S1'}}
11 extern S1 a;
12 class S2 {
13   mutable int a;
14 
15 public:
S2()16   S2() : a(0) {}
S2(S2 & s2)17   S2(S2 &s2) : a(s2.a) {}
18   const S2 &operator =(const S2&) const;
19   S2 &operator =(const S2&);
20   static float S2s; // expected-note {{static data member is predetermined as shared}}
21   static const float S2sc;
22 };
23 const float S2::S2sc = 0; // expected-note {{static data member is predetermined as shared}}
24 const S2 b;
25 const S2 ba[5];
26 class S3 {
27   int a;
28   S3 &operator=(const S3 &s3); // expected-note 2 {{implicitly declared private here}}
29 
30 public:
S3()31   S3() : a(0) {}
S3(S3 & s3)32   S3(S3 &s3) : a(s3.a) {}
33 };
34 const S3 c;         // expected-note {{global variable is predetermined as shared}}
35 const S3 ca[5];     // expected-note {{global variable is predetermined as shared}}
36 extern const int f; // expected-note {{global variable is predetermined as shared}}
37 class S4 {
38   int a;
39   S4();             // expected-note 3 {{implicitly declared private here}}
40   S4(const S4 &s4);
41 
42 public:
S4(int v)43   S4(int v) : a(v) {}
44 };
45 class S5 {
46   int a;
S5()47   S5() : a(0) {} // expected-note {{implicitly declared private here}}
48 
49 public:
S5(const S5 & s5)50   S5(const S5 &s5) : a(s5.a) {}
S5(int v)51   S5(int v) : a(v) {}
52 };
53 class S6 {
54   int a;
S6()55   S6() : a(0) {}
56 
57 public:
S6(const S6 & s6)58   S6(const S6 &s6) : a(s6.a) {}
S6(int v)59   S6(int v) : a(v) {}
60 };
61 
62 S3 h;
63 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
64 
65 template <class I, class C>
foomain(int argc,char ** argv)66 int foomain(int argc, char **argv) {
67   I e(4);
68   I g(5);
69   int i;
70   int &j = i;
71 #pragma omp target
72 #pragma omp teams
73 #pragma omp distribute parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
74   for (int k = 0; k < argc; ++k)
75     ++k;
76 #pragma omp target
77 #pragma omp teams
78 #pragma omp distribute parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
79   for (int k = 0; k < argc; ++k)
80     ++k;
81 #pragma omp target
82 #pragma omp teams
83 #pragma omp distribute parallel for lastprivate() // expected-error {{expected expression}}
84   for (int k = 0; k < argc; ++k)
85     ++k;
86 #pragma omp target
87 #pragma omp teams
88 #pragma omp distribute parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
89   for (int k = 0; k < argc; ++k)
90     ++k;
91 #pragma omp target
92 #pragma omp teams
93 #pragma omp distribute parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
94   for (int k = 0; k < argc; ++k)
95     ++k;
96 #pragma omp target
97 #pragma omp teams
98 #pragma omp distribute parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
99   for (int k = 0; k < argc; ++k)
100     ++k;
101 #pragma omp target
102 #pragma omp teams
103 #pragma omp distribute parallel for lastprivate(argc)
104   for (int k = 0; k < argc; ++k)
105     ++k;
106 #pragma omp target
107 #pragma omp teams
108 #pragma omp distribute parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
109   for (int k = 0; k < argc; ++k)
110     ++k;
111 #pragma omp target
112 #pragma omp teams
113 #pragma omp distribute parallel for lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}}
114   for (int k = 0; k < argc; ++k)
115     ++k;
116 #pragma omp target
117 #pragma omp teams
118 #pragma omp distribute parallel for lastprivate(argv[1]) // expected-error {{expected variable name}}
119   for (int k = 0; k < argc; ++k)
120     ++k;
121 #pragma omp target
122 #pragma omp teams
123 #pragma omp distribute parallel for lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}}
124   for (int k = 0; k < argc; ++k)
125     ++k;
126 #pragma omp target
127 #pragma omp teams
128 #pragma omp distribute parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
129   for (int k = 0; k < argc; ++k)
130     ++k;
131 
132   int v = 0;
133 #pragma omp target
134 #pragma omp teams
135   {
136 #pragma omp distribute parallel for lastprivate(i)
137     for (int k = 0; k < argc; ++k) {
138       i = k;
139       v += i;
140     }
141   }
142 #pragma omp target
143 #pragma omp teams private(i)
144 #pragma omp distribute parallel for lastprivate(j)
145   for (int k = 0; k < argc; ++k)
146     ++k;
147 #pragma omp target
148 #pragma omp teams
149 #pragma omp distribute parallel for lastprivate(i)
150   for (int k = 0; k < argc; ++k)
151     ++k;
152   return 0;
153 }
154 
bar(S4 a[2])155 void bar(S4 a[2]) {
156 #pragma omp target
157 #pragma omp teams
158 #pragma omp distribute parallel for lastprivate(a)
159   for (int i = 0; i < 2; ++i)
160     foo();
161 }
162 
163 namespace A {
164 double x;
165 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
166 }
167 namespace B {
168 using A::x;
169 }
170 
main(int argc,char ** argv)171 int main(int argc, char **argv) {
172   const int d = 5;       // expected-note {{constant variable is predetermined as shared}}
173   const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}}
174   S4 e(4);
175   S5 g(5);
176   S3 m;
177   S6 n(2);
178   int i;
179   int &j = i;
180 #pragma omp target
181 #pragma omp teams
182 #pragma omp distribute parallel for lastprivate // expected-error {{expected '(' after 'lastprivate'}}
183   for (i = 0; i < argc; ++i)
184     foo();
185 #pragma omp target
186 #pragma omp teams
187 #pragma omp distribute parallel for lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
188   for (i = 0; i < argc; ++i)
189     foo();
190 #pragma omp target
191 #pragma omp teams
192 #pragma omp distribute parallel for lastprivate() // expected-error {{expected expression}}
193   for (i = 0; i < argc; ++i)
194     foo();
195 #pragma omp target
196 #pragma omp teams
197 #pragma omp distribute parallel for lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
198   for (i = 0; i < argc; ++i)
199     foo();
200 #pragma omp target
201 #pragma omp teams
202 #pragma omp distribute parallel for lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
203   for (i = 0; i < argc; ++i)
204     foo();
205 #pragma omp target
206 #pragma omp teams
207 #pragma omp distribute parallel for lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
208   for (i = 0; i < argc; ++i)
209     foo();
210 #pragma omp target
211 #pragma omp teams
212 #pragma omp distribute parallel for lastprivate(argc)
213   for (i = 0; i < argc; ++i)
214     foo();
215 #pragma omp target
216 #pragma omp teams
217 #pragma omp distribute parallel for lastprivate(S1) // expected-error {{'S1' does not refer to a value}}
218   for (i = 0; i < argc; ++i)
219     foo();
220 #pragma omp target
221 #pragma omp teams
222 #pragma omp distribute parallel for lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}}
223   for (i = 0; i < argc; ++i)
224     foo();
225 #pragma omp target
226 #pragma omp teams
227 #pragma omp distribute parallel for lastprivate(argv[1]) // expected-error {{expected variable name}}
228   for (i = 0; i < argc; ++i)
229     foo();
230 #pragma omp target
231 #pragma omp teams
232 #pragma omp distribute parallel for lastprivate(2 * 2) // expected-error {{expected variable name}}
233   for (i = 0; i < argc; ++i)
234     foo();
235 #pragma omp target
236 #pragma omp teams
237 #pragma omp distribute parallel for lastprivate(ba)
238   for (i = 0; i < argc; ++i)
239     foo();
240 #pragma omp target
241 #pragma omp teams
242 #pragma omp distribute parallel for lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}}
243   for (i = 0; i < argc; ++i)
244     foo();
245 #pragma omp target
246 #pragma omp teams
247 #pragma omp distribute parallel for lastprivate(da) // expected-error {{shared variable cannot be lastprivate}}
248   for (i = 0; i < argc; ++i)
249     foo();
250   int xa;
251 #pragma omp target
252 #pragma omp teams
253 #pragma omp distribute parallel for lastprivate(xa) // OK
254   for (i = 0; i < argc; ++i)
255     foo();
256 #pragma omp target
257 #pragma omp teams
258 #pragma omp distribute parallel for lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}}
259   for (i = 0; i < argc; ++i)
260     foo();
261 #pragma omp target
262 #pragma omp teams
263 #pragma omp distribute parallel for lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}}
264   for (i = 0; i < argc; ++i)
265     foo();
266 #pragma omp target
267 #pragma omp teams
268 #pragma omp distribute parallel for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp distribute parallel for'}}
269   for (i = 0; i < argc; ++i)
270     foo();
271 #pragma omp target
272 #pragma omp teams
273 #pragma omp distribute parallel for lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
274   for (i = 0; i < argc; ++i)
275     foo();
276 #pragma omp target
277 #pragma omp teams
278 #pragma omp distribute parallel for lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
279   for (i = 0; i < argc; ++i)
280     foo();
281 #pragma omp target
282 #pragma omp teams
283 #pragma omp distribute parallel for lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
284   for (i = 0; i < argc; ++i)
285     foo();
286 #pragma omp target
287 #pragma omp teams
288 #pragma omp distribute parallel for lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}}
289   for (i = 0; i < argc; ++i)
290     foo();
291 #pragma omp target
292 #pragma omp teams
293 #pragma omp distribute parallel for private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}}
294   for (i = 0; i < argc; ++i)
295     foo();
296 #pragma omp target
297 #pragma omp teams
298 #pragma omp distribute parallel for lastprivate(i)
299   for (i = 0; i < argc; ++i)
300     foo();
301 #pragma omp target
302 #pragma omp teams
303 #pragma omp distribute parallel for lastprivate(xa)
304   for (i = 0; i < argc; ++i)
305     foo();
306 #pragma omp target
307 #pragma omp teams
308 #pragma omp distribute parallel for lastprivate(xa)
309   for (i = 0; i < argc; ++i)
310     foo();
311 #pragma omp target
312 #pragma omp teams
313 #pragma omp distribute parallel for lastprivate(j)
314   for (i = 0; i < argc; ++i)
315     foo();
316 #pragma omp target
317 #pragma omp teams
318 #pragma omp distribute parallel for firstprivate(m) lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}}
319   for (i = 0; i < argc; ++i)
320     foo();
321 #pragma omp target
322 #pragma omp teams
323 #pragma omp distribute parallel for lastprivate(n) firstprivate(n) // OK
324   for (i = 0; i < argc; ++i)
325     foo();
326   static int si;
327 #pragma omp target
328 #pragma omp teams
329 #pragma omp distribute parallel for lastprivate(si) // OK
330   for (i = 0; i < argc; ++i)
331     si = i + 1;
332   return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
333 }
334