• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
4 
foo()5 void foo() {
6 }
7 
foobool(int argc)8 bool foobool(int argc) {
9   return argc;
10 }
11 
12 struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}}
13 extern S1 a;
14 class S2 {
15   mutable int a;
operator +(const S2 & arg)16   S2 &operator+(const S2 &arg) { return (*this); } // expected-note 3 {{implicitly declared private here}}
17 
18 public:
S2()19   S2() : a(0) {}
S2(S2 & s2)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;
23 };
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}}
27 class S3 {
28   int a;
29 
30 public:
31   int b;
S3()32   S3() : a(0) {}
S3(const S3 & s3)33   S3(const S3 &s3) : a(s3.a) {}
operator +(const S3 & arg1)34   S3 operator+(const S3 &arg1) { return arg1; }
35 };
operator +(const S3 & arg1,const S3 & arg2)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}}
40 class S4 {
41   int a;
42   S4(); // expected-note {{implicitly declared private here}}
43   S4(const S4 &s4);
operator +(const S4 & arg)44   S4 &operator+(const S4 &arg) { return (*this); }
45 
46 public:
S4(int v)47   S4(int v) : a(v) {}
48 };
operator &=(S4 & arg1,S4 & arg2)49 S4 &operator&=(S4 &arg1, S4 &arg2) { return arg1; }
50 class S5 {
51   int a;
S5()52   S5() : a(0) {} // expected-note {{implicitly declared private here}}
S5(const S5 & s5)53   S5(const S5 &s5) : a(s5.a) {}
54   S5 &operator+(const S5 &arg);
55 
56 public:
S5(int v)57   S5(int v) : a(v) {}
58 };
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}}
62 #endif
63   int a;
64 
65 public:
S6()66   S6() : a(6) {}
operator int()67   operator int() { return 6; }
68 } o;
69 
70 S3 h, k;
71 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
72 
73 template <class T>       // expected-note {{declared here}}
tmain(T argc)74 T tmain(T argc) {
75   const T d = T();       // expected-note 4 {{'d' defined here}}
76   const T da[5] = {T()}; // expected-note 2 {{'da' defined here}}
77   T qa[5] = {T()};
78   T i;
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}}
83   T fl;
84 #pragma omp parallel sections reduction // expected-error {{expected '(' after 'reduction'}}
85   {
86     foo();
87   }
88 #pragma omp parallel sections reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
89   {
90     foo();
91   }
92 #pragma omp parallel sections reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
93   {
94     foo();
95   }
96 #pragma omp parallel sections reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
97   {
98     foo();
99   }
100 #pragma omp parallel sections reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
101   {
102     foo();
103   }
104 #pragma omp parallel sections reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
105   {
106     foo();
107   }
108 #pragma omp parallel sections reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
109   {
110     foo();
111   }
112 #pragma omp parallel sections reduction(& : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
113   {
114     foo();
115   }
116 #pragma omp parallel sections reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{invalid operands to binary expression ('float' and 'float')}}
117   {
118     foo();
119   }
120 #pragma omp parallel sections reduction(|| : argc ? i : argc) // expected-error 2 {{expected variable name, array element or array section}}
121   {
122     foo();
123   }
124 #pragma omp parallel sections 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'}}
125   {
126     foo();
127   }
128 #pragma omp parallel sections reduction(&& : argc)
129   {
130     foo();
131   }
132 #pragma omp parallel sections reduction(^ : T) // expected-error {{'T' does not refer to a value}}
133   {
134     foo();
135   }
136 #pragma omp parallel sections 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'}}
137   {
138     foo();
139   }
140 #pragma omp parallel sections 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}}
141   {
142     foo();
143   }
144 #pragma omp parallel sections reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
145   {
146     foo();
147   }
148 #pragma omp parallel sections reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
149   {
150     foo();
151   }
152 #pragma omp parallel sections reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
153   {
154     foo();
155   }
156 #pragma omp parallel sections reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}} expected-error {{const-qualified list item cannot be reduction}}
157   {
158     foo();
159   }
160 #pragma omp parallel sections reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
161   {
162     foo();
163   }
164 #pragma omp parallel sections reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
165   {
166     foo();
167   }
168 #pragma omp parallel sections reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
169   {
170     foo();
171   }
172 #pragma omp parallel sections reduction(+ : h, k) // expected-error {{threadprivate or thread local variable cannot be reduction}}
173   {
174     foo();
175   }
176 #pragma omp parallel sections reduction(+ : o) // expected-error 2 {{no viable overloaded '='}}
177   {
178     foo();
179   }
180 #pragma omp parallel sections private(i), reduction(+ : j), reduction(+ : q) // expected-error 4 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
181   {
182     foo();
183   }
184 #pragma omp parallel private(k)
185 #pragma omp parallel sections reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
186   {
187     foo();
188   }
189 #pragma omp parallel sections reduction(+ : p), reduction(+ : p) // expected-error 2 {{variable can appear only once in OpenMP 'reduction' clause}} expected-note 2 {{previously referenced here}}
190   {
191     foo();
192   }
193 #pragma omp parallel sections reduction(+ : r) // expected-error 2 {{const-qualified list item cannot be reduction}}
194   {
195     foo();
196   }
197 #pragma omp parallel shared(i)
198 #pragma omp parallel reduction(min : i)
199 #pragma omp parallel sections reduction(max : j) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
200   {
201     foo();
202   }
203 #pragma omp parallel private(fl)
204 #pragma omp parallel sections reduction(+ : fl)
205   {
206     foo();
207   }
208 #pragma omp parallel reduction(* : fl)
209 #pragma omp parallel sections reduction(+ : fl)
210   {
211     foo();
212   }
213 
214   return T();
215 }
216 
217 namespace A {
218 double x;
219 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
220 }
221 namespace B {
222 using A::x;
223 }
224 
main(int argc,char ** argv)225 int main(int argc, char **argv) {
226   const int d = 5;       // expected-note 2 {{'d' defined here}}
227   const int da[5] = {0}; // expected-note {{'da' defined here}}
228   int qa[5] = {0};
229   S4 e(4);
230   S5 g(5);
231   int i;
232   int &j = i;                           // expected-note 2 {{'j' defined here}}
233   S3 &p = k;                            // expected-note 2 {{'p' defined here}}
234   const int &r = da[i];                 // expected-note {{'r' defined here}}
235   int &q = qa[i];                       // expected-note {{'q' defined here}}
236   float fl;
237 #pragma omp parallel sections reduction // expected-error {{expected '(' after 'reduction'}}
238   {
239     foo();
240   }
241 #pragma omp parallel sections reduction + // expected-error {{expected '(' after 'reduction'}} expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
242   {
243     foo();
244   }
245 #pragma omp parallel sections reduction( // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
246   {
247     foo();
248   }
249 #pragma omp parallel sections reduction(- // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
250   {
251     foo();
252   }
253 #pragma omp parallel sections reduction() // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
254   {
255     foo();
256   }
257 #pragma omp parallel sections reduction(*) // expected-warning {{missing ':' after reduction identifier - ignoring}} expected-error {{expected expression}}
258   {
259     foo();
260   }
261 #pragma omp parallel sections reduction(\) // expected-error {{expected unqualified-id}} expected-warning {{missing ':' after reduction identifier - ignoring}}
262   {
263     foo();
264   }
265 #pragma omp parallel sections reduction(foo : argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{incorrect reduction identifier, expected one of '+', '-', '*', '&', '|', '^', '&&', '||', 'min' or 'max'}}
266   {
267     foo();
268   }
269 #pragma omp parallel sections reduction(| : argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
270   {
271     foo();
272   }
273 #pragma omp parallel sections reduction(|| : argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name, array element or array section}}
274   {
275     foo();
276   }
277 #pragma omp parallel sections reduction(~ : argc) // expected-error {{expected unqualified-id}}
278   {
279     foo();
280   }
281 #pragma omp parallel sections reduction(&& : argc)
282   {
283     foo();
284   }
285 #pragma omp parallel sections reduction(^ : S1) // expected-error {{'S1' does not refer to a value}}
286   {
287     foo();
288   }
289 #pragma omp parallel sections 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'}}
290   {
291     foo();
292   }
293 #pragma omp parallel sections 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}}
294   {
295     foo();
296   }
297 #pragma omp parallel sections reduction(max : h.b) // expected-error {{expected variable name, array element or array section}}
298   {
299     foo();
300   }
301 #pragma omp parallel sections reduction(+ : ba) // expected-error {{const-qualified list item cannot be reduction}}
302   {
303     foo();
304   }
305 #pragma omp parallel sections reduction(* : ca) // expected-error {{const-qualified list item cannot be reduction}}
306   {
307     foo();
308   }
309 #pragma omp parallel sections reduction(- : da) // expected-error {{const-qualified list item cannot be reduction}}
310   {
311     foo();
312   }
313 #pragma omp parallel sections reduction(^ : fl) // expected-error {{invalid operands to binary expression ('float' and 'float')}}
314   {
315     foo();
316   }
317 #pragma omp parallel sections reduction(&& : S2::S2s) // expected-error {{shared variable cannot be reduction}}
318   {
319     foo();
320   }
321 #pragma omp parallel sections reduction(&& : S2::S2sc) // expected-error {{const-qualified list item cannot be reduction}}
322   {
323     foo();
324   }
325 #pragma omp parallel sections 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')}}
326   {
327     foo();
328   }
329 #pragma omp parallel sections reduction(+ : h, k, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be reduction}}
330   {
331     foo();
332   }
333 #pragma omp parallel sections reduction(+ : o) // expected-error {{no viable overloaded '='}}
334   {
335     foo();
336   }
337 #pragma omp parallel sections private(i), reduction(+ : j), reduction(+ : q) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
338   {
339     foo();
340   }
341 #pragma omp parallel private(k)
342 #pragma omp parallel sections reduction(+ : p), reduction(+ : p) // expected-error 2 {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
343   {
344     foo();
345   }
346 #pragma omp parallel sections reduction(+ : p), reduction(+ : p) // expected-error {{variable can appear only once in OpenMP 'reduction' clause}} expected-note {{previously referenced here}}
347   {
348     foo();
349   }
350 #pragma omp parallel sections reduction(+ : r) // expected-error {{const-qualified list item cannot be reduction}}
351   {
352     foo();
353   }
354 #pragma omp parallel shared(i)
355 #pragma omp parallel reduction(min : i)
356 #pragma omp parallel sections reduction(max : j) // expected-error {{argument of OpenMP clause 'reduction' must reference the same object in all threads}}
357   {
358     foo();
359   }
360 #pragma omp parallel private(fl)
361 #pragma omp parallel sections reduction(+ : fl)
362   {
363     foo();
364   }
365 #pragma omp parallel reduction(* : fl)
366 #pragma omp parallel sections reduction(+ : fl)
367   {
368     foo();
369   }
370   static int m;
371 #pragma omp parallel sections reduction(+ : m) // OK
372   {
373     foo();
374   }
375 
376   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}}
377 }
378