shithub: rgbds

Download patch

ref: 176a57a1e96c53513b82b093b105bb9b4f92da6c
parent: 0d02355dbf9fef92c2cf40be09e304601a931014
parent: 217c10ddac43fa0b87566bb44bef8236b0eab316
author: Eldred Habert <eldredhabert0@gmail.com>
date: Sun Oct 11 21:44:10 EDT 2020

Merge pull request #600 from NieDzejkob/stray-shift

Report error when shifting outside a macro

--- a/src/asm/macro.c
+++ b/src/asm/macro.c
@@ -130,7 +130,9 @@
 
 void macro_ShiftCurrentArgs(void)
 {
-	if (macroArgs->shift != macroArgs->nbArgs)
+	if (!macroArgs)
+		error("Cannot shift macro arguments outside of a macro\n");
+	else if (macroArgs->shift != macroArgs->nbArgs)
 		macroArgs->shift++;
 }
 
--- /dev/null
+++ b/test/asm/shift-outside-macro.asm
@@ -1,0 +1,1 @@
+shift
--- /dev/null
+++ b/test/asm/shift-outside-macro.err
@@ -1,0 +1,3 @@
+ERROR: shift-outside-macro.asm(1):
+    Cannot shift macro arguments outside of a macro
+error: Assembly aborted (1 errors)!