[cfe-commits] r144333 - in /cfe/trunk/lib/Sema: Sema.cpp SemaOverload.cpp

Richard Smith richard-llvm at metafoo.co.uk
Thu Nov 10 15:32:36 PST 2011


Author: rsmith
Date: Thu Nov 10 17:32:36 2011
New Revision: 144333

URL: http://llvm.org/viewvc/llvm-project?rev=144333&view=rev
Log:
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.

Modified:
    cfe/trunk/lib/Sema/Sema.cpp
    cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=144333&r1=144332&r2=144333&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Thu Nov 10 17:32:36 2011
@@ -252,6 +252,7 @@
       break;
     }
   }
+  assert((VK == VK_RValue || !E->isRValue()) && "can't cast rvalue to lvalue");
 #endif
 
   QualType ExprTy = Context.getCanonicalType(E->getType());

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=144333&r1=144332&r2=144333&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Thu Nov 10 17:32:36 2011
@@ -4090,7 +4090,7 @@
 
   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);
 }
 





More information about the cfe-commits mailing list