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