Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -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 { |
| 13 | explicit Y(float); |
| 14 | }; |
| 15 | |
| 16 | class X { // expected-note{{candidate function}} |
| 17 | public: |
| 18 | explicit X(int); // expected-note{{candidate function}} |
| 19 | X(float, float, float); // expected-note{{candidate function}} |
| 20 | X(float, Y); // expected-note{{candidate function}} |
| 21 | }; |
| 22 | |
Douglas Gregor | f03d7c7 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 23 | class Z { |
Douglas Gregor | 18fe568 | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 24 | public: |
Douglas Gregor | f03d7c7 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 25 | Z(int); |
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); |
| 31 | X x3(1.0, 1.0); // expected-error{{no matching constructor for initialization of 'x3'; candidates are:}} |
| 32 | Y y(1.0); |
| 33 | X x4(3.14, y); |
| 34 | |
Douglas Gregor | f03d7c7 | 2008-11-05 15:29:30 +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 { |
Fariborz Jahanian | 8b915e7 | 2009-09-15 22:15:23 +0000 | [diff] [blame] | 43 | operator int*(); |
Fariborz Jahanian | 34acd3e | 2009-09-15 19:12:21 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | void foo(const Derived cd, Derived d) { |
Fariborz Jahanian | 8b915e7 | 2009-09-15 22:15:23 +0000 | [diff] [blame] | 47 | int *pi = cd; // expected-error {{incompatible type initializing 'struct Derived const', expected 'int *'}} |
| 48 | int *ppi = d; |
Fariborz Jahanian | 34acd3e | 2009-09-15 19:12:21 +0000 | [diff] [blame] | 49 | |
| 50 | } |