Constant folding of pointer type cast

This commit is contained in:
drmortalwombat 2024-09-29 17:24:42 +02:00
parent daeb3ddfdd
commit 84a8bf22e8
2 changed files with 9 additions and 0 deletions

View File

@ -732,6 +732,13 @@ Expression* Expression::ConstantFold(Errors * errors, LinkerSection * dataSectio
ex->mDecType = mDecType;
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)
{

View File

@ -1510,6 +1510,8 @@ Declaration * Parser::CopyConstantInitializer(int offset, Declaration* dtype, Ex
exp = CoerceExpression(exp, dtype);
exp = exp->ConstantFold(mErrors, mDataSection);
Declaration* dec = exp->mDecValue;
if (exp->mType == EX_CONSTANT)