shithub: rgbds

Download patch

ref: 23ab245ceca3238b8126ead77adcd6275a528077
parent: eb824765918b7c54b08a700f5123092cfcae3fc8
author: ISSOtm <[email protected]>
date: Sun Jan 12 08:01:46 EST 2020

Return a consistent number for const BANK() when erroring out

--- a/src/asm/constexpr.c
+++ b/src/asm/constexpr.c
@@ -40,15 +40,14 @@
 
 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_BankSection(struct ConstExpression *expr, char *tzSectionName)
 {
+	constexpr_Number(expr, 0);
 	struct Section *pSection = out_FindSectionByName(tzSectionName);
 
 	if (!pSection)
--- a/test/asm/pc-bank.err
+++ b/test/asm/pc-bank.err
@@ -2,5 +2,4 @@
     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)!