Fix temporary object structured initialization
This commit is contained in:
parent
d7bfd0a668
commit
bcd118a8b3
|
@ -2696,6 +2696,10 @@ bool Declaration::CanAssign(const Declaration* fromType) const
|
|||
return this->CanAssign(fromType->mBase);
|
||||
return false;
|
||||
}
|
||||
else if (mType == DT_TYPE_ARRAY && fromType->mType == DT_TYPE_ARRAY)
|
||||
{
|
||||
return mSize == fromType->mSize && mStride == fromType->mStride && mBase->CanAssign(fromType->mBase);
|
||||
}
|
||||
else if (mType == DT_TYPE_POINTER)
|
||||
{
|
||||
if (fromType->mType == DT_TYPE_POINTER || fromType->mType == DT_TYPE_ARRAY)
|
||||
|
|
|
@ -5814,33 +5814,41 @@ Expression* Parser::ParseCastExpression(Expression* exp)
|
|||
if (mScanner->mToken == TK_OPEN_BRACE)
|
||||
{
|
||||
Declaration* cdec = new Declaration(mScanner->mLocation, DT_VARIABLE);
|
||||
cdec->mBase = exp->mDecType->ToConstType();
|
||||
cdec->mFlags |= DTF_CONST | DTF_STATIC | DTF_GLOBAL | DTF_DEFINED;
|
||||
cdec->mFlags |= DTF_CONST | DTF_STATIC | DTF_GLOBAL;
|
||||
cdec->mBase = exp->mDecType;
|
||||
|
||||
Expression* cexp = new Expression(mScanner->mLocation, EX_VARIABLE);
|
||||
cexp->mDecValue = cdec;
|
||||
cexp->mDecType = cdec->mBase;
|
||||
|
||||
cdec->mValue = ParseInitExpression(cdec->mBase);
|
||||
cdec->mSection = mDataSection;
|
||||
cdec->mSize = cdec->mBase->mSize;
|
||||
|
||||
Declaration* vdec = new Declaration(mScanner->mLocation, DT_VARIABLE);
|
||||
vdec->mBase = exp->mDecType;
|
||||
vdec->mVarIndex = mLocalIndex++;
|
||||
vdec->mFlags |= DTF_DEFINED;
|
||||
vdec->mSize = vdec->mBase->mSize;
|
||||
if (mFunctionType)
|
||||
{
|
||||
Declaration* vdec = new Declaration(mScanner->mLocation, DT_VARIABLE);
|
||||
vdec->mBase = cdec->mBase;
|
||||
vdec->mVarIndex = mLocalIndex++;
|
||||
vdec->mFlags |= DTF_DEFINED;
|
||||
vdec->mSize = vdec->mBase->mSize;
|
||||
|
||||
Expression* nexp = new Expression(mScanner->mLocation, EX_VARIABLE);
|
||||
nexp->mDecValue = vdec;
|
||||
nexp->mDecType = vdec->mBase;
|
||||
Expression* nexp = new Expression(mScanner->mLocation, EX_VARIABLE);
|
||||
nexp->mDecValue = vdec;
|
||||
nexp->mDecType = vdec->mBase;
|
||||
|
||||
Expression* iexp = new Expression(mScanner->mLocation, EX_INITIALIZATION);
|
||||
iexp->mLeft = nexp;
|
||||
iexp->mRight = cexp;
|
||||
iexp->mDecType = exp->mDecType;
|
||||
Expression* iexp = new Expression(mScanner->mLocation, EX_INITIALIZATION);
|
||||
iexp->mLeft = nexp;
|
||||
iexp->mRight = cexp;
|
||||
iexp->mDecType = cdec->mBase;
|
||||
|
||||
exp = iexp;
|
||||
cdec->mBase = cdec->mBase->ToConstType();
|
||||
|
||||
exp = iexp;
|
||||
}
|
||||
else
|
||||
exp = cexp;
|
||||
|
||||
cexp->mDecType = cdec->mBase;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue