diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-03-25 00:20:38 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-03-25 00:20:38 +0000 |
commit | f0e0b17d0504d25b4673de015cf7401e2296323c (patch) | |
tree | 9a719c5bb729b1ac1a11856a94530bb7eeb6caff /lib/Sema/SemaExprCXX.cpp | |
parent | c6e378e7d4e14b451f50158968d012dace6646d2 (diff) |
Kill off two more uses of Sema::CheckReferenceInit in favor of the new
initialization code. Exposed a bug where we were not marking an
implicit conversion as an lvalue when we were forming a call to a
conversion function whose return type is a reference.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99459 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprCXX.cpp')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 366089f2ab..3cba68694b 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -2048,28 +2048,26 @@ static bool FindConditionalOverload(Sema &Self, Expr *&LHS, Expr *&RHS, /// handles the reference binding specially. static bool ConvertForConditional(Sema &Self, Expr *&E, const ImplicitConversionSequence &ICS) { - if (ICS.isStandard() && ICS.Standard.ReferenceBinding) { - assert(ICS.Standard.DirectBinding && + if ((ICS.isStandard() && ICS.Standard.ReferenceBinding) || + (ICS.isUserDefined() && ICS.UserDefined.After.ReferenceBinding)) { + assert(((ICS.isStandard() && ICS.Standard.DirectBinding) || + (ICS.isUserDefined() && ICS.UserDefined.After.DirectBinding)) && "TryClassUnification should never generate indirect ref bindings"); - // FIXME: CheckReferenceInit should be able to reuse the ICS instead of - // redoing all the work. - return Self.CheckReferenceInit(E, Self.Context.getLValueReferenceType( - TargetType(ICS)), - /*FIXME:*/E->getLocStart(), - /*SuppressUserConversions=*/false, - /*AllowExplicit=*/false, - /*ForceRValue=*/false); - } - if (ICS.isUserDefined() && ICS.UserDefined.After.ReferenceBinding) { - assert(ICS.UserDefined.After.DirectBinding && - "TryClassUnification should never generate indirect ref bindings"); - return Self.CheckReferenceInit(E, Self.Context.getLValueReferenceType( - TargetType(ICS)), - /*FIXME:*/E->getLocStart(), - /*SuppressUserConversions=*/false, - /*AllowExplicit=*/false, - /*ForceRValue=*/false); + InitializedEntity Entity + = InitializedEntity::InitializeTemporary( + Self.Context.getLValueReferenceType(TargetType(ICS))); + InitializationKind Kind = InitializationKind::CreateCopy(E->getLocStart(), + SourceLocation()); + InitializationSequence InitSeq(Self, Entity, Kind, &E, 1); + Sema::OwningExprResult Result = InitSeq.Perform(Self, Entity, Kind, + Sema::MultiExprArg(Self, (void **)&E, 1)); + if (Result.isInvalid()) + return true; + + E = Result.takeAs<Expr>(); + return false; } + if (Self.PerformImplicitConversion(E, TargetType(ICS), ICS, Sema::AA_Converting)) return true; return false; |