]> granicus.if.org Git - clang/commitdiff
Implicit casts from rvalue to lvalue are not meaningful. Don't accidentally add
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 10 Nov 2011 23:32:36 +0000 (23:32 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 10 Nov 2011 23:32:36 +0000 (23:32 +0000)
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

lib/Sema/Sema.cpp
lib/Sema/SemaOverload.cpp

index d36b67aed85989d4567da734b578966bfee43554..b8dec3cb6bafab1d7c8547c58b303ff5c465ff0c 100644 (file)
@@ -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());
index 4db75a3bdac501f219a2521fcc0f6653fb4dbd43..a8fdfcb0d40518915096c1ab99128de68a6512cd 100644 (file)
@@ -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);
 }