shithub: rgbds

Download patch

ref: 02cb5a0526553259dfc8229f361619bc3d458371
parent: 8397b3d8ecbd4271a3a68f7c118eac3383132d6a
author: ISSOtm <eldredhabert0@gmail.com>
date: Sun May 2 19:42:53 EDT 2021

Avoid performing invalid actions on LOAD errors

These are rejected because they could lead to incorrect behavior,
so then don't do it...

--- a/src/asm/section.c
+++ b/src/asm/section.c
@@ -417,11 +417,15 @@
 	if (!checkcodesection())
 		return;
 
-	if (currentLoadSection)
-		fatalerror("`LOAD` blocks cannot be nested\n");
+	if (currentLoadSection) {
+		error("`LOAD` blocks cannot be nested\n");
+		return;
+	}
 
-	if (sect_HasData(type))
+	if (sect_HasData(type)) {
 		error("`LOAD` blocks cannot create a ROM section\n");
+		return;
+	}
 
 	struct Section *sect = getSection(name, type, org, attribs, mod);
 
@@ -433,8 +437,10 @@
 
 void out_EndLoadSection(void)
 {
-	if (!currentLoadSection)
+	if (!currentLoadSection) {
 		error("Found `ENDL` outside of a `LOAD` block\n");
+		return;
+	}
 
 	changeSection();
 	curOffset += loadOffset;
--- a/test/asm/load-rom.err
+++ b/test/asm/load-rom.err
@@ -1,3 +1,5 @@
 ERROR: load-rom.asm(3):
     `LOAD` blocks cannot create a ROM section
-error: Assembly aborted (1 error)!
+ERROR: load-rom.asm(5):
+    Found `ENDL` outside of a `LOAD` block
+error: Assembly aborted (2 errors)!