From 1bc5a2ad7ee0ed3428afb0dce0cdee1ff4827a3a Mon Sep 17 00:00:00 2001 From: drmortalwombat <90205530+drmortalwombat@users.noreply.github.com> Date: Sun, 28 Jul 2024 14:41:29 +0200 Subject: [PATCH] Add compile time error for undefined labels --- oscar64/InterCodeGenerator.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/oscar64/InterCodeGenerator.cpp b/oscar64/InterCodeGenerator.cpp index 68af5a1..f2bd4bd 100644 --- a/oscar64/InterCodeGenerator.cpp +++ b/oscar64/InterCodeGenerator.cpp @@ -1091,10 +1091,15 @@ void InterCodeGenerator::TranslateAssembler(InterCodeModule* mod, Expression* ex if (aexp->mBase->mBase) disp = aexp->mOffset + aexp->mBase->mInteger - offset - 1; else - mErrors->Error(aexp->mLocation, EERR_ASM_INVALD_OPERAND, "Undefined immediate operand", aexp->mBase->mQualIdent); + mErrors->Error(aexp->mLocation, EERR_ASM_INVALD_OPERAND, "Undefined label", aexp->mBase->mQualIdent); + } + else if (aexp->mType == DT_LABEL) + { + if (aexp->mBase) + disp = aexp->mInteger - offset - 1; + else + mErrors->Error(aexp->mLocation, EERR_ASM_INVALD_OPERAND, "Undefined label", aexp->mQualIdent); } - else - disp = aexp->mInteger - offset - 1; if (disp < -128 || disp > 127) mErrors->Error(aexp->mLocation, EERR_ASM_INVALD_OPERAND, "Branch target out of range");