1 // RUN: %clang_cc1 -verify -fopenmp %s
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s
3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %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}}
85 #pragma omp for simd reduction // expected-error {{expected '(' after 'reduction'}}
86 for (int i = 0; i < 10; ++i)
89 #pragma omp for simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp for simd' are ignored}}
90 for (int i = 0; i < 10; ++i)
93 #pragma omp for simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
94 for (int i = 0; i < 10; ++i)
97 #pragma omp for simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
98 for (int i = 0; i < 10; ++i)
101 #pragma omp for simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
102 for (int i = 0; i < 10; ++i)
105 #pragma omp for simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
106 for (int i = 0; i < 10; ++i)
109 #pragma omp for simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
110 for (int i = 0; i < 10; ++i)
113 #pragma omp for simd reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
114 for (int i = 0; i < 10; ++i)
117 #pragma omp for 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')}}
118 for (int i = 0; i < 10; ++i)
121 #pragma omp for simd reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
122 for (int i = 0; i < 10; ++i)
125 #pragma omp for 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'}}
126 for (int i = 0; i < 10; ++i)
129 #pragma omp for simd reduction(&& : argc)
130 for (int i = 0; i < 10; ++i)
133 #pragma omp for simd reduction(^ : T) // expected-error {{'T' does not refer to a value}}
134 for (int i = 0; i < 10; ++i)
137 #pragma omp for 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'}}
138 for (int i = 0; i < 10; ++i)
141 #pragma omp for 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}}
142 for (int i = 0; i < 10; ++i)
145 #pragma omp for simd reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
146 for (int i = 0; i < 10; ++i)
149 #pragma omp for simd reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
150 for (int i = 0; i < 10; ++i)
153 #pragma omp for simd reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
154 for (int i = 0; i < 10; ++i)
157 #pragma omp for simd reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}}
158 for (int i = 0; i < 10; ++i)
161 #pragma omp for simd reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
162 for (int i = 0; i < 10; ++i)
165 #pragma omp for simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
166 for (int i = 0; i < 10; ++i)
169 #pragma omp for simd reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
170 for (int i = 0; i < 10; ++i)
173 #pragma omp for simd reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
174 for (int i = 0; i < 10; ++i)
177 #pragma omp for simd reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
178 for (int i = 0; i < 10; ++i)
181 #pragma omp for simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
182 for (int i = 0; i < 10; ++i)
184 #pragma omp parallel private(k)
185 #pragma omp for simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
186 for (int i = 0; i < 10; ++i)
189 #pragma omp for simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}}
190 for (int i = 0; i < 10; ++i)
193 #pragma omp for simd reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}}
194 for (int i = 0; i < 10; ++i)
196 #pragma omp parallel shared(i)
197 #pragma omp parallel reduction(min : i)
198 #pragma omp for simd reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
199 for (int i = 0; i < 10; ++i)
201 #pragma omp parallel private(fl) // expected-note 2 {{defined as private}}
202 #pragma omp for simd reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}}
203 for (int i = 0; i < 10; ++i)
205 #pragma omp parallel reduction(* : fl) // expected-note 2 {{defined as reduction}}
206 #pragma omp for simd reduction(+ : fl) // expected-error 2 {{reduction variable must be shared}}
207 for (int i = 0; i < 10; ++i)
215 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
221 int main(int argc, char **argv) {
222 const int d = 5; // expected-note 2 {{'d' defined here}}
223 const int da[5] = {0}; // expected-note {{'da' defined here}}
228 int &j = i; // expected-note 2 {{'j' defined here}}
229 S3 &p = k; // expected-note 2 {{'p' defined here}}
230 const int &r = da[i]; // expected-note {{'r' defined here}}
231 int &q = qa[i]; // expected-note {{'q' defined here}}
234 #pragma omp for simd reduction // expected-error {{expected '(' after 'reduction'}}
235 for (int i = 0; i < 10; ++i)
238 #pragma omp for simd reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp for simd' are ignored}}
239 for (int i = 0; i < 10; ++i)
242 #pragma omp for simd reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
243 for (int i = 0; i < 10; ++i)
246 #pragma omp for simd reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
247 for (int i = 0; i < 10; ++i)
250 #pragma omp for simd reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
251 for (int i = 0; i < 10; ++i)
254 #pragma omp for simd reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
255 for (int i = 0; i < 10; ++i)
258 #pragma omp for simd reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
259 for (int i = 0; i < 10; ++i)
262 #pragma omp for simd reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
263 for (int i = 0; i < 10; ++i)
266 #pragma omp for simd reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
267 for (int i = 0; i < 10; ++i)
270 #pragma omp for simd reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
271 for (int i = 0; i < 10; ++i)
274 #pragma omp for simd reduction(~ : argc) // expected-error {{expected unqualified-id}}
275 for (int i = 0; i < 10; ++i)
278 #pragma omp for simd reduction(&& : argc)
279 for (int i = 0; i < 10; ++i)
282 #pragma omp for simd reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
283 for (int i = 0; i < 10; ++i)
286 #pragma omp for 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'}}
287 for (int i = 0; i < 10; ++i)
290 #pragma omp for 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}}
291 for (int i = 0; i < 10; ++i)
294 #pragma omp for simd reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
295 for (int i = 0; i < 10; ++i)
298 #pragma omp for simd reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
299 for (int i = 0; i < 10; ++i)
302 #pragma omp for simd reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
303 for (int i = 0; i < 10; ++i)
306 #pragma omp for simd reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}}
307 for (int i = 0; i < 10; ++i)
310 #pragma omp for simd reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
311 for (int i = 0; i < 10; ++i)
314 #pragma omp for simd reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
315 for (int i = 0; i < 10; ++i)
318 #pragma omp for simd reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
319 for (int i = 0; i < 10; ++i)
322 #pragma omp for 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')}}
323 for (int i = 0; i < 10; ++i)
326 #pragma omp for simd reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
327 for (int i = 0; i < 10; ++i)
330 #pragma omp for simd reduction(+ : o) // expected-error {{no viable overloaded '='}}
331 for (int i = 0; i < 10; ++i)
334 #pragma omp for simd private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
335 for (int i = 0; i < 10; ++i)
337 #pragma omp parallel private(k)
338 #pragma omp for simd reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
339 for (int i = 0; i < 10; ++i)
342 #pragma omp for simd reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
343 for (int i = 0; i < 10; ++i)
346 #pragma omp for simd reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}}
347 for (int i = 0; i < 10; ++i)
349 #pragma omp parallel shared(i)
350 #pragma omp parallel reduction(min : i)
351 #pragma omp for simd reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
352 for (int i = 0; i < 10; ++i)
354 #pragma omp parallel private(fl) // expected-note {{defined as private}}
355 #pragma omp for simd reduction(+ : fl) // expected-error {{reduction variable must be shared}}
356 for (int i = 0; i < 10; ++i)
358 #pragma omp parallel reduction(* : fl) // expected-note {{defined as reduction}}
359 #pragma omp for simd reduction(+ : fl) // expected-error {{reduction variable must be shared}}
360 for (int i = 0; i < 10; ++i)
363 #pragma omp for simd reduction(+ : m)
364 for (int i = 0; i < 10; ++i)
367 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}}