blob: 641eaa9411f1a31a0518047e4d763add79231c87 [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor6f543152008-11-05 15:29:30 +00002class X {
3public:
Douglas Gregor7566e4a2010-04-18 02:16:12 +00004 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 Gregor6f543152008-11-05 15:29:30 +00007};
8
9class Y : public X { };
10
11void f(Y y, int *ip, float *fp) {
John McCall85f90552010-03-10 11:27:22 +000012 X x1 = y; // expected-error{{no matching constructor for initialization of 'X'}}
Douglas Gregor7566e4a2010-04-18 02:16:12 +000013 X x2 = 0; // expected-error{{no viable constructor copying variable}}
14 X x3 = ip; // expected-error{{no viable constructor copying variable}}
Douglas Gregora4b592a2009-12-19 03:01:41 +000015 X x4 = fp; // expected-error{{no viable conversion}}
Douglas Gregor7566e4a2010-04-18 02:16:12 +000016 X x2a(0); // expected-error{{call to constructor of 'X' is ambiguous}}
17 X x3a(ip);
18 X x4a(fp);
Douglas Gregor6f543152008-11-05 15:29:30 +000019}
Douglas Gregor0f3dd9a2009-02-19 00:52:42 +000020
21struct foo {
22 void bar();
23};
24
25// PR3600
Chris Lattner24b89462010-09-05 00:17:29 +000026void test(const foo *P) { P->bar(); } // expected-error{{cannot initialize object parameter of type 'foo' with an expression of type 'const foo'}}
Douglas Gregor45cf7e32010-04-02 18:24:57 +000027
28namespace PR6757 {
29 struct Foo {
30 Foo();
Douglas Gregor5ab11652010-04-17 22:01:05 +000031 Foo(Foo&); // expected-note{{candidate constructor not viable}}
Douglas Gregor45cf7e32010-04-02 18:24:57 +000032 };
33
34 struct Bar {
35 operator const Foo&() const;
36 };
37
Douglas Gregor5ab11652010-04-17 22:01:05 +000038 void f(Foo);
Douglas Gregor45cf7e32010-04-02 18:24:57 +000039
Douglas Gregor45cf7e32010-04-02 18:24:57 +000040 void g(Foo foo) {
Chris Lattner24b89462010-09-05 00:17:29 +000041 f(Bar()); // expected-error{{no viable constructor copying parameter of type 'const PR6757::Foo'}}
Douglas Gregor45cf7e32010-04-02 18:24:57 +000042 f(foo);
43 }
44}