shithub: rgbds

Download patch

ref: 14fea5f6596b1c2a907f5fe98dd279718ff7b292
parent: 1e16a0ff85139dabf99c4cf7f6f92cd9921460f9
parent: 38372c59edb070d2c0320d21c6cf898e118e3e26
author: AntonioND <[email protected]>
date: Sun Feb 26 16:49:22 EST 2017

Merge pull request #119 from Ben10do/add-end-checks

Verify that IFs, REPTs and MACROs are terminated

--- a/src/asm/asmy.y
+++ b/src/asm/asmy.y
@@ -182,6 +182,10 @@
 		}
 	}
 
+	if (level != 0) {
+		fatalerror("Unterminated REPT block");
+	}
+
 	len=src-pCurrentBuffer->pBuffer-4;
 
 	src=pCurrentBuffer->pBuffer;
@@ -257,6 +261,10 @@
 		}
 	}
 
+	if (level != 0) {
+		fatalerror("Unterminated MACRO definition");
+	}
+
 	len=src-pCurrentBuffer->pBuffer-4;
 
 	src=pCurrentBuffer->pBuffer;
@@ -348,6 +356,10 @@
 		}
 	}
 
+	if (level != 0) {
+		fatalerror("Unterminated IF construct");
+	}
+
 	len=src-pCurrentBuffer->pBuffer;
 
 	yyskipbytes( len );
@@ -401,6 +413,10 @@
 				src+=1;
 			}
 		}
+	}
+
+	if (level != 0) {
+		fatalerror("Unterminated IF construct");
 	}
 
 	len=src-pCurrentBuffer->pBuffer;