Constant folding of pointer type cast
This commit is contained in:
parent
daeb3ddfdd
commit
84a8bf22e8
|
@ -732,6 +732,13 @@ Expression* Expression::ConstantFold(Errors * errors, LinkerSection * dataSectio
|
||||||
ex->mDecType = mDecType;
|
ex->mDecType = mDecType;
|
||||||
return ex;
|
return ex;
|
||||||
}
|
}
|
||||||
|
else if (mLeft->mDecValue->mType == DT_CONST_POINTER)
|
||||||
|
{
|
||||||
|
Expression* ex = new Expression(mLocation, EX_CONSTANT);
|
||||||
|
ex->mDecValue = mLeft->mDecValue;
|
||||||
|
ex->mDecType = mDecType;
|
||||||
|
return ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (mDecType->mType == DT_TYPE_INTEGER)
|
else if (mDecType->mType == DT_TYPE_INTEGER)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1510,6 +1510,8 @@ Declaration * Parser::CopyConstantInitializer(int offset, Declaration* dtype, Ex
|
||||||
|
|
||||||
exp = CoerceExpression(exp, dtype);
|
exp = CoerceExpression(exp, dtype);
|
||||||
|
|
||||||
|
exp = exp->ConstantFold(mErrors, mDataSection);
|
||||||
|
|
||||||
Declaration* dec = exp->mDecValue;
|
Declaration* dec = exp->mDecValue;
|
||||||
|
|
||||||
if (exp->mType == EX_CONSTANT)
|
if (exp->mType == EX_CONSTANT)
|
||||||
|
|
Loading…
Reference in New Issue