Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Argyrios Kyrtzidis | 73a0d88 | 2008-10-06 17:10:33 +0000 | [diff] [blame] | 2 | |
| 3 | int x(1); |
Argyrios Kyrtzidis | 3f2a8a0 | 2008-10-07 10:21:57 +0000 | [diff] [blame] | 4 | int (x2)(1); |
Argyrios Kyrtzidis | 73a0d88 | 2008-10-06 17:10:33 +0000 | [diff] [blame] | 5 | |
| 6 | void f() { |
| 7 | int x(1); |
Douglas Gregor | 3eb1c54 | 2008-12-17 16:19:15 +0000 | [diff] [blame] | 8 | int (x2)(1); |
Argyrios Kyrtzidis | 73a0d88 | 2008-10-06 17:10:33 +0000 | [diff] [blame] | 9 | for (int x(1);;) {} |
| 10 | } |
Douglas Gregor | 18fe568 | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 11 | |
| 12 | class Y { |
John McCall | 7002f4c | 2010-04-09 19:03:51 +0000 | [diff] [blame] | 13 | public: explicit Y(float); |
Douglas Gregor | 18fe568 | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 14 | }; |
| 15 | |
John McCall | 220ccbf | 2010-01-13 00:25:19 +0000 | [diff] [blame] | 16 | class X { // expected-note{{candidate constructor (the implicit copy constructor)}} |
Douglas Gregor | 18fe568 | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 17 | public: |
John McCall | b1622a1 | 2010-01-06 09:43:14 +0000 | [diff] [blame] | 18 | explicit X(int); // expected-note{{candidate constructor}} |
| 19 | X(float, float, float); // expected-note{{candidate constructor}} |
| 20 | X(float, Y); // expected-note{{candidate constructor}} |
Douglas Gregor | 18fe568 | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 21 | }; |
| 22 | |
John McCall | 220ccbf | 2010-01-13 00:25:19 +0000 | [diff] [blame] | 23 | class Z { // expected-note{{candidate constructor (the implicit copy constructor)}} |
Douglas Gregor | 18fe568 | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 24 | public: |
John McCall | b1622a1 | 2010-01-06 09:43:14 +0000 | [diff] [blame] | 25 | Z(int); // expected-note{{candidate constructor}} |
Douglas Gregor | 18fe568 | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 26 | }; |
| 27 | |
| 28 | void g() { |
| 29 | X x1(5); |
| 30 | X x2(1.0, 3, 4.2); |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 31 | X x3(1.0, 1.0); // expected-error{{no matching constructor for initialization of 'X'}} |
Douglas Gregor | 18fe568 | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 32 | Y y(1.0); |
| 33 | X x4(3.14, y); |
| 34 | |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 35 | Z z; // expected-error{{no matching constructor for initialization of 'Z'}} |
Douglas Gregor | 18fe568 | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 36 | } |
Fariborz Jahanian | 34acd3e | 2009-09-15 19:12:21 +0000 | [diff] [blame] | 37 | |
| 38 | struct Base { |
Fariborz Jahanian | 8b915e7 | 2009-09-15 22:15:23 +0000 | [diff] [blame] | 39 | operator int*() const; |
Fariborz Jahanian | 34acd3e | 2009-09-15 19:12:21 +0000 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | struct Derived : Base { |
Eli Friedman | cfdc81a | 2009-12-19 08:11:05 +0000 | [diff] [blame] | 43 | operator int*(); // expected-note {{candidate function}} |
Fariborz Jahanian | 34acd3e | 2009-09-15 19:12:21 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | void foo(const Derived cd, Derived d) { |
Chris Lattner | 0c42bb6 | 2010-09-05 00:17:29 +0000 | [diff] [blame] | 47 | int *pi = cd; // expected-error {{no viable conversion from 'const Derived' to 'int *'}} |
Fariborz Jahanian | 8b915e7 | 2009-09-15 22:15:23 +0000 | [diff] [blame] | 48 | int *ppi = d; |
Fariborz Jahanian | 34acd3e | 2009-09-15 19:12:21 +0000 | [diff] [blame] | 49 | |
| 50 | } |