Add compound literals

This commit is contained in:
drmortalwombat 2023-06-10 15:17:57 +02:00
parent ab9ae6bf0e
commit 72687b7581

View File

@ -1600,6 +1600,24 @@ Expression* Parser::ParseSimpleExpression(void)
mErrors->Error(mScanner->mLocation, EERR_SYNTAX, "')' expected"); mErrors->Error(mScanner->mLocation, EERR_SYNTAX, "')' expected");
if (exp->mType == EX_TYPE) if (exp->mType == EX_TYPE)
{
if (mScanner->mToken == TK_OPEN_BRACE)
{
Declaration* vdec = new Declaration(mScanner->mLocation, DT_VARIABLE);
vdec->mBase = exp->mDecType;
vdec->mFlags |= DTF_CONST | DTF_STATIC | DTF_GLOBAL;
Expression* nexp = new Expression(mScanner->mLocation, EX_VARIABLE);
nexp->mDecValue = vdec;
nexp->mDecType = vdec->mBase;
vdec->mValue = ParseInitExpression(vdec->mBase);
vdec->mSection = mDataSection;
vdec->mSize = vdec->mBase->mSize;
exp = nexp;
}
else
{ {
Expression* nexp = new Expression(mScanner->mLocation, EX_TYPECAST); Expression* nexp = new Expression(mScanner->mLocation, EX_TYPECAST);
nexp->mDecType = exp->mDecType; nexp->mDecType = exp->mDecType;
@ -1607,6 +1625,7 @@ Expression* Parser::ParseSimpleExpression(void)
nexp->mRight = ParsePrefixExpression(); nexp->mRight = ParsePrefixExpression();
exp = nexp->ConstantFold(mErrors); exp = nexp->ConstantFold(mErrors);
} }
}
break; break;
case TK_ASM: case TK_ASM:
mScanner->NextToken(); mScanner->NextToken();