forked from OSchip/llvm-project
Constant expression evalation: const_cast support.
llvm-svn: 144382
This commit is contained in:
parent
1a9ad0fbee
commit
6804be5a2e
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {};
|
||||
|
||||
|
|
Loading…
Reference in New Issue