diff --git a/include/asm/symbol.h b/include/asm/symbol.h index fa02a821..7bcc1407 100644 --- a/include/asm/symbol.h +++ b/include/asm/symbol.h @@ -125,7 +125,6 @@ struct Symbol *sym_FindSymbol(char const *symName); struct Symbol *sym_AddMacro(char const *symName, int32_t defLineNo, char *body, size_t size); struct Symbol *sym_Ref(char const *symName); struct Symbol *sym_AddString(char const *symName, char const *value); -uint32_t sym_GetDefinedValue(char const *s); void sym_Purge(char const *symName); void sym_Init(void); diff --git a/src/asm/rpn.c b/src/asm/rpn.c index cf94333e..7e51df86 100644 --- a/src/asm/rpn.c +++ b/src/asm/rpn.c @@ -309,7 +309,9 @@ bool rpn_IsDiffConstant(struct Expression const *src, struct Symbol const *sym) if (!sym1 || !sym || sym1->type != SYM_LABEL || sym->type != SYM_LABEL) return false; - return sym_GetSection(sym1) == sym_GetSection(sym); + struct Section const *section1 = sym_GetSection(sym1); + struct Section const *section2 = sym_GetSection(sym); + return section1 && (section1 == section2); } static bool isDiffConstant(struct Expression const *src1, diff --git a/src/asm/symbol.c b/src/asm/symbol.c index 59c77541..0fd7ba65 100644 --- a/src/asm/symbol.c +++ b/src/asm/symbol.c @@ -322,23 +322,6 @@ uint32_t sym_GetConstantValue(char const *s) return 0; } -/* - * Return a defined symbols value... aborts if not defined yet - */ -uint32_t sym_GetDefinedValue(char const *s) -{ - struct Symbol const *sym = sym_FindSymbol(s); - - if (sym == NULL || !sym_IsDefined(sym)) - error("'%s' not defined\n", s); - else if (!sym_IsNumeric(sym)) - error("'%s' is a macro or string symbol\n", s); - else - return sym_GetValue(sym); - - return 0; -} - char const *sym_GetCurrentSymbolScope(void) { return labelScope; diff --git a/test/asm/use-label-outside-section.asm b/test/asm/use-label-outside-section.asm new file mode 100644 index 00000000..73440b5d --- /dev/null +++ b/test/asm/use-label-outside-section.asm @@ -0,0 +1,3 @@ +lab: + PRINTV lab-lab + PRINTT "\n" diff --git a/test/asm/use-label-outside-section.err b/test/asm/use-label-outside-section.err new file mode 100644 index 00000000..893a7012 --- /dev/null +++ b/test/asm/use-label-outside-section.err @@ -0,0 +1,5 @@ +ERROR: use-label-outside-section.asm(1): + Label "lab" created outside of a SECTION +ERROR: use-label-outside-section.asm(2): + Expected constant expression: 'lab' is not constant at assembly time +error: Assembly aborted (2 errors)! diff --git a/test/asm/use-label-outside-section.out b/test/asm/use-label-outside-section.out new file mode 100644 index 00000000..ebfabbe4 --- /dev/null +++ b/test/asm/use-label-outside-section.out @@ -0,0 +1 @@ +$0