From d412fe598be2a31380280fb9012f8876fb099e52 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 21 Jan 2011 00:27:08 +0000 Subject: [PATCH] When performing reference binding via a conversion function, perform type checking based on the actual reference type we're trying to bind the result to, rather than stripping the reference. llvm-svn: 123950 --- clang/lib/Sema/SemaInit.cpp | 9 ++------- clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp | 7 +++---- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 7360eca1e99a..e25795de40bd 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -2363,11 +2363,6 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, // functions. CXXRecordDecl *T2RecordDecl = cast(T2RecordType->getDecl()); - // Determine the type we are converting to. If we are allowed to - // convert to an rvalue, take the type that the destination type - // refers to. - QualType ToType = AllowRValues? cv1T1 : DestType; - const UnresolvedSetImpl *Conversions = T2RecordDecl->getVisibleConversionFunctions(); for (UnresolvedSetImpl::const_iterator I = Conversions->begin(), @@ -2395,10 +2390,10 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, if (ConvTemplate) S.AddTemplateConversionCandidate(ConvTemplate, I.getPair(), ActingDC, Initializer, - ToType, CandidateSet); + DestType, CandidateSet); else S.AddConversionCandidate(Conv, I.getPair(), ActingDC, - Initializer, ToType, CandidateSet); + Initializer, DestType, CandidateSet); } } } diff --git a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp index f8a13b7c2a73..4629cb64846b 100644 --- a/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp +++ b/clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-0x.cpp @@ -22,7 +22,6 @@ struct ConvertsTo { void test_rvalue_refs() { // If the initializer expression... - // - is an xvalue, class prvalue, array prvalue or function lvalue // and "cv1 T1" is reference-compatible with "cv2 T2", or @@ -54,9 +53,9 @@ void test_rvalue_refs() { // class prvalue Base&& base6 = ConvertsTo(); Base&& base7 = ConvertsTo(); - - // FIXME: function lvalue - // int (&&function1)(int) = ConvertsTo(); + + // function lvalue + int (&&function1)(int) = ConvertsTo(); } class NonCopyable {