From 23ab245ceca3238b8126ead77adcd6275a528077 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Sun, 12 Jan 2020 13:01:46 +0100 Subject: [PATCH] Return a consistent number for const BANK() when erroring out --- src/asm/constexpr.c | 8 ++++---- test/asm/pc-bank.err | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/asm/constexpr.c b/src/asm/constexpr.c index ace38524..6742510b 100644 --- a/src/asm/constexpr.c +++ b/src/asm/constexpr.c @@ -40,15 +40,14 @@ void constexpr_Symbol(struct ConstExpression *expr, char *tzSym) void constexpr_BankSymbol(struct ConstExpression *expr, char *tzSym) { + constexpr_Number(expr, 0); + if (sym_FindSymbol(tzSym) == pPCSymbol) { if (pCurrentSection->nBank == -1) yyerror("%s's bank is not known yet", tzSym); else constexpr_Number(expr, pCurrentSection->nBank); - return; - } - - if (sym_isConstant(tzSym)) { + } else if (sym_isConstant(tzSym)) { yyerror("BANK argument must be a relocatable identifier"); } else { struct sSymbol *pSymbol = sym_FindSymbol(tzSym); @@ -64,6 +63,7 @@ void constexpr_BankSymbol(struct ConstExpression *expr, char *tzSym) void constexpr_BankSection(struct ConstExpression *expr, char *tzSectionName) { + constexpr_Number(expr, 0); struct Section *pSection = out_FindSectionByName(tzSectionName); if (!pSection) diff --git a/test/asm/pc-bank.err b/test/asm/pc-bank.err index b165f4ec..cb5d4b31 100644 --- a/test/asm/pc-bank.err +++ b/test/asm/pc-bank.err @@ -2,5 +2,4 @@ ERROR: pc-bank.asm(2): Source address $2a00 not in $FF00 to $FFFF ERROR: pc-bank.asm(11): @'s bank is not known yet -ERROR: pc-bank.asm(11): - Non-constant expression +error: Assembly aborted (2 errors)!