ref: 929e2a44901092fc7a7aad2bf767da5aa9b7d618
parent: cc1129093d87b47e9d0a30146f9a0c78a96774e4
author: dannye <33dannye@gmail.com>
date: Sun Feb 21 18:43:44 EST 2021
rgbasm: Report conflicting file/line number for duplicate sections
--- a/include/asm/section.h
+++ b/include/asm/section.h
@@ -22,6 +22,8 @@
char *name;
enum SectionType type;
enum SectionModifier modifier;
+ struct FileStackNode *src; /* Where the section was defined */
+ uint32_t fileLine; /* Line where the section was defined */
uint32_t size;
uint32_t org;
uint32_t bank;
--- a/src/asm/section.c
+++ b/src/asm/section.c
@@ -230,8 +230,9 @@
break;
case SECTION_NORMAL:
- // TODO: this should report where the section was defined
- fail("Section already defined previously\n");
+ fail("Section already defined previously at ");
+ fstk_Dump(sect->src, sect->fileLine);
+ putc('\n', stderr);
break;
}
}
@@ -325,6 +326,8 @@
sect->type = type;
sect->modifier = mod;
+ sect->src = fstk_GetFileStack();
+ sect->fileLine = lexer_GetLineNo();
sect->size = 0;
sect->org = org;
sect->bank = bank;
--- a/test/asm/duplicate-section.err
+++ b/test/asm/duplicate-section.err
@@ -1,4 +1,4 @@
ERROR: duplicate-section.asm(4):
- Section already defined previously
+ Section already defined previously at duplicate-section.asm(2)
FATAL: duplicate-section.asm(4):
Cannot create section "sec" (1 error)