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 teams distribute parallel for reduction // expected-error {{expected '(' after 'reduction'}}
86 for (int j=0; j<100; j++) foo();
88 #pragma omp teams distribute parallel for reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
89 for (int j=0; j<100; j++) foo();
91 #pragma omp teams distribute parallel for reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
92 for (int j=0; j<100; j++) foo();
94 #pragma omp teams distribute parallel for reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
95 for (int j=0; j<100; j++) foo();
97 #pragma omp teams distribute parallel for reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
98 for (int j=0; j<100; j++) foo();
100 #pragma omp teams distribute parallel for reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
101 for (int j=0; j<100; j++) foo();
103 #pragma omp teams distribute parallel for reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
104 for (int j=0; j<100; j++) foo();
106 #pragma omp teams distribute parallel for reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
107 for (int j=0; j<100; j++) foo();
109 #pragma omp teams 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')}}
110 for (int j=0; j<100; j++) foo();
112 #pragma omp teams distribute parallel for reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
113 for (int j=0; j<100; j++) foo();
115 #pragma omp teams 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'}}
116 for (int j=0; j<100; j++) foo();
118 #pragma omp teams distribute parallel for reduction(&& : argc)
119 for (int j=0; j<100; j++) foo();
121 #pragma omp teams distribute parallel for reduction(^ : T) // expected-error {{'T' does not refer to a value}}
122 for (int j=0; j<100; j++) foo();
124 #pragma omp teams 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'}}
125 for (int j=0; j<100; j++) foo();
127 #pragma omp teams 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}}
128 for (int j=0; j<100; j++) foo();
130 #pragma omp teams distribute parallel for reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
131 for (int j=0; j<100; j++) foo();
133 #pragma omp teams distribute parallel for reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
134 for (int j=0; j<100; j++) foo();
136 #pragma omp teams distribute parallel for reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
137 for (int j=0; j<100; j++) foo();
139 #pragma omp teams distribute parallel for reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}}
140 for (int j=0; j<100; j++) foo();
142 #pragma omp teams distribute parallel for reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
143 for (int j=0; j<100; j++) foo();
145 #pragma omp teams distribute parallel for reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
146 for (int j=0; j<100; j++) foo();
148 #pragma omp teams distribute parallel for reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
149 for (int j=0; j<100; j++) foo();
151 #pragma omp teams distribute parallel for reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
152 for (int j=0; j<100; j++) foo();
154 #pragma omp teams distribute parallel for reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
155 for (int j=0; j<100; j++) foo();
157 #pragma omp teams 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}}
158 for (int j=0; j<100; j++) foo();
159 #pragma omp parallel private(k)
161 #pragma omp teams distribute parallel for reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
162 for (int j=0; j<100; j++) foo();
164 #pragma omp teams 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}}
165 for (int j=0; j<100; j++) foo();
167 #pragma omp teams distribute parallel for reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}}
168 for (int j=0; j<100; j++) foo();
169 #pragma omp parallel shared(i)
170 #pragma omp parallel reduction(min : i)
172 #pragma omp teams distribute parallel for reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
173 for (int j=0; j<100; j++) foo();
175 #pragma omp teams distribute parallel for reduction(+ : fl)
176 for (int j=0; j<100; j++) foo();
183 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
189 int main(int argc, char **argv) {
190 const int d = 5; // expected-note 2 {{'d' defined here}}
191 const int da[5] = {0}; // expected-note {{'da' defined here}}
196 int &j = i; // expected-note 2 {{'j' defined here}}
197 S3 &p = k; // expected-note 2 {{'p' defined here}}
198 const int &r = da[i]; // expected-note {{'r' defined here}}
199 int &q = qa[i]; // expected-note {{'q' defined here}}
202 #pragma omp teams distribute parallel for reduction // expected-error {{expected '(' after 'reduction'}}
203 for (int j=0; j<100; j++) foo();
205 #pragma omp teams distribute parallel for reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
206 for (int j=0; j<100; j++) foo();
208 #pragma omp teams distribute parallel for reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
209 for (int j=0; j<100; j++) foo();
211 #pragma omp teams distribute parallel for reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
212 for (int j=0; j<100; j++) foo();
214 #pragma omp teams distribute parallel for reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
215 for (int j=0; j<100; j++) foo();
217 #pragma omp teams distribute parallel for reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
218 for (int j=0; j<100; j++) foo();
220 #pragma omp teams distribute parallel for reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
221 for (int j=0; j<100; j++) foo();
223 #pragma omp teams 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'}}
224 for (int j=0; j<100; j++) foo();
226 #pragma omp teams distribute parallel for reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
227 for (int j=0; j<100; j++) foo();
229 #pragma omp teams distribute parallel for reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
230 for (int j=0; j<100; j++) foo();
232 #pragma omp teams distribute parallel for reduction(~ : argc) // expected-error {{expected unqualified-id}}
233 for (int j=0; j<100; j++) foo();
235 #pragma omp teams distribute parallel for reduction(&& : argc)
236 for (int j=0; j<100; j++) foo();
238 #pragma omp teams distribute parallel for reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
239 for (int j=0; j<100; j++) foo();
241 #pragma omp teams 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'}}
242 for (int j=0; j<100; j++) foo();
244 #pragma omp teams 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}}
245 for (int j=0; j<100; j++) foo();
247 #pragma omp teams distribute parallel for reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
248 for (int j=0; j<100; j++) foo();
250 #pragma omp teams distribute parallel for reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
251 for (int j=0; j<100; j++) foo();
253 #pragma omp teams distribute parallel for reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
254 for (int j=0; j<100; j++) foo();
256 #pragma omp teams distribute parallel for reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}}
257 for (int j=0; j<100; j++) foo();
259 #pragma omp teams distribute parallel for reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
260 for (int j=0; j<100; j++) foo();
262 #pragma omp teams distribute parallel for reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
263 for (int j=0; j<100; j++) foo();
265 #pragma omp teams distribute parallel for reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
266 for (int j=0; j<100; j++) foo();
268 #pragma omp teams 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')}}
269 for (int j=0; j<100; j++) foo();
271 #pragma omp teams distribute parallel for reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
272 for (int j=0; j<100; j++) foo();
274 #pragma omp teams distribute parallel for reduction(+ : o) // expected-error {{no viable overloaded '='}}
275 for (int j=0; j<100; j++) foo();
277 #pragma omp teams 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}}
278 for (int j=0; j<100; j++) foo();
279 #pragma omp parallel private(k)
281 #pragma omp teams distribute parallel for reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
282 for (int j=0; j<100; j++) foo();
284 #pragma omp teams distribute parallel for reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
285 for (int j=0; j<100; j++) foo();
287 #pragma omp teams distribute parallel for reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}}
288 for (int j=0; j<100; j++) foo();
289 #pragma omp parallel shared(i)
290 #pragma omp parallel reduction(min : i)
292 #pragma omp teams distribute parallel for reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
293 for (int j=0; j<100; j++) foo();
295 #pragma omp teams distribute parallel for reduction(+ : fl)
296 for (int j=0; j<100; j++) foo();
299 #pragma omp teams distribute parallel for reduction(+ : m) // OK
300 for (int j=0; j<100; j++) foo();
302 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}}