xref: /aosp_15_r20/external/clang/test/OpenMP/sections_reduction_messages.cpp (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 150 -o - %s
2*67e74705SXin Li // RUN: %clang_cc1 -verify -fopenmp -std=c++98 -ferror-limit 150 -o - %s
3*67e74705SXin Li // RUN: %clang_cc1 -verify -fopenmp -std=c++11 -ferror-limit 150 -o - %s
4*67e74705SXin Li 
foo()5*67e74705SXin Li void foo() {
6*67e74705SXin Li }
7*67e74705SXin Li 
foobool(int argc)8*67e74705SXin Li bool foobool(int argc) {
9*67e74705SXin Li   return argc;
10*67e74705SXin Li }
11*67e74705SXin Li 
12*67e74705SXin Li struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
13*67e74705SXin Li extern S1 a;
14*67e74705SXin Li class S2 {
15*67e74705SXin Li   mutable int a;
operator +(const S2 & arg)16*67e74705SXin Li   S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}}
17*67e74705SXin Li 
18*67e74705SXin Li public:
S2()19*67e74705SXin Li   S2() : a(0) {}
S2(S2 & s2)20*67e74705SXin Li   S2(S2 &s2) : a(s2.a) {}
21*67e74705SXin Li   static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
22*67e74705SXin Li   static const float S2sc;
23*67e74705SXin Li };
24*67e74705SXin Li const float S2::S2sc = 0; // expected-note 2 {{'S2sc' defined here}}
25*67e74705SXin Li S2 b;                     // expected-note 3 {{'b' defined here}}
26*67e74705SXin Li const S2 ba[5];           // expected-note 2 {{'ba' defined here}}
27*67e74705SXin Li class S3 {
28*67e74705SXin Li   int a;
29*67e74705SXin Li 
30*67e74705SXin Li public:
31*67e74705SXin Li   int b;
S3()32*67e74705SXin Li   S3() : a(0) {}
S3(const S3 & s3)33*67e74705SXin Li   S3(const S3 &s3) : a(s3.a) {}
operator +(const S3 & arg1)34*67e74705SXin Li   S3 operator+(const S3 &arg1) { return arg1; }
35*67e74705SXin Li };
operator +(const S3 & arg1,const S3 & arg2)36*67e74705SXin Li int operator+(const S3 &arg1, const S3 &arg2) { return 5; }
37*67e74705SXin Li S3 c;               // expected-note 3 {{'c' defined here}}
38*67e74705SXin Li const S3 ca[5];     // expected-note 2 {{'ca' defined here}}
39*67e74705SXin Li extern const int f; // expected-note 4 {{'f' declared here}}
40*67e74705SXin Li class S4 {
41*67e74705SXin Li   int a;
42*67e74705SXin Li   S4(); // expected-note {{implicitly declared private here}}
43*67e74705SXin Li   S4(const S4 &s4);
operator +(const S4 & arg)44*67e74705SXin Li   S4 &operator+(const S4 &arg) { return (*this); }
45*67e74705SXin Li 
46*67e74705SXin Li public:
S4(int v)47*67e74705SXin Li   S4(int v) : a(v) {}
48*67e74705SXin Li };
operator &=(S4 & arg1,S4 & arg2)49*67e74705SXin Li S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
50*67e74705SXin Li class S5 {
51*67e74705SXin Li   int a;
S5()52*67e74705SXin Li   S5() : a(0) {} // expected-note {{implicitly declared private here}}
S5(const S5 & s5)53*67e74705SXin Li   S5(const S5 &s5) : a(s5.a) {}
54*67e74705SXin Li   S5 &operator+(const S5 &arg);
55*67e74705SXin Li 
56*67e74705SXin Li public:
S5(int v)57*67e74705SXin Li   S5(int v) : a(v) {}
58*67e74705SXin Li };
59*67e74705SXin Li class S6 { // expected-note 3 {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'int' to 'const S6' for 1st argument}}
60*67e74705SXin Li #if __cplusplus >= 201103L // C++11 or later
61*67e74705SXin Li // expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}
62*67e74705SXin Li #endif
63*67e74705SXin Li   int a;
64*67e74705SXin Li 
65*67e74705SXin Li public:
S6()66*67e74705SXin Li   S6() : a(6) {}
operator int()67*67e74705SXin Li   operator int() { return 6; }
68*67e74705SXin Li } o;
69*67e74705SXin Li 
70*67e74705SXin Li S3 h, k;
71*67e74705SXin Li #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
72*67e74705SXin Li 
73*67e74705SXin Li template <class T>       // expected-note {{declared here}}
tmain(T argc)74*67e74705SXin Li T tmain(T argc) {
75*67e74705SXin Li   const T d = T();       // expected-note 4 {{'d' defined here}}
76*67e74705SXin Li   const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
77*67e74705SXin Li   T qa[5] = {T()};
78*67e74705SXin Li   T i;
79*67e74705SXin Li   T &j = i;                // expected-note 4 {{'j' defined here}}
80*67e74705SXin Li   S3 &p = k;               // expected-note 2 {{'p' defined here}}
81*67e74705SXin Li   const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}}
82*67e74705SXin Li   T &q = qa[(int)i];       // expected-note 2 {{'q' defined here}}
83*67e74705SXin Li   T fl;
84*67e74705SXin Li #pragma omp parallel
85*67e74705SXin Li #pragma omp sections reduction // expected-error {{expected '(' after 'reduction'}}
86*67e74705SXin Li   {
87*67e74705SXin Li     foo();
88*67e74705SXin Li   }
89*67e74705SXin Li #pragma omp parallel
90*67e74705SXin Li #pragma omp sections reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp sections' are ignored}}
91*67e74705SXin Li   {
92*67e74705SXin Li     foo();
93*67e74705SXin Li   }
94*67e74705SXin Li #pragma omp parallel
95*67e74705SXin Li #pragma omp sections reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
96*67e74705SXin Li   {
97*67e74705SXin Li     foo();
98*67e74705SXin Li   }
99*67e74705SXin Li #pragma omp parallel
100*67e74705SXin Li #pragma omp sections reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
101*67e74705SXin Li   {
102*67e74705SXin Li     foo();
103*67e74705SXin Li   }
104*67e74705SXin Li #pragma omp parallel
105*67e74705SXin Li #pragma omp sections reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
106*67e74705SXin Li   {
107*67e74705SXin Li     foo();
108*67e74705SXin Li   }
109*67e74705SXin Li #pragma omp parallel
110*67e74705SXin Li #pragma omp sections reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
111*67e74705SXin Li   {
112*67e74705SXin Li     foo();
113*67e74705SXin Li   }
114*67e74705SXin Li #pragma omp parallel
115*67e74705SXin Li #pragma omp sections reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
116*67e74705SXin Li   {
117*67e74705SXin Li     foo();
118*67e74705SXin Li   }
119*67e74705SXin Li #pragma omp parallel
120*67e74705SXin Li #pragma omp sections reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
121*67e74705SXin Li   {
122*67e74705SXin Li     foo();
123*67e74705SXin Li   }
124*67e74705SXin Li #pragma omp parallel
125*67e74705SXin Li #pragma omp sections reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
126*67e74705SXin Li   {
127*67e74705SXin Li     foo();
128*67e74705SXin Li   }
129*67e74705SXin Li #pragma omp parallel
130*67e74705SXin Li #pragma omp sections reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
131*67e74705SXin Li   {
132*67e74705SXin Li     foo();
133*67e74705SXin Li   }
134*67e74705SXin Li #pragma omp parallel
135*67e74705SXin Li #pragma omp sections reduction(foo : argc) //expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'float'}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 'int'}}
136*67e74705SXin Li   {
137*67e74705SXin Li     foo();
138*67e74705SXin Li   }
139*67e74705SXin Li #pragma omp parallel
140*67e74705SXin Li #pragma omp sections reduction(&& : argc)
141*67e74705SXin Li   {
142*67e74705SXin Li     foo();
143*67e74705SXin Li   }
144*67e74705SXin Li #pragma omp parallel
145*67e74705SXin Li #pragma omp sections reduction(^ : T) // expected-error {{'T' does not refer to a value}}
146*67e74705SXin Li   {
147*67e74705SXin Li     foo();
148*67e74705SXin Li   }
149*67e74705SXin Li #pragma omp parallel
150*67e74705SXin Li #pragma omp sections reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 3 {{const-qualified list item cannot be reduction}} expected-error 2 {{'operator+' is a private member of 'S2'}}
151*67e74705SXin Li   {
152*67e74705SXin Li     foo();
153*67e74705SXin Li   }
154*67e74705SXin Li #pragma omp parallel
155*67e74705SXin Li #pragma omp sections reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 4 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 3 {{const-qualified list item cannot be reduction}}
156*67e74705SXin Li   {
157*67e74705SXin Li     foo();
158*67e74705SXin Li   }
159*67e74705SXin Li #pragma omp parallel
160*67e74705SXin Li #pragma omp sections reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
161*67e74705SXin Li   {
162*67e74705SXin Li     foo();
163*67e74705SXin Li   }
164*67e74705SXin Li #pragma omp parallel
165*67e74705SXin Li #pragma omp sections reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
166*67e74705SXin Li   {
167*67e74705SXin Li     foo();
168*67e74705SXin Li   }
169*67e74705SXin Li #pragma omp parallel
170*67e74705SXin Li #pragma omp sections reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
171*67e74705SXin Li   {
172*67e74705SXin Li     foo();
173*67e74705SXin Li   }
174*67e74705SXin Li #pragma omp parallel
175*67e74705SXin Li #pragma omp sections reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}}
176*67e74705SXin Li   {
177*67e74705SXin Li     foo();
178*67e74705SXin Li   }
179*67e74705SXin Li #pragma omp parallel
180*67e74705SXin Li #pragma omp sections reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
181*67e74705SXin Li   {
182*67e74705SXin Li     foo();
183*67e74705SXin Li   }
184*67e74705SXin Li #pragma omp parallel
185*67e74705SXin Li #pragma omp sections reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
186*67e74705SXin Li   {
187*67e74705SXin Li     foo();
188*67e74705SXin Li   }
189*67e74705SXin Li #pragma omp parallel
190*67e74705SXin Li #pragma omp sections reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
191*67e74705SXin Li   {
192*67e74705SXin Li     foo();
193*67e74705SXin Li   }
194*67e74705SXin Li #pragma omp parallel
195*67e74705SXin Li #pragma omp sections reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
196*67e74705SXin Li   {
197*67e74705SXin Li     foo();
198*67e74705SXin Li   }
199*67e74705SXin Li #pragma omp parallel
200*67e74705SXin Li #pragma omp sections reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
201*67e74705SXin Li   {
202*67e74705SXin Li     foo();
203*67e74705SXin Li   }
204*67e74705SXin Li #pragma omp parallel
205*67e74705SXin Li #pragma omp sections private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
206*67e74705SXin Li   {
207*67e74705SXin Li     foo();
208*67e74705SXin Li   }
209*67e74705SXin Li #pragma omp parallel private(k)
210*67e74705SXin Li #pragma omp sections reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
211*67e74705SXin Li   {
212*67e74705SXin Li     foo();
213*67e74705SXin Li   }
214*67e74705SXin Li #pragma omp parallel
215*67e74705SXin Li #pragma omp sections reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}}
216*67e74705SXin Li   {
217*67e74705SXin Li     foo();
218*67e74705SXin Li   }
219*67e74705SXin Li #pragma omp parallel
220*67e74705SXin Li #pragma omp sections reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}}
221*67e74705SXin Li   {
222*67e74705SXin Li     foo();
223*67e74705SXin Li   }
224*67e74705SXin Li #pragma omp parallel shared(i)
225*67e74705SXin Li #pragma omp parallel reduction(min : i)
226*67e74705SXin Li #pragma omp sections reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
227*67e74705SXin Li   {
228*67e74705SXin Li     foo();
229*67e74705SXin Li   }
230*67e74705SXin Li #pragma omp parallel private(fl)       // expected-note 2 {{defined as private}}
231*67e74705SXin Li #pragma omp sections reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}}
232*67e74705SXin Li   {
233*67e74705SXin Li     foo();
234*67e74705SXin Li   }
235*67e74705SXin Li #pragma omp parallel reduction(* : fl) // expected-note 2 {{defined as reduction}}
236*67e74705SXin Li #pragma omp sections reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}}
237*67e74705SXin Li   {
238*67e74705SXin Li     foo();
239*67e74705SXin Li   }
240*67e74705SXin Li 
241*67e74705SXin Li   return T();
242*67e74705SXin Li }
243*67e74705SXin Li 
244*67e74705SXin Li namespace A {
245*67e74705SXin Li double x;
246*67e74705SXin Li #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
247*67e74705SXin Li }
248*67e74705SXin Li namespace B {
249*67e74705SXin Li using A::x;
250*67e74705SXin Li }
251*67e74705SXin Li 
main(int argc,char ** argv)252*67e74705SXin Li int main(int argc, char **argv) {
253*67e74705SXin Li   const int d = 5;       // expected-note 2 {{'d' defined here}}
254*67e74705SXin Li   const int da[5] = {0}; // expected-note {{'da' defined here}}
255*67e74705SXin Li   int qa[5] = {0};
256*67e74705SXin Li   S4 e(4);
257*67e74705SXin Li   S5 g(5);
258*67e74705SXin Li   int i;
259*67e74705SXin Li   int &j = i;           // expected-note 2 {{'j' defined here}}
260*67e74705SXin Li   S3 &p = k;            // expected-note 2 {{'p' defined here}}
261*67e74705SXin Li   const int &r = da[i]; // expected-note {{'r' defined here}}
262*67e74705SXin Li   int &q = qa[i];       // expected-note {{'q' defined here}}
263*67e74705SXin Li   float fl;
264*67e74705SXin Li #pragma omp parallel
265*67e74705SXin Li #pragma omp sections reduction // expected-error {{expected '(' after 'reduction'}}
266*67e74705SXin Li   {
267*67e74705SXin Li     foo();
268*67e74705SXin Li   }
269*67e74705SXin Li #pragma omp parallel
270*67e74705SXin Li #pragma omp sections reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp sections' are ignored}}
271*67e74705SXin Li   {
272*67e74705SXin Li     foo();
273*67e74705SXin Li   }
274*67e74705SXin Li #pragma omp parallel
275*67e74705SXin Li #pragma omp sections reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
276*67e74705SXin Li   {
277*67e74705SXin Li     foo();
278*67e74705SXin Li   }
279*67e74705SXin Li #pragma omp parallel
280*67e74705SXin Li #pragma omp sections reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
281*67e74705SXin Li   {
282*67e74705SXin Li     foo();
283*67e74705SXin Li   }
284*67e74705SXin Li #pragma omp parallel
285*67e74705SXin Li #pragma omp sections reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
286*67e74705SXin Li   {
287*67e74705SXin Li     foo();
288*67e74705SXin Li   }
289*67e74705SXin Li #pragma omp parallel
290*67e74705SXin Li #pragma omp sections reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
291*67e74705SXin Li   {
292*67e74705SXin Li     foo();
293*67e74705SXin Li   }
294*67e74705SXin Li #pragma omp parallel
295*67e74705SXin Li #pragma omp sections reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
296*67e74705SXin Li   {
297*67e74705SXin Li     foo();
298*67e74705SXin Li   }
299*67e74705SXin Li #pragma omp parallel
300*67e74705SXin Li #pragma omp sections reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
301*67e74705SXin Li   {
302*67e74705SXin Li     foo();
303*67e74705SXin Li   }
304*67e74705SXin Li #pragma omp parallel
305*67e74705SXin Li #pragma omp sections reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
306*67e74705SXin Li   {
307*67e74705SXin Li     foo();
308*67e74705SXin Li   }
309*67e74705SXin Li #pragma omp parallel
310*67e74705SXin Li #pragma omp sections reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
311*67e74705SXin Li   {
312*67e74705SXin Li     foo();
313*67e74705SXin Li   }
314*67e74705SXin Li #pragma omp parallel
315*67e74705SXin Li #pragma omp sections reduction(~ : argc) // expected-error {{expected unqualified-id}}
316*67e74705SXin Li   {
317*67e74705SXin Li     foo();
318*67e74705SXin Li   }
319*67e74705SXin Li #pragma omp parallel
320*67e74705SXin Li #pragma omp sections reduction(&& : argc)
321*67e74705SXin Li   {
322*67e74705SXin Li     foo();
323*67e74705SXin Li   }
324*67e74705SXin Li #pragma omp parallel
325*67e74705SXin Li #pragma omp sections reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
326*67e74705SXin Li   {
327*67e74705SXin Li     foo();
328*67e74705SXin Li   }
329*67e74705SXin Li #pragma omp parallel
330*67e74705SXin Li #pragma omp sections reduction(+ : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{const-qualified list item cannot be reduction}} expected-error {{'operator+' is a private member of 'S2'}}
331*67e74705SXin Li   {
332*67e74705SXin Li     foo();
333*67e74705SXin Li   }
334*67e74705SXin Li #pragma omp parallel
335*67e74705SXin Li #pragma omp sections reduction(min : a, b, c, d, f) // expected-error {{a reduction list item with incomplete type 'S1'}} expected-error 2 {{arguments of OpenMP clause 'reduction' for 'min' or 'max' must be of arithmetic type}} expected-error 2 {{const-qualified list item cannot be reduction}}
336*67e74705SXin Li   {
337*67e74705SXin Li     foo();
338*67e74705SXin Li   }
339*67e74705SXin Li #pragma omp parallel
340*67e74705SXin Li #pragma omp sections reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
341*67e74705SXin Li   {
342*67e74705SXin Li     foo();
343*67e74705SXin Li   }
344*67e74705SXin Li #pragma omp parallel
345*67e74705SXin Li #pragma omp sections reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
346*67e74705SXin Li   {
347*67e74705SXin Li     foo();
348*67e74705SXin Li   }
349*67e74705SXin Li #pragma omp parallel
350*67e74705SXin Li #pragma omp sections reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
351*67e74705SXin Li   {
352*67e74705SXin Li     foo();
353*67e74705SXin Li   }
354*67e74705SXin Li #pragma omp parallel
355*67e74705SXin Li #pragma omp sections reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}}
356*67e74705SXin Li   {
357*67e74705SXin Li     foo();
358*67e74705SXin Li   }
359*67e74705SXin Li #pragma omp parallel
360*67e74705SXin Li #pragma omp sections reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
361*67e74705SXin Li   {
362*67e74705SXin Li     foo();
363*67e74705SXin Li   }
364*67e74705SXin Li #pragma omp parallel
365*67e74705SXin Li #pragma omp sections reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
366*67e74705SXin Li   {
367*67e74705SXin Li     foo();
368*67e74705SXin Li   }
369*67e74705SXin Li #pragma omp parallel
370*67e74705SXin Li #pragma omp sections reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
371*67e74705SXin Li   {
372*67e74705SXin Li     foo();
373*67e74705SXin Li   }
374*67e74705SXin Li #pragma omp parallel
375*67e74705SXin Li #pragma omp sections reduction(& : e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{invalid operands to binary expression ('S4' and 'S4')}} expected-error {{calling a private constructor of class 'S5'}} expected-error {{invalid operands to binary expression ('S5' and 'S5')}}
376*67e74705SXin Li   {
377*67e74705SXin Li     foo();
378*67e74705SXin Li   }
379*67e74705SXin Li #pragma omp parallel
380*67e74705SXin Li #pragma omp sections reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
381*67e74705SXin Li   {
382*67e74705SXin Li     foo();
383*67e74705SXin Li   }
384*67e74705SXin Li #pragma omp parallel
385*67e74705SXin Li #pragma omp sections reduction(+ : o) // expected-error {{no viable overloaded '='}}
386*67e74705SXin Li   {
387*67e74705SXin Li     foo();
388*67e74705SXin Li   }
389*67e74705SXin Li #pragma omp parallel
390*67e74705SXin Li #pragma omp sections private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
391*67e74705SXin Li   {
392*67e74705SXin Li     foo();
393*67e74705SXin Li   }
394*67e74705SXin Li #pragma omp parallel private(k)
395*67e74705SXin Li #pragma omp sections reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
396*67e74705SXin Li   {
397*67e74705SXin Li     foo();
398*67e74705SXin Li   }
399*67e74705SXin Li #pragma omp parallel
400*67e74705SXin Li #pragma omp sections reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
401*67e74705SXin Li   {
402*67e74705SXin Li     foo();
403*67e74705SXin Li   }
404*67e74705SXin Li #pragma omp parallel
405*67e74705SXin Li #pragma omp sections reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}}
406*67e74705SXin Li   {
407*67e74705SXin Li     foo();
408*67e74705SXin Li   }
409*67e74705SXin Li #pragma omp parallel shared(i)
410*67e74705SXin Li #pragma omp parallel reduction(min : i)
411*67e74705SXin Li #pragma omp sections reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
412*67e74705SXin Li   {
413*67e74705SXin Li     foo();
414*67e74705SXin Li   }
415*67e74705SXin Li #pragma omp parallel private(fl)       // expected-note {{defined as private}}
416*67e74705SXin Li #pragma omp sections reduction(+ : fl) // expected-error {{reduction variable must be shared}}
417*67e74705SXin Li   {
418*67e74705SXin Li     foo();
419*67e74705SXin Li   }
420*67e74705SXin Li #pragma omp parallel reduction(* : fl) // expected-note {{defined as reduction}}
421*67e74705SXin Li #pragma omp sections reduction(+ : fl) // expected-error {{reduction variable must be shared}}
422*67e74705SXin Li   {
423*67e74705SXin Li     foo();
424*67e74705SXin Li   }
425*67e74705SXin Li   static int m;
426*67e74705SXin Li #pragma omp sections reduction(+ : m) // OK
427*67e74705SXin Li   {
428*67e74705SXin Li     foo();
429*67e74705SXin Li   }
430*67e74705SXin Li 
431*67e74705SXin Li   return tmain(argc) + tmain(fl); // expected-note {{in instantiation of function template specialization 'tmain<int>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<float>' requested here}}
432*67e74705SXin Li }
433