Module Name: src
Committed By: rillig
Date: Sun Feb 4 08:51:57 UTC 2024
Modified Files:
src/usr.bin/make/unit-tests: varmod-indirect.exp varmod-indirect.mk
Log Message:
tests/make: indirect modifiers are evaluated in parse-only mode
Found by sjg@.
To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-indirect.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/varmod-indirect.exp
diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.23 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.24
--- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.23 Thu Jun 1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/varmod-indirect.exp Sun Feb 4 08:51:57 2024
@@ -38,6 +38,8 @@ Parsing line 197: .MAKEFLAGS: -d0
ParseDependency(.MAKEFLAGS: -d0)
Global: .MAKEFLAGS = -r -k -d 0 -d pv -d
Global: .MAKEFLAGS = -r -k -d 0 -d pv -d 0
+make: "varmod-indirect.mk" line 274: Unknown modifier "Z"
+make: "varmod-indirect.mk" line 274: Malformed conditional (0 && ${VAR:${M_invalid}})
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/varmod-indirect.mk
diff -u src/usr.bin/make/unit-tests/varmod-indirect.mk:1.14 src/usr.bin/make/unit-tests/varmod-indirect.mk:1.15
--- src/usr.bin/make/unit-tests/varmod-indirect.mk:1.14 Sun Nov 19 22:32:44 2023
+++ src/usr.bin/make/unit-tests/varmod-indirect.mk Sun Feb 4 08:51:57 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.14 2023/11/19 22:32:44 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.15 2024/02/04 08:51:57 rillig Exp $
#
# Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
# These can be used for very basic purposes like converting a string to either
@@ -255,4 +255,21 @@ _:= before ${UNDEF:${:UZ}} after
. error
.endif
-all:
+
+# In parse-only mode, the indirect modifiers must not be evaluated.
+#
+# Before var.c 1.1096 from 2024-02-04, the expression for an indirect modifier
+# was evaluated.
+#
+# The expression ${:UZ} starts with the value "", and in parse-only mode, the
+# modifier ':UZ' does not modify the expression value. This results in an
+# empty string for the indirect modifiers, generating no warning.
+.if 0 && ${VAR:${:UZ}}
+.endif
+# The expression ${M_invalid} starts with the value "Z", which is an unknown
+# modifier. Trying to apply this unknown modifier generated a warning.
+M_invalid= Z
+# expect+2: Unknown modifier "Z"
+# expect+1: Malformed conditional (0 && ${VAR:${M_invalid}})
+.if 0 && ${VAR:${M_invalid}}
+.endif