rgbasm: Report conflicting file/line number for duplicate sections

This commit is contained in:
dannye
2021-02-21 23:43:44 -06:00
committed by Eldred Habert
parent cc1129093d
commit 929e2a4490
3 changed files with 8 additions and 3 deletions

View File

@@ -22,6 +22,8 @@ struct Section {
char *name; char *name;
enum SectionType type; enum SectionType type;
enum SectionModifier modifier; 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 size;
uint32_t org; uint32_t org;
uint32_t bank; uint32_t bank;

View File

@@ -230,8 +230,9 @@ static void mergeSections(struct Section *sect, enum SectionType type, uint32_t
break; break;
case SECTION_NORMAL: case SECTION_NORMAL:
// TODO: this should report where the section was defined fail("Section already defined previously at ");
fail("Section already defined previously\n"); fstk_Dump(sect->src, sect->fileLine);
putc('\n', stderr);
break; break;
} }
} }
@@ -325,6 +326,8 @@ static struct Section *getSection(char const *name, enum SectionType type, uint3
sect->type = type; sect->type = type;
sect->modifier = mod; sect->modifier = mod;
sect->src = fstk_GetFileStack();
sect->fileLine = lexer_GetLineNo();
sect->size = 0; sect->size = 0;
sect->org = org; sect->org = org;
sect->bank = bank; sect->bank = bank;

View File

@@ -1,4 +1,4 @@
ERROR: duplicate-section.asm(4): ERROR: duplicate-section.asm(4):
Section already defined previously Section already defined previously at duplicate-section.asm(2)
FATAL: duplicate-section.asm(4): FATAL: duplicate-section.asm(4):
Cannot create section "sec" (1 error) Cannot create section "sec" (1 error)