Debian Codegraph @

clang/test/OpenMP/parallel_for_reduction_messages.cpp

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