1 // 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
5 // 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
12 bool foobool(int argc) {
16 void foobar(int &ref) {
19 #pragma omp distribute parallel for reduction(+:ref)
20 for (int i = 0; i < 10; ++i)
24 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
28 S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}}
32 S2(S2 &s2) : a(s2.a) {}
33 static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
34 static const float S2sc; // expected-note 2 {{'S2sc' declared here}}
36 const float S2::S2sc = 0;
37 S2 b; // expected-note 3 {{'b' defined here}}
38 const S2 ba[5]; // expected-note 2 {{'ba' defined here}}
45 S3(const S3 &s3) : a(s3.a) {}
46 S3 operator+(const S3 &arg1) { return arg1; }
48 int operator+(const S3 &arg1, const S3 &arg2) { return 5; }
49 S3 c; // expected-note 3 {{'c' defined here}}
50 const S3 ca[5]; // expected-note 2 {{'ca' defined here}}
51 extern const int f; // expected-note 4 {{'f' declared here}}
54 S4(); // expected-note {{implicitly declared private here}}
56 S4 &operator+(const S4 &arg) { return (*this); }
61 S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
64 S5() : a(0) {} // expected-note {{implicitly declared private here}}
65 S5(const S5 &s5) : a(s5.a) {}
66 S5 &operator+(const S5 &arg);
71 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}}
72 #if __cplusplus >= 201103L // C++11 or later
73 // expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}
79 operator int() { return 6; }
83 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
85 template <class T> // expected-note {{declared here}}
87 const T d = T(); // expected-note 4 {{'d' defined here}}
88 const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
91 T &j = i; // expected-note 4 {{'j' defined here}}
92 S3 &p = k; // expected-note 2 {{'p' defined here}}
93 const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}}
94 T &q = qa[(int)i]; // expected-note 2 {{'q' defined here}}
98 #pragma omp distribute parallel for reduction // expected-error {{expected '(' after 'reduction'}}
99 for (int i = 0; i < 10; ++i)
103 #pragma omp distribute parallel for reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
104 for (int i = 0; i < 10; ++i)
108 #pragma omp distribute parallel for reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
109 for (int i = 0; i < 10; ++i)
113 #pragma omp distribute parallel for reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
114 for (int i = 0; i < 10; ++i)
118 #pragma omp distribute parallel for reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
119 for (int i = 0; i < 10; ++i)
123 #pragma omp distribute parallel for reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
124 for (int i = 0; i < 10; ++i)
128 #pragma omp distribute parallel for reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
129 for (int i = 0; i < 10; ++i)
133 #pragma omp distribute parallel for reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
134 for (int i = 0; i < 10; ++i)
138 #pragma omp distribute 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')}}
139 for (int i = 0; i < 10; ++i)
143 #pragma omp distribute parallel for reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
144 for (int i = 0; i < 10; ++i)
148 #pragma omp distribute parallel for 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'}}
149 for (int i = 0; i < 10; ++i)
153 #pragma omp distribute parallel for reduction(&& : argc)
154 for (int i = 0; i < 10; ++i)
158 #pragma omp distribute parallel for reduction(^ : T) // expected-error {{'T' does not refer to a value}}
159 for (int i = 0; i < 10; ++i)
163 #pragma omp distribute parallel for 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'}}
164 for (int i = 0; i < 10; ++i)
168 #pragma omp distribute 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 list item cannot be reduction}}
169 for (int i = 0; i < 10; ++i)
173 #pragma omp distribute parallel for reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
174 for (int i = 0; i < 10; ++i)
178 #pragma omp distribute parallel for reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
179 for (int i = 0; i < 10; ++i)
183 #pragma omp distribute parallel for reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
184 for (int i = 0; i < 10; ++i)
188 #pragma omp distribute parallel for reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}}
189 for (int i = 0; i < 10; ++i)
193 #pragma omp distribute parallel for reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
194 for (int i = 0; i < 10; ++i)
198 #pragma omp distribute parallel for reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
199 for (int i = 0; i < 10; ++i)
203 #pragma omp distribute parallel for reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
204 for (int i = 0; i < 10; ++i)
208 #pragma omp distribute parallel for reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
209 for (int i = 0; i < 10; ++i)
213 #pragma omp distribute parallel for reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
214 for (int i = 0; i < 10; ++i)
218 #pragma omp distribute parallel for private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
219 for (int i = 0; i < 10; ++i)
221 #pragma omp parallel private(k)
224 #pragma omp distribute parallel for reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
225 for (int i = 0; i < 10; ++i)
229 #pragma omp distribute parallel for reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}}
230 for (int i = 0; i < 10; ++i)
234 #pragma omp distribute parallel for reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}}
235 for (int i = 0; i < 10; ++i)
237 #pragma omp parallel shared(i)
238 #pragma omp parallel reduction(min : i)
241 #pragma omp distribute parallel for reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
242 for (int i = 0; i < 10; ++i)
244 #pragma omp parallel private(fl)
247 #pragma omp distribute parallel for reduction(+ : fl)
248 for (int i = 0; i < 10; ++i)
250 #pragma omp parallel reduction(* : fl)
253 #pragma omp distribute parallel for reduction(+ : fl)
254 for (int i = 0; i < 10; ++i)
262 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
268 int main(int argc, char **argv) {
269 const int d = 5; // expected-note 2 {{'d' defined here}}
270 const int da[5] = {0}; // expected-note {{'da' defined here}}
275 int &j = i; // expected-note 2 {{'j' defined here}}
276 S3 &p = k; // expected-note 2 {{'p' defined here}}
277 const int &r = da[i]; // expected-note {{'r' defined here}}
278 int &q = qa[i]; // expected-note {{'q' defined here}}
282 #pragma omp distribute parallel for reduction // expected-error {{expected '(' after 'reduction'}}
283 for (int i = 0; i < 10; ++i)
287 #pragma omp distribute parallel for reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
288 for (int i = 0; i < 10; ++i)
292 #pragma omp distribute parallel for reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
293 for (int i = 0; i < 10; ++i)
297 #pragma omp distribute parallel for reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
298 for (int i = 0; i < 10; ++i)
302 #pragma omp distribute parallel for reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
303 for (int i = 0; i < 10; ++i)
307 #pragma omp distribute parallel for reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
308 for (int i = 0; i < 10; ++i)
312 #pragma omp distribute parallel for reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
313 for (int i = 0; i < 10; ++i)
317 #pragma omp distribute parallel for reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
318 for (int i = 0; i < 10; ++i)
322 #pragma omp distribute parallel for reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
323 for (int i = 0; i < 10; ++i)
327 #pragma omp distribute parallel for reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
328 for (int i = 0; i < 10; ++i)
332 #pragma omp distribute parallel for reduction(~ : argc) // expected-error {{expected unqualified-id}}
333 for (int i = 0; i < 10; ++i)
337 #pragma omp distribute parallel for reduction(&& : argc)
338 for (int i = 0; i < 10; ++i)
342 #pragma omp distribute parallel for reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
343 for (int i = 0; i < 10; ++i)
347 #pragma omp distribute parallel for 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'}}
348 for (int i = 0; i < 10; ++i)
352 #pragma omp distribute 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 list item cannot be reduction}}
353 for (int i = 0; i < 10; ++i)
357 #pragma omp distribute parallel for reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
358 for (int i = 0; i < 10; ++i)
362 #pragma omp distribute parallel for reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
363 for (int i = 0; i < 10; ++i)
367 #pragma omp distribute parallel for reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
368 for (int i = 0; i < 10; ++i)
372 #pragma omp distribute parallel for reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}}
373 for (int i = 0; i < 10; ++i)
377 #pragma omp distribute parallel for reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
378 for (int i = 0; i < 10; ++i)
382 #pragma omp distribute parallel for reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
383 for (int i = 0; i < 10; ++i)
387 #pragma omp distribute parallel for reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
388 for (int i = 0; i < 10; ++i)
392 #pragma omp distribute parallel for reduction(& : e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{invalid 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')}}
393 for (int i = 0; i < 10; ++i)
397 #pragma omp distribute parallel for reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
398 for (int i = 0; i < 10; ++i)
402 #pragma omp distribute parallel for reduction(+ : o) // expected-error {{no viable overloaded '='}}
403 for (int i = 0; i < 10; ++i)
407 #pragma omp distribute parallel for private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
408 for (int i = 0; i < 10; ++i)
410 #pragma omp parallel private(k)
413 #pragma omp distribute parallel for reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
414 for (int i = 0; i < 10; ++i)
418 #pragma omp distribute parallel for reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
419 for (int i = 0; i < 10; ++i)
423 #pragma omp distribute parallel for reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}}
424 for (int i = 0; i < 10; ++i)
426 #pragma omp parallel shared(i)
427 #pragma omp parallel reduction(min : i)
430 #pragma omp distribute parallel for reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
431 for (int i = 0; i < 10; ++i)
433 #pragma omp parallel private(fl)
436 #pragma omp distribute parallel for reduction(+ : fl)
437 for (int i = 0; i < 10; ++i)
439 #pragma omp parallel reduction(* : fl)
442 #pragma omp distribute parallel for reduction(+ : fl)
443 for (int i = 0; i < 10; ++i)
448 #pragma omp distribute parallel for reduction(+ : m) // OK
449 for (int i = 0; i < 10; ++i)
452 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}}