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