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
8 bool foobool(int argc) {
12 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
16 S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}}
20 S2(S2 &s2) : a(s2.a) {}
21 static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
22 static const float S2sc;
24 const float S2::S2sc = 0; // expected-note 2 {{'S2sc' defined here}}
25 S2 b; // expected-note 3 {{'b' defined here}}
26 const S2 ba[5]; // expected-note 2 {{'ba' defined here}}
33 S3(const S3 &s3) : a(s3.a) {}
34 S3 operator+(const S3 &arg1) { return arg1; }
36 int operator+(const S3 &arg1, const S3 &arg2) { return 5; }
37 S3 c; // expected-note 3 {{'c' defined here}}
38 const S3 ca[5]; // expected-note 2 {{'ca' defined here}}
39 extern const int f; // expected-note 4 {{'f' declared here}}
42 S4(); // expected-note {{implicitly declared private here}}
44 S4 &operator+(const S4 &arg) { return (*this); }
49 S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
52 S5() : a(0) {} // expected-note {{implicitly declared private here}}
53 S5(const S5 &s5) : a(s5.a) {}
54 S5 &operator+(const S5 &arg);
59 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}}
60 #if __cplusplus >= 201103L // C++11 or later
61 // expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}
67 operator int() { return 6; }
71 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
73 template <class T> // expected-note {{declared here}}
75 const T d = T(); // expected-note 4 {{'d' defined here}}
76 const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
79 T &j = i; // expected-note 4 {{'j' defined here}}
80 S3 &p = k; // expected-note 2 {{'p' defined here}}
81 const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}}
82 T &q = qa[(int)i]; // expected-note 2 {{'q' defined here}}
86 #pragma omp distribute simd reduction // expected-error {{expected '(' after 'reduction'}}
87 for (int i = 0; i < 10; ++i)
91 #pragma omp distribute simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
92 for (int i = 0; i < 10; ++i)
96 #pragma omp distribute simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
97 for (int i = 0; i < 10; ++i)
101 #pragma omp distribute simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
102 for (int i = 0; i < 10; ++i)
106 #pragma omp distribute simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
107 for (int i = 0; i < 10; ++i)
111 #pragma omp distribute simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
112 for (int i = 0; i < 10; ++i)
116 #pragma omp distribute simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
117 for (int i = 0; i < 10; ++i)
121 #pragma omp distribute simd reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
122 for (int i = 0; i < 10; ++i)
126 #pragma omp distribute simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
127 for (int i = 0; i < 10; ++i)
131 #pragma omp distribute simd reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
132 for (int i = 0; i < 10; ++i)
136 #pragma omp distribute simd 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'}}
137 for (int i = 0; i < 10; ++i)
141 #pragma omp distribute simd reduction(&& : argc)
142 for (int i = 0; i < 10; ++i)
146 #pragma omp distribute simd reduction(^ : T) // expected-error {{'T' does not refer to a value}}
147 for (int i = 0; i < 10; ++i)
151 #pragma omp distribute simd 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'}}
152 for (int i = 0; i < 10; ++i)
156 #pragma omp distribute simd 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}}
157 for (int i = 0; i < 10; ++i)
161 #pragma omp distribute simd reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
162 for (int i = 0; i < 10; ++i)
166 #pragma omp distribute simd reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
167 for (int i = 0; i < 10; ++i)
171 #pragma omp distribute simd reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
172 for (int i = 0; i < 10; ++i)
176 #pragma omp distribute simd reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}}
177 for (int i = 0; i < 10; ++i)
181 #pragma omp distribute simd reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
182 for (int i = 0; i < 10; ++i)
186 #pragma omp distribute simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
187 for (int i = 0; i < 10; ++i)
191 #pragma omp distribute simd reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
192 for (int i = 0; i < 10; ++i)
196 #pragma omp distribute simd reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
197 for (int i = 0; i < 10; ++i)
201 #pragma omp distribute simd reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
202 for (int i = 0; i < 10; ++i)
206 #pragma omp distribute simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
207 for (int i = 0; i < 10; ++i)
209 #pragma omp parallel private(k)
212 #pragma omp distribute simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
213 for (int i = 0; i < 10; ++i)
217 #pragma omp distribute simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}}
218 for (int i = 0; i < 10; ++i)
222 #pragma omp distribute simd reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}}
223 for (int i = 0; i < 10; ++i)
225 #pragma omp parallel shared(i)
226 #pragma omp parallel reduction(min : i)
229 #pragma omp distribute simd reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
230 for (int i = 0; i < 10; ++i)
232 #pragma omp parallel private(fl)
235 #pragma omp distribute simd reduction(+ : fl)
236 for (int i = 0; i < 10; ++i)
238 #pragma omp parallel reduction(* : fl)
241 #pragma omp distribute simd reduction(+ : fl)
242 for (int i = 0; i < 10; ++i)
250 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
256 int main(int argc, char **argv) {
257 const int d = 5; // expected-note 2 {{'d' defined here}}
258 const int da[5] = {0}; // expected-note {{'da' defined here}}
263 int &j = i; // expected-note 2 {{'j' defined here}}
264 S3 &p = k; // expected-note 2 {{'p' defined here}}
265 const int &r = da[i]; // expected-note {{'r' defined here}}
266 int &q = qa[i]; // expected-note {{'q' defined here}}
270 #pragma omp distribute simd reduction // expected-error {{expected '(' after 'reduction'}}
271 for (int i = 0; i < 10; ++i)
275 #pragma omp distribute simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp distribute simd' are ignored}}
276 for (int i = 0; i < 10; ++i)
280 #pragma omp distribute simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
281 for (int i = 0; i < 10; ++i)
285 #pragma omp distribute simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
286 for (int i = 0; i < 10; ++i)
290 #pragma omp distribute simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
291 for (int i = 0; i < 10; ++i)
295 #pragma omp distribute simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
296 for (int i = 0; i < 10; ++i)
300 #pragma omp distribute simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
301 for (int i = 0; i < 10; ++i)
305 #pragma omp distribute simd reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
306 for (int i = 0; i < 10; ++i)
310 #pragma omp distribute simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
311 for (int i = 0; i < 10; ++i)
315 #pragma omp distribute simd reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
316 for (int i = 0; i < 10; ++i)
320 #pragma omp distribute simd reduction(~ : argc) // expected-error {{expected unqualified-id}}
321 for (int i = 0; i < 10; ++i)
325 #pragma omp distribute simd reduction(&& : argc)
326 for (int i = 0; i < 10; ++i)
330 #pragma omp distribute simd reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
331 for (int i = 0; i < 10; ++i)
335 #pragma omp distribute simd 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'}}
336 for (int i = 0; i < 10; ++i)
340 #pragma omp distribute simd 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}}
341 for (int i = 0; i < 10; ++i)
345 #pragma omp distribute simd reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
346 for (int i = 0; i < 10; ++i)
350 #pragma omp distribute simd reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
351 for (int i = 0; i < 10; ++i)
355 #pragma omp distribute simd reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
356 for (int i = 0; i < 10; ++i)
360 #pragma omp distribute simd reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}}
361 for (int i = 0; i < 10; ++i)
365 #pragma omp distribute simd reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
366 for (int i = 0; i < 10; ++i)
370 #pragma omp distribute simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
371 for (int i = 0; i < 10; ++i)
375 #pragma omp distribute simd reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
376 for (int i = 0; i < 10; ++i)
380 #pragma omp distribute simd 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')}}
381 for (int i = 0; i < 10; ++i)
385 #pragma omp distribute simd reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
386 for (int i = 0; i < 10; ++i)
390 #pragma omp distribute simd reduction(+ : o) // expected-error {{no viable overloaded '='}}
391 for (int i = 0; i < 10; ++i)
395 #pragma omp distribute simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
396 for (int i = 0; i < 10; ++i)
398 #pragma omp parallel private(k)
401 #pragma omp distribute simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
402 for (int i = 0; i < 10; ++i)
406 #pragma omp distribute simd reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
407 for (int i = 0; i < 10; ++i)
411 #pragma omp distribute simd reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}}
412 for (int i = 0; i < 10; ++i)
414 #pragma omp parallel shared(i)
415 #pragma omp parallel reduction(min : i)
418 #pragma omp distribute simd reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
419 for (int i = 0; i < 10; ++i)
421 #pragma omp parallel private(fl)
424 #pragma omp distribute simd reduction(+ : fl)
425 for (int i = 0; i < 10; ++i)
427 #pragma omp parallel reduction(* : fl)
430 #pragma omp distribute simd reduction(+ : fl)
431 for (int i = 0; i < 10; ++i)
436 #pragma omp distribute simd reduction(+ : m) // OK
437 for (int i = 0; i < 10; ++i)
440 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}}