mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Cannot start a new section that's already on the stack
This is only relevant for FRAGMENT or UNION sections, since normal ones would fail with "Section already defined previously". Fixes #730
This commit is contained in:
@@ -87,15 +87,10 @@ static inline void reserveSpace(uint32_t delta_size)
|
|||||||
|
|
||||||
struct Section *out_FindSectionByName(const char *name)
|
struct Section *out_FindSectionByName(const char *name)
|
||||||
{
|
{
|
||||||
struct Section *sect = pSectionList;
|
for (struct Section *sect = pSectionList; sect; sect = sect->next) {
|
||||||
|
|
||||||
while (sect) {
|
|
||||||
if (strcmp(name, sect->name) == 0)
|
if (strcmp(name, sect->name) == 0)
|
||||||
return sect;
|
return sect;
|
||||||
|
|
||||||
sect = sect->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -376,6 +371,11 @@ void out_NewSection(char const *name, uint32_t type, uint32_t org,
|
|||||||
if (currentLoadSection)
|
if (currentLoadSection)
|
||||||
fatalerror("Cannot change the section within a `LOAD` block\n");
|
fatalerror("Cannot change the section within a `LOAD` block\n");
|
||||||
|
|
||||||
|
for (struct SectionStackEntry *stack = sectionStack; stack; stack = stack->next) {
|
||||||
|
if (stack->section && !strcmp(name, stack->section->name))
|
||||||
|
fatalerror("Section '%s' is already on the stack\n", name);
|
||||||
|
}
|
||||||
|
|
||||||
struct Section *sect = getSection(name, type, org, attribs, mod);
|
struct Section *sect = getSection(name, type, org, attribs, mod);
|
||||||
|
|
||||||
changeSection();
|
changeSection();
|
||||||
|
|||||||
7
test/asm/new-pushed-section.asm
Normal file
7
test/asm/new-pushed-section.asm
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
SECTION FRAGMENT "A", ROM0
|
||||||
|
db 1
|
||||||
|
PUSHS
|
||||||
|
SECTION FRAGMENT "A", ROM0
|
||||||
|
db 2
|
||||||
|
POPS
|
||||||
|
db 3
|
||||||
2
test/asm/new-pushed-section.err
Normal file
2
test/asm/new-pushed-section.err
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
FATAL: new-pushed-section.asm(4):
|
||||||
|
Section 'A' is already on the stack
|
||||||
0
test/asm/new-pushed-section.out
Normal file
0
test/asm/new-pushed-section.out
Normal file
Reference in New Issue
Block a user