diff --git a/oscar64/Declaration.cpp b/oscar64/Declaration.cpp index cbae647..5d46492 100644 --- a/oscar64/Declaration.cpp +++ b/oscar64/Declaration.cpp @@ -577,16 +577,16 @@ Expression* Expression::ConstantFold(Errors * errors, LinkerSection * dataSectio uint64 i = 0; while (i < 64 && rgn->mCartridgeBanks != (1ULL << i)) i++; - if (i < 64) - { - Expression* ex = new Expression(mLocation, EX_CONSTANT); - Declaration* dec = new Declaration(mLocation, DT_CONST_INTEGER); - dec->mBase = TheUnsignedCharTypeDeclaration; - dec->mInteger = i; - ex->mDecValue = dec; - ex->mDecType = dec->mBase; - return ex; - } + if (i >= 64) + i = 0xff; + + Expression* ex = new Expression(mLocation, EX_CONSTANT); + Declaration* dec = new Declaration(mLocation, DT_CONST_INTEGER); + dec->mBase = TheUnsignedCharTypeDeclaration; + dec->mInteger = i; + ex->mDecValue = dec; + ex->mDecType = dec->mBase; + return ex; } return this; diff --git a/oscar64/InterCodeGenerator.cpp b/oscar64/InterCodeGenerator.cpp index 609f588..a2ba9d8 100644 --- a/oscar64/InterCodeGenerator.cpp +++ b/oscar64/InterCodeGenerator.cpp @@ -2659,7 +2659,8 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration* vr = CoerceType(proc, exp, block, inlineMapper, vr, vl.mType); } - StoreValue(proc, exp, block, inlineMapper, vl, vr); + if (vl.mType->mType != DT_TYPE_VOID) + StoreValue(proc, exp, block, inlineMapper, vl, vr); } } @@ -4512,7 +4513,7 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration* vr.mReference = 0; vr.mType = procType->mBase; } - else + else if (vr.mType->mType != DT_TYPE_VOID) vr = Dereference(proc, exp, block, inlineMapper, vr); if (!procType->mBase || procType->mBase->mType == DT_TYPE_VOID) diff --git a/oscar64/Parser.cpp b/oscar64/Parser.cpp index cc3b69d..4fcdc4d 100644 --- a/oscar64/Parser.cpp +++ b/oscar64/Parser.cpp @@ -1364,7 +1364,7 @@ Declaration * Parser::ParseFunctionDeclaration(Declaration* bdec) } else { - if (!(adec->mBase->mFlags & DTF_DEFINED) && adec->mBase->mType != DT_TYPE_ARRAY && !adec->mBase->mTemplate) + if (adec->mType != DT_PACK_VARIABLE && !(adec->mBase->mFlags & DTF_DEFINED) && adec->mBase->mType != DT_TYPE_ARRAY && !adec->mBase->mTemplate) mErrors->Error(adec->mLocation, EERR_UNDEFINED_OBJECT, "Type of argument not defined"); if (adec->mType == DT_PACK_VARIABLE || adec->mType == DT_PACK_ANON) @@ -2073,7 +2073,7 @@ Expression* Parser::ParseVarInitExpression(Expression* vexp, bool inner) exp->mDecType = dtype; } - else if (dtype->mType == DT_TYPE_AUTO) + else if (dtype->mType == DT_TYPE_AUTO || dtype->mType == DT_TYPE_REFERENCE) { exp = ParseRExpression(); }