[cfe-commits] r143364 - in /cfe/trunk: lib/Sema/SemaCast.cpp test/SemaCXX/constant-expression-cxx11.cpp

Eli Friedman eli.friedman at gmail.com
Mon Oct 31 13:59:03 PDT 2011


Author: efriedma
Date: Mon Oct 31 15:59:03 2011
New Revision: 143364

URL: http://llvm.org/viewvc/llvm-project?rev=143364&view=rev
Log:
Add missing lvalue-to-rvalue conversion.


Modified:
    cfe/trunk/lib/Sema/SemaCast.cpp
    cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp

Modified: cfe/trunk/lib/Sema/SemaCast.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCast.cpp?rev=143364&r1=143363&r2=143364&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCast.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCast.cpp Mon Oct 31 15:59:03 2011
@@ -529,6 +529,12 @@
 /// Refer to C++ 5.2.7 for details. Dynamic casts are used mostly for runtime-
 /// checked downcasts in class hierarchies.
 void CastOperation::CheckDynamicCast() {
+  if (ValueKind == VK_RValue && !isPlaceholder(BuiltinType::Overload)) {
+    SrcExpr = Self.DefaultFunctionArrayLvalueConversion(SrcExpr.take());
+    if (SrcExpr.isInvalid()) // if conversion failed, don't report another error
+      return;
+  }
+
   QualType OrigSrcType = SrcExpr.get()->getType();
   QualType DestType = Self.Context.getCanonicalType(this->DestType);
 

Modified: cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp?rev=143364&r1=143363&r2=143364&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp Mon Oct 31 15:59:03 2011
@@ -197,6 +197,9 @@
 constexpr bool s5 = &x < &x;
 constexpr bool s6 = &x > &x;
 
+constexpr S* sptr = &s;
+constexpr bool dyncast = sptr == dynamic_cast<S*>(sptr);
+
 using check = int[m1 + (m2<<1) + (m3<<2) + (m4<<3) + (m5<<4) + (m6<<5) +
                   (n1<<6) + (n2<<7) + (n7<<8) + (n8<<9) + (g1<<10) + (g2<<11) +
                (s1<<12) + (s2<<13) + (s3<<14) + (s4<<15) + (s5<<16) + (s6<<17)];





More information about the cfe-commits mailing list