From 2a670227465c2be203f30650676da8b51715c44f Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 2 Jul 2018 23:25:22 +0000 Subject: Per C++ [over.match.copy]p1, direct-initialization of a reference can only invoke converting constructors of the reference's underlying type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336153 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/CXX') diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp index e775e8f0e3..869fc4f014 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5.cpp @@ -61,3 +61,12 @@ namespace test3 { unsigned &t9 = (a->bitY += 3); // expected-error {{non-const reference cannot bind to bit-field 'bitY'}} } } + +namespace explicit_ctor { + struct A {}; + struct B { // expected-note 2{{candidate}} + explicit B(const A&); + }; + A a; + const B &b(a); // expected-error {{no viable conversion}} +} -- cgit v1.2.1