]> granicus.if.org Git - clang/commitdiff
Constant expression evalation: const_cast support.
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 11 Nov 2011 08:28:03 +0000 (08:28 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 11 Nov 2011 08:28:03 +0000 (08:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144382 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/SemaCXX/constant-expression-cxx11.cpp

index 2027b42d966383e8d81c83064bcf2ec3c95274c3..7eb818d223e74f721cd70e10c2519a810576db53 100644 (file)
@@ -830,11 +830,8 @@ static bool ExtractSubobject(EvalInfo &Info, CCValue &Obj, QualType ObjType,
                              const SubobjectDesignator &Sub, QualType SubType) {
   if (Sub.Invalid || Sub.OnePastTheEnd)
     return false;
-  if (Sub.Entries.empty()) {
-    assert(Info.Ctx.hasSameUnqualifiedType(ObjType, SubType) &&
-           "Unexpected subobject type");
+  if (Sub.Entries.empty())
     return true;
-  }
 
   assert(!Obj.isLValue() && "extracting subobject of lvalue");
   const APValue *O = &Obj;
@@ -877,8 +874,6 @@ static bool ExtractSubobject(EvalInfo &Info, CCValue &Obj, QualType ObjType,
       return false;
   }
 
-  assert(Info.Ctx.hasSameUnqualifiedType(ObjType, SubType) &&
-         "Unexpected subobject type");
   Obj = CCValue(*O, CCValue::GlobalValue());
   return true;
 }
index c1d4a1109a278ab38b051455c34fa7cc8b1032da..71a98a5fcfc593f8e05cfc5d6265505804ef796f 100644 (file)
@@ -77,6 +77,19 @@ namespace DerivedToVBaseCast {
 
 }
 
+namespace ConstCast {
+
+constexpr int n1 = 0;
+constexpr int n2 = const_cast<int&>(n1);
+constexpr int *n3 = const_cast<int*>(&n1);
+constexpr int n4 = *const_cast<int*>(&n1);
+constexpr const int * const *n5 = const_cast<const int* const*>(&n3);
+constexpr int **n6 = const_cast<int**>(&n3);
+constexpr int n7 = **n5;
+constexpr int n8 = **n6;
+
+}
+
 namespace TemplateArgumentConversion {
   template<int n> struct IntParam {};