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