Make UNION-related errors non-fatal

This commit is contained in:
ISSOtm
2021-05-02 23:57:03 +02:00
parent 1d01268249
commit 75ce230dce

View File

@@ -534,10 +534,14 @@ static void createPatch(enum PatchType type, struct Expression const *expr, uint
void sect_StartUnion(void) void sect_StartUnion(void)
{ {
if (!currentSection) if (!currentSection) {
fatalerror("UNIONs must be inside a SECTION\n"); error("UNIONs must be inside a SECTION\n");
if (sect_HasData(currentSection->type)) return;
fatalerror("Cannot use UNION inside of ROM0 or ROMX sections\n"); }
if (sect_HasData(currentSection->type)) {
error("Cannot use UNION inside of ROM0 or ROMX sections\n");
return;
}
struct UnionStackEntry *entry = malloc(sizeof(*entry)); struct UnionStackEntry *entry = malloc(sizeof(*entry));
if (!entry) if (!entry)
@@ -559,15 +563,19 @@ static void endUnionMember(void)
void sect_NextUnionMember(void) void sect_NextUnionMember(void)
{ {
if (!unionStack) if (!unionStack) {
fatalerror("Found NEXTU outside of a UNION construct\n"); error("Found NEXTU outside of a UNION construct\n");
return;
}
endUnionMember(); endUnionMember();
} }
void sect_EndUnion(void) void sect_EndUnion(void)
{ {
if (!unionStack) if (!unionStack) {
fatalerror("Found ENDU outside of a UNION construct\n"); error("Found ENDU outside of a UNION construct\n");
return;
}
endUnionMember(); endUnionMember();
curOffset += unionStack->size; curOffset += unionStack->size;
struct UnionStackEntry *next = unionStack->next; struct UnionStackEntry *next = unionStack->next;