From 2eabf78eb6affeece016b71a2df152c7aa38db4d Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 13 Jun 2013 00:57:57 +0000 Subject: When copy-initializing a temporary for a reference binding, don't allow use of explicit constructors. llvm-svn: 183879 --- clang/test/SemaCXX/references.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'clang/test') diff --git a/clang/test/SemaCXX/references.cpp b/clang/test/SemaCXX/references.cpp index 4f3dab0514b..37fc2a856fd 100644 --- a/clang/test/SemaCXX/references.cpp +++ b/clang/test/SemaCXX/references.cpp @@ -137,3 +137,10 @@ namespace PR8608 { // The following crashed trying to recursively evaluate the LValue. const int &do_not_crash = do_not_crash; // expected-warning{{reference 'do_not_crash' is not yet bound to a value when used within its own initialization}} + +namespace ExplicitRefInit { + // This is invalid: we can't copy-initialize an 'A' temporary using an + // explicit constructor. + struct A { explicit A(int); }; + const A &a(0); // expected-error {{reference to type 'const ExplicitRefInit::A' could not bind to an rvalue of type 'int'}} +} -- cgit v1.2.3