Fix template void return of reference parameter

This commit is contained in:
drmortalwombat 2024-09-30 16:54:50 +02:00
parent c3b46d6a78
commit 581137ade7
3 changed files with 15 additions and 14 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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();
}