]> granicus.if.org Git - yasm/commitdiff
Fix crash on the valid NASM preprocessor syntax:
authorPeter Johnson <peter@tortall.net>
Thu, 3 Apr 2003 06:14:29 +0000 (06:14 -0000)
committerPeter Johnson <peter@tortall.net>
Thu, 3 Apr 2003 06:14:29 +0000 (06:14 -0000)
var: db 5
varlen equ $-var
%if varlen>100
...
%endif
by always acting like we're in preprocess-only mode and adjusting error
message appropriately.
This would be HARD to truly fix, as yasm only parses the input once.

svn path=/trunk/yasm/; revision=920

modules/preprocs/nasm/Makefile.inc
modules/preprocs/nasm/nasm-eval.c
modules/preprocs/nasm/tests/Makefile.inc [new file with mode: 0644]
modules/preprocs/nasm/tests/ifcritical-err.asm [new file with mode: 0644]
modules/preprocs/nasm/tests/ifcritical-err.errwarn [new file with mode: 0644]
modules/preprocs/nasm/tests/nasmpp_test.sh [new file with mode: 0755]

index 3b65abed15aac909798d9532229c1c4e3bc3c652..9b1119c04b42a53181009c747c0acc3552fef18f 100644 (file)
@@ -21,8 +21,11 @@ BUILT_SOURCES += nasm-macros.c
 CLEANFILES += nasm-macros.c
 
 EXTRA_DIST += modules/preprocs/nasm/macros.pl \
-       modules/preprocs/nasm/standard.mac
+       modules/preprocs/nasm/standard.mac \
+       modules/preprocs/nasm/tests/Makefile.inc
 
 #yasm_nasm_la_LDFLAGS = -module -avoid-version -no-undefined
 #yasm_nasm_la_LIBADD = libyasm.la
 #YASM_MODULES += -dlopen yasm_nasm.la
+
+include modules/preprocs/nasm/tests/Makefile.inc
index 942f4c8bb96255735a86a181466a1a72e25e9939..0a237dfe5a9c7c1dfc124eef2f1506dc9e5f71c3 100644 (file)
@@ -692,9 +692,9 @@ static nasm_expr *expr6(int critical)
             * symbol, Here or Base references are valid because we
             * are in preprocess-only mode.
             */
-           if (!location->known) {
+           if (!location || !location->known) {
                error(ERR_NONFATAL,
-                     "%s not supported in preprocess-only mode",
+                     "%s not supported",
                      (i == TOKEN_ID ? "symbol references" :
                       i == TOKEN_HERE ? "`$'" : "`$$'"));
                addtotemp(EXPR_UNKNOWN, 1L);
diff --git a/modules/preprocs/nasm/tests/Makefile.inc b/modules/preprocs/nasm/tests/Makefile.inc
new file mode 100644 (file)
index 0000000..7e2608e
--- /dev/null
@@ -0,0 +1,9 @@
+# $IdPath$
+
+TESTS += \
+       modules/preprocs/nasm/tests/nasmpp_test.sh
+
+EXTRA_DIST += \
+       modules/preprocs/nasm/tests/nasmpp_test.sh      \
+       modules/preprocs/nasm/tests/ifcritical-err.asm  \
+       modules/preprocs/nasm/tests/ifcritical-err.errwarn
diff --git a/modules/preprocs/nasm/tests/ifcritical-err.asm b/modules/preprocs/nasm/tests/ifcritical-err.asm
new file mode 100644 (file)
index 0000000..1290dd8
--- /dev/null
@@ -0,0 +1,7 @@
+; This worked under NASM.  Due to the once-parse model used by YASM, this no
+; longer works.  However, it should error, not crash!
+teststring db "Hello, world"
+teststringlen equ $-teststring
+%if teststringlen>100
+ db '5'
+%endif
diff --git a/modules/preprocs/nasm/tests/ifcritical-err.errwarn b/modules/preprocs/nasm/tests/ifcritical-err.errwarn
new file mode 100644 (file)
index 0000000..7cc7b03
--- /dev/null
@@ -0,0 +1,2 @@
+-:4: symbol references not supported
+-:4: non-constant value given to `%if'
diff --git a/modules/preprocs/nasm/tests/nasmpp_test.sh b/modules/preprocs/nasm/tests/nasmpp_test.sh
new file mode 100755 (executable)
index 0000000..f5a25a5
--- /dev/null
@@ -0,0 +1,4 @@
+#! /bin/sh
+# $IdPath$
+${srcdir}/out_test.sh nasmpp_test modules/preprocs/nasm/tests "nasm preproc" "-f bin" ""
+exit $?