Fix return of const array as pointer

This commit is contained in:
drmortalwombat 2023-08-31 14:13:43 +02:00
parent fa19e466de
commit da9b8f2a42

View File

@ -3733,6 +3733,13 @@ InterCodeGenerator::ExValue InterCodeGenerator::TranslateExpression(Declaration*
{ {
vr = TranslateExpression(procType, proc, block, exp->mLeft, destack, breakBlock, continueBlock, inlineMapper); vr = TranslateExpression(procType, proc, block, exp->mLeft, destack, breakBlock, continueBlock, inlineMapper);
if (procType->mBase->mType == DT_TYPE_POINTER && (vr.mType->mType == DT_TYPE_ARRAY || vr.mType->mType == DT_TYPE_FUNCTION))
{
vr = Dereference(proc, exp, block, vr, 1);
vr.mReference = 0;
vr.mType = procType->mBase;
}
else
vr = Dereference(proc, exp, block, vr); vr = Dereference(proc, exp, block, vr);
if (!procType->mBase || procType->mBase->mType == DT_TYPE_VOID) if (!procType->mBase || procType->mBase->mType == DT_TYPE_VOID)
@ -4725,7 +4732,7 @@ InterCodeProcedure* InterCodeGenerator::TranslateProcedure(InterCodeModule * mod
InterCodeProcedure* proc = new InterCodeProcedure(mod, dec->mLocation, dec->mQualIdent, mLinker->AddObject(dec->mLocation, dec->mQualIdent, dec->mSection, LOT_BYTE_CODE, dec->mAlignment)); InterCodeProcedure* proc = new InterCodeProcedure(mod, dec->mLocation, dec->mQualIdent, mLinker->AddObject(dec->mLocation, dec->mQualIdent, dec->mSection, LOT_BYTE_CODE, dec->mAlignment));
#if 0 #if 0
if (proc->mIdent && !strcmp(proc->mIdent->mString, "dividers")) if (proc->mIdent && !strcmp(proc->mIdent->mString, "test"))
exp->Dump(0); exp->Dump(0);
#endif #endif
#if 0 #if 0