1 // RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-target
2 // RUN: %clang_cc1 -verify -fopenmp -std=c++98 %s -Wno-openmp-target
3 // RUN: %clang_cc1 -verify -fopenmp -std=c++11 %s -Wno-openmp-target
5 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-target
6 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++98 %s -Wno-openmp-target
7 // RUN: %clang_cc1 -verify -fopenmp-simd -std=c++11 %s -Wno-openmp-target
12 bool foobool(int argc) {
16 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
20 S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}}
24 S2(S2 &s2) : a(s2.a) {}
25 static float S2s; // expected-note 2 {{static data member is predetermined as shared}}
26 static const float S2sc; // expected-note 2 {{'S2sc' declared here}}
28 const float S2::S2sc = 0;
29 S2 b; // expected-note 3 {{'b' defined here}}
30 const S2 ba[5]; // expected-note 2 {{'ba' defined here}}
37 S3(const S3 &s3) : a(s3.a) {}
38 S3 operator+(const S3 &arg1) { return arg1; }
40 int operator+(const S3 &arg1, const S3 &arg2) { return 5; }
41 S3 c; // expected-note 3 {{'c' defined here}}
42 const S3 ca[5]; // expected-note 2 {{'ca' defined here}}
43 extern const int f; // expected-note 4 {{'f' declared here}}
46 S4(); // expected-note {{implicitly declared private here}}
48 S4 &operator+(const S4 &arg) { return (*this); }
53 S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
56 S5() : a(0) {} // expected-note {{implicitly declared private here}}
57 S5(const S5 &s5) : a(s5.a) {}
58 S5 &operator+(const S5 &arg);
63 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}}
64 #if __cplusplus >= 201103L // C++11 or later
65 // expected-note@-2 3 {{candidate function (the implicit move assignment operator) not viable}}
71 operator int() { return 6; }
75 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
77 template <class T> // expected-note {{declared here}}
79 const T d = T(); // expected-note 4 {{'d' defined here}}
80 const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
83 T &j = i; // expected-note 4 {{'j' defined here}}
84 S3 &p = k; // expected-note 2 {{'p' defined here}}
85 const T &r = da[(int)i]; // expected-note 2 {{'r' defined here}}
86 T &q = qa[(int)i]; // expected-note 2 {{'q' defined here}}
89 #pragma omp teams distribute parallel for reduction // expected-error {{expected '(' after 'reduction'}}
90 for (int j=0; j<100; j++) foo();
92 #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}}
93 for (int j=0; j<100; j++) foo();
95 #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 '('}}
96 for (int j=0; j<100; j++) foo();
98 #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 '('}}
99 for (int j=0; j<100; j++) foo();
101 #pragma omp teams distribute parallel for reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
102 for (int j=0; j<100; j++) foo();
104 #pragma omp teams distribute parallel for reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
105 for (int j=0; j<100; j++) foo();
107 #pragma omp teams distribute parallel for reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
108 for (int j=0; j<100; j++) foo();
110 #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')}}
111 for (int j=0; j<100; j++) foo();
113 #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')}}
114 for (int j=0; j<100; j++) foo();
116 #pragma omp teams distribute parallel for reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
117 for (int j=0; j<100; j++) foo();
119 #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'}}
120 for (int j=0; j<100; j++) foo();
122 #pragma omp teams distribute parallel for reduction(&& : argc)
123 for (int j=0; j<100; j++) foo();
125 #pragma omp teams distribute parallel for reduction(^ : T) // expected-error {{'T' does not refer to a value}}
126 for (int j=0; j<100; j++) foo();
128 #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 variable cannot be reduction}} expected-error 2 {{'operator+' is a private member of 'S2'}}
129 for (int j=0; j<100; j++) foo();
131 #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 variable cannot be reduction}}
132 for (int j=0; j<100; j++) foo();
134 #pragma omp teams distribute parallel for reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
135 for (int j=0; j<100; j++) foo();
137 #pragma omp teams distribute parallel for reduction(+ : ba) // expected-error {{const-qualified variable cannot be reduction}}
138 for (int j=0; j<100; j++) foo();
140 #pragma omp teams distribute parallel for reduction(* : ca) // expected-error {{const-qualified variable cannot be reduction}}
141 for (int j=0; j<100; j++) foo();
143 #pragma omp teams distribute parallel for reduction(- : da) // expected-error {{const-qualified variable cannot be reduction}} expected-error {{const-qualified variable cannot be reduction}}
144 for (int j=0; j<100; j++) foo();
146 #pragma omp teams distribute parallel for reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
147 for (int j=0; j<100; j++) foo();
149 #pragma omp teams distribute parallel for reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
150 for (int j=0; j<100; j++) foo();
152 #pragma omp teams distribute parallel for reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
153 for (int j=0; j<100; j++) foo();
155 #pragma omp teams distribute parallel for reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
156 for (int j=0; j<100; j++) foo();
158 #pragma omp teams distribute parallel for reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
159 for (int j=0; j<100; j++) foo();
161 #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}}
162 for (int j=0; j<100; j++) foo();
163 #pragma omp parallel private(k)
165 #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}}
166 for (int j=0; j<100; j++) foo();
168 #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}}
169 for (int j=0; j<100; j++) foo();
171 #pragma omp teams distribute parallel for reduction(+ : r) // expected-error 2 {{const-qualified variable cannot be reduction}}
172 for (int j=0; j<100; j++) foo();
173 #pragma omp parallel shared(i)
174 #pragma omp parallel reduction(min : i)
176 #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}}
177 for (int j=0; j<100; j++) foo();
179 #pragma omp teams distribute parallel for reduction(+ : fl)
180 for (int j=0; j<100; j++) foo();
187 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
193 int main(int argc, char **argv) {
194 const int d = 5; // expected-note 2 {{'d' defined here}}
195 const int da[5] = {0}; // expected-note {{'da' defined here}}
200 int &j = i; // expected-note 2 {{'j' defined here}}
201 S3 &p = k; // expected-note 2 {{'p' defined here}}
202 const int &r = da[i]; // expected-note {{'r' defined here}}
203 int &q = qa[i]; // expected-note {{'q' defined here}}
206 #pragma omp teams distribute parallel for reduction // expected-error {{expected '(' after 'reduction'}}
207 for (int j=0; j<100; j++) foo();
209 #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}}
210 for (int j=0; j<100; j++) foo();
212 #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 '('}}
213 for (int j=0; j<100; j++) foo();
215 #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 '('}}
216 for (int j=0; j<100; j++) foo();
218 #pragma omp teams distribute parallel for reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
219 for (int j=0; j<100; j++) foo();
221 #pragma omp teams distribute parallel for reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
222 for (int j=0; j<100; j++) foo();
224 #pragma omp teams distribute parallel for reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
225 for (int j=0; j<100; j++) foo();
227 #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'}}
228 for (int j=0; j<100; j++) foo();
230 #pragma omp teams distribute parallel for reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
231 for (int j=0; j<100; j++) foo();
233 #pragma omp teams distribute parallel for reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
234 for (int j=0; j<100; j++) foo();
236 #pragma omp teams distribute parallel for reduction(~ : argc) // expected-error {{expected unqualified-id}}
237 for (int j=0; j<100; j++) foo();
239 #pragma omp teams distribute parallel for reduction(&& : argc)
240 for (int j=0; j<100; j++) foo();
242 #pragma omp teams distribute parallel for reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
243 for (int j=0; j<100; j++) foo();
245 #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 variable cannot be reduction}} expected-error {{'operator+' is a private member of 'S2'}}
246 for (int j=0; j<100; j++) foo();
248 #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 variable cannot be reduction}}
249 for (int j=0; j<100; j++) foo();
251 #pragma omp teams distribute parallel for reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
252 for (int j=0; j<100; j++) foo();
254 #pragma omp teams distribute parallel for reduction(+ : ba) // expected-error {{const-qualified variable cannot be reduction}}
255 for (int j=0; j<100; j++) foo();
257 #pragma omp teams distribute parallel for reduction(* : ca) // expected-error {{const-qualified variable cannot be reduction}}
258 for (int j=0; j<100; j++) foo();
260 #pragma omp teams distribute parallel for reduction(- : da) // expected-error {{const-qualified variable cannot be reduction}}
261 for (int j=0; j<100; j++) foo();
263 #pragma omp teams distribute parallel for reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
264 for (int j=0; j<100; j++) foo();
266 #pragma omp teams distribute parallel for reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
267 for (int j=0; j<100; j++) foo();
269 #pragma omp teams distribute parallel for reduction(&& : S2::S2sc) // expected-error {{const-qualified variable cannot be reduction}}
270 for (int j=0; j<100; j++) foo();
272 #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')}}
273 for (int j=0; j<100; j++) foo();
275 #pragma omp teams distribute parallel for reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
276 for (int j=0; j<100; j++) foo();
278 #pragma omp teams distribute parallel for reduction(+ : o) // expected-error {{no viable overloaded '='}}
279 for (int j=0; j<100; j++) foo();
281 #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}}
282 for (int j=0; j<100; j++) foo();
283 #pragma omp parallel private(k)
285 #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}}
286 for (int j=0; j<100; j++) foo();
288 #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}}
289 for (int j=0; j<100; j++) foo();
291 #pragma omp teams distribute parallel for reduction(+ : r) // expected-error {{const-qualified variable cannot be reduction}}
292 for (int j=0; j<100; j++) foo();
293 #pragma omp parallel shared(i)
294 #pragma omp parallel reduction(min : i)
296 #pragma omp teams distribute parallel for reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
297 for (int j=0; j<100; j++) foo();
299 #pragma omp teams distribute parallel for reduction(+ : fl)
300 for (int j=0; j<100; j++) foo();
303 #pragma omp teams distribute parallel for reduction(+ : m) // OK
304 for (int j=0; j<100; j++) foo();
306 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}}