changeset 561:a6a9d46f071f

Make ifdef and ifndef complain if they aren't given a symbol If makes no sense to test "nothing" for definedness. If no symbol is provided to ifdef or ifndef, complain about a bad operand.
author William Astle <lost@l-w.ca>
date Thu, 30 Nov 2023 16:54:12 -0700
parents dba08c7dff96
children 6237505ee1dc
files lwasm/pseudo.c
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/pseudo.c	Fri Sep 22 12:15:09 2023 -0600
+++ b/lwasm/pseudo.c	Thu Nov 30 16:54:12 2023 -0700
@@ -1342,6 +1342,12 @@
 again:
 	for (i = 0; (*p)[i] && !isspace((*p)[i]) && (*p)[i] != '|' && (*p)[i] != '&'; i++)
 		/* do nothing */ ;
+
+	if (i == 0)
+	{
+		lwasm_register_error(as, l, E_OPERAND_BAD);
+		return;
+	}
 	
 	sym = lw_strndup(*p, i);
 	(*p) += i;
@@ -1382,6 +1388,12 @@
 	for (i = 0; (*p)[i] && !isspace((*p)[i]) && (*p)[i] != '&' && (*p)[i] != '|'; i++)
 		/* do nothing */ ;
 	
+	if (i == 0)
+	{
+		lwasm_register_error(as, l, E_OPERAND_BAD);
+		return;
+	}
+
 	sym = lw_strndup(*p, i);
 	(*p) += i;