From: Richard Smith Date: Thu, 10 Nov 2011 23:32:36 +0000 (+0000) Subject: Implicit casts from rvalue to lvalue are not meaningful. Don't accidentally add X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=acdfa4d504a8f2514d60569f9ce55d45f11795b9;p=clang Implicit casts from rvalue to lvalue are not meaningful. Don't accidentally add them when performing a const conversion on the implicit object argument for a member operator call on an rvalue. No change to the testsuite: the test for this change is that the added assertion does not fire any more. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144333 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index d36b67aed8..b8dec3cb6b 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -252,6 +252,7 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty, break; } } + assert((VK == VK_RValue || !E->isRValue()) && "can't cast rvalue to lvalue"); #endif QualType ExprTy = Context.getCanonicalType(E->getType()); diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 4db75a3bda..a8fdfcb0d4 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -4090,7 +4090,7 @@ Sema::PerformObjectArgumentInitialization(Expr *From, if (!Context.hasSameType(From->getType(), DestType)) From = ImpCastExprToType(From, DestType, CK_NoOp, - From->getType()->isPointerType() ? VK_RValue : VK_LValue).take(); + From->getValueKind()).take(); return Owned(From); }