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