blob: d99d2e42d762b1ca8a34d6b89e281ba814c687cf [file] [log] [blame]
Alexey Bataevfa312f32017-07-21 18:48:21 +00001// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 150 -o - %s
2// RUN: %clang_cc1 -verify -fopenmp -std=c++98 -ferror-limit 150 -o - %s
3// RUN: %clang_cc1 -verify -fopenmp -std=c++11 -ferror-limit 150 -o - %s
4
Alexey Bataeva8a9153a2017-12-29 18:07:07 +00005// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 150 -o - %s
6// RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 -ferror-limit 150 -o - %s
7// RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 -ferror-limit 150 -o - %s
8// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
9
Alexey Bataevfa312f32017-07-21 18:48:21 +000010void foo() {
11}
12
13bool foobool(int argc) {
14 return argc;
15}
16
17void foobar(int &ref) {
18#pragma omp taskgroup task_reduction(+:ref)
19#pragma omp task in_reduction(+:ref)
20 foo();
21}
22
23void foobar1(int &ref) {
24#pragma omp taskgroup task_reduction(+:ref)
25#pragma omp task in_reduction(-:ref)
26 foo();
27}
28
29#pragma omp declare reduction (red:int:omp_out += omp_in)
30
31void foobar2(int &ref) {
32#pragma omp taskgroup task_reduction(+:ref) // expected-note {{previously marked as task_reduction with different reduction operation}}
33#pragma omp task in_reduction(red:ref) // expected-error{{in_reduction variable must have the same reduction operation as in a task_reduction clause}}
34 foo();
35}
36
37void foobar3(int &ref) {
38#pragma omp taskgroup task_reduction(red:ref) // expected-note {{previously marked as task_reduction with different reduction operation}}
39#pragma omp task in_reduction(min:ref) // expected-error{{in_reduction variable must have the same reduction operation as in a task_reduction clause}}
40 foo();
41}
42
43void foobar4(int &ref) {
44#pragma omp task in_reduction(min:ref) // expected-error {{in_reduction variable must appear in a task_reduction clause}}
45 foo();
46}
47
48struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
49extern S1 a;
50class S2 {
51 mutable int a;
52 S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}}
53
54public:
55 S2() : a(0) {}
56 S2(S2 &s2) : a(s2.a) {}
57 static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
58 static const float S2sc; // expected-note 2 {{'S2sc' declared here}}
59};
60const float S2::S2sc = 0;
61S2 b; // expected-note 3 {{'b' defined here}}
62const S2 ba[5]; // expected-note 2 {{'ba' defined here}}
63class S3 {
64 int a;
65
66public:
67 int b;
68 S3() : a(0) {}
69 S3(const S3 &s3) : a(s3.a) {}
70 S3 operator+(const S3 &arg1) { return arg1; }
71};
72int operator+(const S3 &arg1, const S3 &arg2) { return 5; }
73S3 c; // expected-note 3 {{'c' defined here}}
74const S3 ca[5]; // expected-note 2 {{'ca' defined here}}
75extern const int f; // expected-note 4 {{'f' declared here}}
76class S4 {
77 int a;
78 S4(); // expected-note {{implicitly declared private here}}
79 S4(const S4 &s4);
80 S4 &operator+(const S4 &arg) { return (*this); }
81
82public:
83 S4(int v) : a(v) {}
84};
85S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
86class S5 {
87 int a;
88 S5() : a(0) {} // expected-note {{implicitly declared private here}}
89 S5(const S5 &s5) : a(s5.a) {}
90 S5 &operator+(const S5 &arg);
91
92public:
93 S5(int v) : a(v) {}
94};
95class S6 { // expected-note 3 {{candidate function (the implicit copy assignment operator) not viable: no known conversion from 'int' to 'const S6' for 1st argument}}
96#if __cplusplus >= 201103L // C++11 or later
97// expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}
98#endif
99 int a;
100
101public:
102 S6() : a(6) {}
103 operator int() { return 6; }
104} o;
105
106S3 h, k;
107#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
108
109template <class T> // expected-note {{declared here}}
110T tmain(T argc) {
111 const T d = T(); // expected-note 4 {{'d' defined here}}
112 const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
113 T qa[5] = {T()};
114 T i;
115 T &j = i; // expected-note 2 {{'j' defined here}}
116 S3 &p = k; // expected-note 2 {{'p' defined here}}
117 const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}}
118 T &q = qa[(int)i];
119 T fl;
120#pragma omp taskgroup task_reduction(+:argc)
121#pragma omp task in_reduction // expected-error {{expected '(' after 'in_reduction'}}
122 foo();
123#pragma omp taskgroup task_reduction(+:argc)
124#pragma omp task in_reduction + // expected-error {{expected '(' after 'in_reduction'}} expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
125 foo();
126#pragma omp taskgroup task_reduction(+:argc)
127#pragma omp task in_reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
128 foo();
129#pragma omp taskgroup task_reduction(+:argc)
130#pragma omp task in_reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
131 foo();
132#pragma omp taskgroup task_reduction(+:argc)
133#pragma omp task in_reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
134 foo();
135#pragma omp taskgroup task_reduction(+:argc)
136#pragma omp task in_reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}}
137 foo();
138#pragma omp taskgroup task_reduction(+:argc)
139#pragma omp task in_reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
140 foo();
141#pragma omp taskgroup task_reduction(&:argc) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
142#pragma omp task in_reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
143 foo();
144#pragma omp taskgroup task_reduction(|:argc) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
145#pragma omp task 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')}}
146 foo();
147#pragma omp task in_reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
148 foo();
149#pragma omp task 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'}}
150 foo();
151#pragma omp taskgroup task_reduction(&&:argc)
152#pragma omp task in_reduction(&& : argc)
153 foo();
154#pragma omp task in_reduction(^ : T) // expected-error {{'T' does not refer to a value}}
155 foo();
156#pragma omp taskgroup task_reduction(+:c)
157#pragma omp task in_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'}} expected-error 2 {{in_reduction variable must appear in a task_reduction clause}}
158 foo();
159#pragma omp task 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 list item cannot be reduction}}
160 foo();
161#pragma omp task in_reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
162 foo();
163#pragma omp task in_reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
164 foo();
165#pragma omp task in_reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
166 foo();
167#pragma omp task in_reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}}
168 foo();
169#pragma omp task in_reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}} expected-error {{in_reduction variable must appear in a task_reduction clause}}
170 foo();
171#pragma omp task in_reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
172 foo();
173#pragma omp task in_reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
174 foo();
175#pragma omp taskgroup task_reduction(+:k)
176#pragma omp task in_reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
177 foo();
178#pragma omp task in_reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
179 foo();
180#pragma omp parallel private(k)
181#pragma omp task in_reduction(+ : p), in_reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'in_reduction' must reference the same object in all threads}}
182 foo();
183#pragma omp taskgroup task_reduction(+:p)
184#pragma omp task 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}}
185 foo();
186#pragma omp task in_reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}}
187 foo();
188#pragma omp parallel shared(i)
189#pragma omp parallel reduction(min : i)
190#pragma omp task in_reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'in_reduction' must reference the same object in all threads}}
191 foo();
192#pragma omp taskgroup task_reduction(+:fl)
193#pragma omp task in_reduction(+ : fl)
194 foo();
195#pragma omp parallel
196#pragma omp for reduction(- : fl)
197 for (int i = 0; i < 10; ++i)
198#pragma omp taskgroup task_reduction(+:fl)
199#pragma omp task in_reduction(+ : fl)
200 foo();
201
202 return T();
203}
204
205namespace A {
206double x;
207#pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
208}
209namespace B {
210using A::x;
211}
212
213int main(int argc, char **argv) {
214 const int d = 5; // expected-note 2 {{'d' defined here}}
215 const int da[5] = {0}; // expected-note {{'da' defined here}}
216 int qa[5] = {0};
217 S4 e(4);
218 S5 g(5);
219 int i;
220 int &j = i; // expected-note {{'j' defined here}}
221 S3 &p = k; // expected-note 2 {{'p' defined here}}
222 const int &r = da[i]; // expected-note {{'r' defined here}}
223 int &q = qa[i];
224 float fl;
225#pragma omp task in_reduction // expected-error {{expected '(' after 'in_reduction'}}
226 foo();
227#pragma omp task in_reduction + // expected-error {{expected '(' after 'in_reduction'}} expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
228 foo();
229#pragma omp task in_reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
230 foo();
231#pragma omp task in_reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
232 foo();
233#pragma omp task in_reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
234 foo();
235#pragma omp task in_reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}}
236 foo();
237#pragma omp task in_reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
238 foo();
239#pragma omp task in_reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
240 foo();
241#pragma omp taskgroup task_reduction(|:argc)
242{
243#pragma omp taskgroup task_reduction(+:argc) // expected-note {{previously marked as task_reduction with different reduction operation}}
244{
245#pragma omp task in_reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{in_reduction variable must have the same reduction operation as in a task_reduction clause}}
246 foo();
247}
248#pragma omp task in_reduction(| : argc)
249 foo();
250}
251#pragma omp task in_reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
252 foo();
253#pragma omp task in_reduction(~ : argc) // expected-error {{expected unqualified-id}}
254 foo();
255#pragma omp taskgroup task_reduction(&&:argc)
256#pragma omp task in_reduction(&& : argc)
257 foo();
258#pragma omp task in_reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
259 foo();
260#pragma omp taskgroup task_reduction(+:c)
261#pragma omp task in_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'}} expected-error {{in_reduction variable must appear in a task_reduction clause}}
262 foo();
263#pragma omp task 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 list item cannot be reduction}}
264 foo();
265#pragma omp task in_reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
266 foo();
267#pragma omp task in_reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
268 foo();
269#pragma omp task in_reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
270 foo();
271#pragma omp task in_reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}}
272 foo();
273#pragma omp task in_reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
274 foo();
275#pragma omp task in_reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
276 foo();
277#pragma omp task in_reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
278 foo();
279#pragma omp task in_reduction(& : e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{nvalid 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')}}
280 foo();
281#pragma omp taskgroup task_reduction(+:k)
282#pragma omp task in_reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
283 foo();
284#pragma omp task in_reduction(+ : o) // expected-error {{no viable overloaded '='}}
285 foo();
286#pragma omp parallel private(k)
287#pragma omp task in_reduction(+ : p), in_reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'in_reduction' must reference the same object in all threads}}
288 foo();
289#pragma omp taskgroup task_reduction(+:p)
290#pragma omp task in_reduction(+ : p), in_reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'in_reduction' clause}} expected-note {{previously referenced here}}
291 foo();
292#pragma omp task in_reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}}
293 foo();
294#pragma omp parallel shared(i)
295#pragma omp parallel reduction(min : i)
296#pragma omp task in_reduction(max : j) // expected-error {{argument of OpenMP clause 'in_reduction' must reference the same object in all threads}}
297 foo();
298#pragma omp parallel
299#pragma omp for private(fl)
300 for (int i = 0; i < 10; ++i)
301#pragma omp taskgroup task_reduction(+:fl)
302#pragma omp task in_reduction(+ : fl)
303 foo();
304#pragma omp taskgroup task_reduction(+:fl)
305#pragma omp task in_reduction(+ : fl)
306 foo();
307 static int m;
308#pragma omp taskgroup task_reduction(+:m)
309#pragma omp task in_reduction(+ : m) // OK
310 m++;
311
312 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}}
313}