Constant expression evalation: const_cast support.

llvm-svn: 144382
This commit is contained in:
Richard Smith 2011-11-11 08:28:03 +00:00
parent 1a9ad0fbee
commit 6804be5a2e
2 changed files with 14 additions and 6 deletions

View 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;
}

View 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 {};