Debian Codegraph @

clang/test/OpenMP/task_in_reduction_message.cpp

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