1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc class X { 3*f4a2713aSLionel Sambuc public: 4*f4a2713aSLionel Sambuc explicit X(const X&); // expected-note {{candidate constructor}} 5*f4a2713aSLionel Sambuc X(int*); // expected-note 3{{candidate constructor}} 6*f4a2713aSLionel Sambuc explicit X(float*); // expected-note {{candidate constructor}} 7*f4a2713aSLionel Sambuc }; 8*f4a2713aSLionel Sambuc 9*f4a2713aSLionel Sambuc class Y : public X { }; 10*f4a2713aSLionel Sambuc f(Y y,int * ip,float * fp)11*f4a2713aSLionel Sambucvoid f(Y y, int *ip, float *fp) { 12*f4a2713aSLionel Sambuc X x1 = y; // expected-error{{no matching constructor for initialization of 'X'}} 13*f4a2713aSLionel Sambuc X x2 = 0; 14*f4a2713aSLionel Sambuc X x3 = ip; 15*f4a2713aSLionel Sambuc X x4 = fp; // expected-error{{no viable conversion}} 16*f4a2713aSLionel Sambuc X x2a(0); // expected-error{{call to constructor of 'X' is ambiguous}} 17*f4a2713aSLionel Sambuc X x3a(ip); 18*f4a2713aSLionel Sambuc X x4a(fp); 19*f4a2713aSLionel Sambuc } 20*f4a2713aSLionel Sambuc 21*f4a2713aSLionel Sambuc struct foo { 22*f4a2713aSLionel Sambuc void bar(); // expected-note{{declared here}} 23*f4a2713aSLionel Sambuc }; 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel Sambuc // PR3600 test(const foo * P)26*f4a2713aSLionel Sambucvoid test(const foo *P) { P->bar(); } // expected-error{{'bar' not viable: 'this' argument has type 'const foo', but function is not marked const}} 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc namespace PR6757 { 29*f4a2713aSLionel Sambuc struct Foo { 30*f4a2713aSLionel Sambuc Foo(); 31*f4a2713aSLionel Sambuc Foo(Foo&); // expected-note{{candidate constructor not viable}} 32*f4a2713aSLionel Sambuc }; 33*f4a2713aSLionel Sambuc 34*f4a2713aSLionel Sambuc struct Bar { 35*f4a2713aSLionel Sambuc operator const Foo&() const; 36*f4a2713aSLionel Sambuc }; 37*f4a2713aSLionel Sambuc 38*f4a2713aSLionel Sambuc void f(Foo); 39*f4a2713aSLionel Sambuc g(Foo foo)40*f4a2713aSLionel Sambuc void g(Foo foo) { 41*f4a2713aSLionel Sambuc f(Bar()); // expected-error{{no viable constructor copying parameter of type 'const PR6757::Foo'}} 42*f4a2713aSLionel Sambuc f(foo); 43*f4a2713aSLionel Sambuc } 44*f4a2713aSLionel Sambuc } 45*f4a2713aSLionel Sambuc 46*f4a2713aSLionel Sambuc namespace DR5 { 47*f4a2713aSLionel Sambuc // Core issue 5: if a temporary is created in copy-initialization, it is of 48*f4a2713aSLionel Sambuc // the cv-unqualified version of the destination type. 49*f4a2713aSLionel Sambuc namespace Ex1 { 50*f4a2713aSLionel Sambuc struct C { }; 51*f4a2713aSLionel Sambuc C c; 52*f4a2713aSLionel Sambuc struct A { 53*f4a2713aSLionel Sambuc A(const A&); 54*f4a2713aSLionel Sambuc A(const C&); 55*f4a2713aSLionel Sambuc }; 56*f4a2713aSLionel Sambuc const volatile A a = c; // ok 57*f4a2713aSLionel Sambuc } 58*f4a2713aSLionel Sambuc 59*f4a2713aSLionel Sambuc namespace Ex2 { 60*f4a2713aSLionel Sambuc struct S { 61*f4a2713aSLionel Sambuc S(S&&); // expected-warning {{C++11}} 62*f4a2713aSLionel Sambuc S(int); 63*f4a2713aSLionel Sambuc }; 64*f4a2713aSLionel Sambuc const S a(0); 65*f4a2713aSLionel Sambuc const S b = 0; 66*f4a2713aSLionel Sambuc } 67*f4a2713aSLionel Sambuc } 68