shithub: rgbds

Download patch

ref: f6f25296a01bd5b8c2382ebda2eff45323280506
parent: cb62076f8c5f0ea56dabb154912949e63ba59e9e
author: ISSOtm <[email protected]>
date: Sat Mar 7 13:02:06 EST 2020

Fix passing constant label to BANK() causing an error

--- a/include/asm/rpn.h
+++ b/include/asm/rpn.h
@@ -42,8 +42,8 @@
 void rpn_LOW(struct Expression *expr, const struct Expression *src);
 void rpn_UNNEG(struct Expression *expr, const struct Expression *src);
 void rpn_UNNOT(struct Expression *expr, const struct Expression *src);
-void rpn_BankSymbol(struct Expression *expr, char *tzSym);
-void rpn_BankSection(struct Expression *expr, char *tzSectionName);
+void rpn_BankSymbol(struct Expression *expr, char const *tzSym);
+void rpn_BankSection(struct Expression *expr, char const *tzSectionName);
 void rpn_BankSelf(struct Expression *expr);
 void rpn_Init(struct Expression *expr);
 void rpn_Free(struct Expression *expr);
--- a/include/asm/symbol.h
+++ b/include/asm/symbol.h
@@ -59,10 +59,14 @@
 	    || sym->type == SYM_SET;
 }
 
+static inline bool sym_IsLabel(struct sSymbol const *sym)
+{
+	return sym->type == SYM_LABEL || sym->type == SYM_REF;
+}
+
 static inline bool sym_IsLocal(struct sSymbol const *sym)
 {
-	return (sym->type == SYM_LABEL || sym->type == SYM_REF)
-		&& strchr(sym->tzName, '.');
+	return sym_IsLabel(sym) && strchr(sym->tzName, '.');
 }
 
 static inline bool sym_IsExported(struct sSymbol const *sym)
--- a/src/asm/rpn.c
+++ b/src/asm/rpn.c
@@ -165,7 +165,7 @@
 	}
 }
 
-void rpn_BankSymbol(struct Expression *expr, char *tzSym)
+void rpn_BankSymbol(struct Expression *expr, char const *tzSym)
 {
 	struct sSymbol const *sym = sym_FindSymbol(tzSym);
 
@@ -176,7 +176,7 @@
 	}
 
 	rpn_Init(expr);
-	if (sym && sym_IsConstant(sym)) {
+	if (sym && !sym_IsLabel(sym)) {
 		yyerror("BANK argument must be a relocatable identifier");
 	} else {
 		sym_Ref(tzSym);
@@ -198,7 +198,7 @@
 	}
 }
 
-void rpn_BankSection(struct Expression *expr, char *tzSectionName)
+void rpn_BankSection(struct Expression *expr, char const *tzSectionName)
 {
 	rpn_Init(expr);