Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | f03d7c7 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 2 | class X { |
| 3 | public: |
Douglas Gregor | 153b3ba | 2010-04-18 02:16:12 +0000 | [diff] [blame] | 4 | explicit X(const X&); // expected-note {{candidate constructor}} |
| 5 | X(int*); // expected-note 3{{candidate constructor}} |
| 6 | explicit X(float*); // expected-note {{candidate constructor}} |
Douglas Gregor | f03d7c7 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 7 | }; |
| 8 | |
| 9 | class Y : public X { }; |
| 10 | |
| 11 | void f(Y y, int *ip, float *fp) { |
John McCall | 7c2342d | 2010-03-10 11:27:22 +0000 | [diff] [blame] | 12 | X x1 = y; // expected-error{{no matching constructor for initialization of 'X'}} |
Douglas Gregor | 153b3ba | 2010-04-18 02:16:12 +0000 | [diff] [blame] | 13 | X x2 = 0; // expected-error{{no viable constructor copying variable}} |
| 14 | X x3 = ip; // expected-error{{no viable constructor copying variable}} |
Douglas Gregor | 7abfbdb | 2009-12-19 03:01:41 +0000 | [diff] [blame] | 15 | X x4 = fp; // expected-error{{no viable conversion}} |
Douglas Gregor | 153b3ba | 2010-04-18 02:16:12 +0000 | [diff] [blame] | 16 | X x2a(0); // expected-error{{call to constructor of 'X' is ambiguous}} |
| 17 | X x3a(ip); |
| 18 | X x4a(fp); |
Douglas Gregor | f03d7c7 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 19 | } |
Douglas Gregor | 611a8c4 | 2009-02-19 00:52:42 +0000 | [diff] [blame] | 20 | |
| 21 | struct foo { |
| 22 | void bar(); |
| 23 | }; |
| 24 | |
| 25 | // PR3600 |
Chris Lattner | 0c42bb6 | 2010-09-05 00:17:29 +0000 | [diff] [blame] | 26 | void test(const foo *P) { P->bar(); } // expected-error{{cannot initialize object parameter of type 'foo' with an expression of type 'const foo'}} |
Douglas Gregor | 2f59979 | 2010-04-02 18:24:57 +0000 | [diff] [blame] | 27 | |
| 28 | namespace PR6757 { |
| 29 | struct Foo { |
| 30 | Foo(); |
Douglas Gregor | 3fbaf3e | 2010-04-17 22:01:05 +0000 | [diff] [blame] | 31 | Foo(Foo&); // expected-note{{candidate constructor not viable}} |
Douglas Gregor | 2f59979 | 2010-04-02 18:24:57 +0000 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | struct Bar { |
| 35 | operator const Foo&() const; |
| 36 | }; |
| 37 | |
Douglas Gregor | 3fbaf3e | 2010-04-17 22:01:05 +0000 | [diff] [blame] | 38 | void f(Foo); |
Douglas Gregor | 2f59979 | 2010-04-02 18:24:57 +0000 | [diff] [blame] | 39 | |
Douglas Gregor | 2f59979 | 2010-04-02 18:24:57 +0000 | [diff] [blame] | 40 | void g(Foo foo) { |
Chris Lattner | 0c42bb6 | 2010-09-05 00:17:29 +0000 | [diff] [blame] | 41 | f(Bar()); // expected-error{{no viable constructor copying parameter of type 'const PR6757::Foo'}} |
Douglas Gregor | 2f59979 | 2010-04-02 18:24:57 +0000 | [diff] [blame] | 42 | f(foo); |
| 43 | } |
| 44 | } |