diff --git a/oscar64/Declaration.cpp b/oscar64/Declaration.cpp index 6101ccc..5cf79f2 100644 --- a/oscar64/Declaration.cpp +++ b/oscar64/Declaration.cpp @@ -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) diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index 2f54500..c5829b9 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -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 {