Module Name: src
Committed By: rillig
Date: Fri Sep 11 05:12:08 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: cond-op.exp cond-op.mk
Log Message:
make(1): add test for evaluation of condition after parse error
To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cond-op.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-op.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/unit-tests/cond-op.exp
diff -u src/usr.bin/make/unit-tests/cond-op.exp:1.2 src/usr.bin/make/unit-tests/cond-op.exp:1.3
--- src/usr.bin/make/unit-tests/cond-op.exp:1.2 Fri Aug 28 14:07:51 2020
+++ src/usr.bin/make/unit-tests/cond-op.exp Fri Sep 11 05:12:08 2020
@@ -1,5 +1,7 @@
make: "cond-op.mk" line 45: Malformed conditional ("!word" == !word)
-make: "cond-op.mk" line 57: Parsing continues until here.
+make: "cond-op.mk" line 56: Malformed conditional (0 ${ERR::=evaluated})
+make: "cond-op.mk" line 60: warning: After detecting a parse error, the rest is evaluated.
+make: "cond-op.mk" line 64: Parsing continues until here.
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/cond-op.mk
diff -u src/usr.bin/make/unit-tests/cond-op.mk:1.5 src/usr.bin/make/unit-tests/cond-op.mk:1.6
--- src/usr.bin/make/unit-tests/cond-op.mk:1.5 Fri Sep 11 04:40:26 2020
+++ src/usr.bin/make/unit-tests/cond-op.mk Fri Sep 11 05:12:08 2020
@@ -1,4 +1,4 @@
-# $NetBSD: cond-op.mk,v 1.5 2020/09/11 04:40:26 rillig Exp $
+# $NetBSD: cond-op.mk,v 1.6 2020/09/11 05:12:08 rillig Exp $
#
# Tests for operators like &&, ||, ! in .if conditions.
#
@@ -41,7 +41,7 @@
# This condition is malformed because the '!' on the right-hand side must not
# appear unquoted. If any, it must be enclosed in quotes.
# In any case, it is not interpreted as a negation of an unquoted string.
-# See CondGetString.
+# See CondParser_String.
.if "!word" == !word
.error
.endif
@@ -53,6 +53,16 @@
.error
.endif
+# As soon as the parser sees the '$', it knows that the condition will
+# be malformed. Therefore there is no point in evaluating it.
+# As of 2020-09-11, that part of the condition is evaluated nevertheless.
+.if 0 ${ERR::=evaluated}
+. error
+.endif
+.if ${ERR:Uundefined} == evaluated
+. warning After detecting a parse error, the rest is evaluated.
+.endif
+
# Just in case that parsing should ever stop on the first error.
.info Parsing continues until here.