[cfe-commits] r144382 - in /cfe/trunk: lib/AST/ExprConstant.cpp test/SemaCXX/constant-expression-cxx11.cpp
Richard Smith
richard-llvm at metafoo.co.uk
Fri Nov 11 00:28:04 PST 2011
Author: rsmith
Date: Fri Nov 11 02:28:03 2011
New Revision: 144382
URL: http://llvm.org/viewvc/llvm-project?rev=144382&view=rev
Log:
Constant expression evalation: const_cast support.
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=144382&r1=144381&r2=144382&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Nov 11 02:28:03 2011
@@ -830,11 +830,8 @@
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 @@
return false;
}
- assert(Info.Ctx.hasSameUnqualifiedType(ObjType, SubType) &&
- "Unexpected subobject type");
Obj = CCValue(*O, CCValue::GlobalValue());
return true;
}
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=144382&r1=144381&r2=144382&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp (original)
+++ cfe/trunk/test/SemaCXX/constant-expression-cxx11.cpp Fri Nov 11 02:28:03 2011
@@ -77,6 +77,19 @@
}
+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 {};
More information about the cfe-commits
mailing list