Module Name:    src
Committed By:   rillig
Date:           Mon Apr 19 22:05:29 UTC 2021

Modified Files:
        src/usr.bin/make/unit-tests: varmod-ifelse.exp varmod-ifelse.mk

Log Message:
tests/make: demonstrate unexpected behavior of the modifier ':?'


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-ifelse.exp
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-ifelse.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-ifelse.exp
diff -u src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.5 src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.6
--- src/usr.bin/make/unit-tests/varmod-ifelse.exp:1.5	Thu Dec 10 16:36:47 2020
+++ src/usr.bin/make/unit-tests/varmod-ifelse.exp	Mon Apr 19 22:05:29 2021
@@ -15,6 +15,8 @@ CondParser_Eval: ${ ${:U\$}{VAR} == valu
 CondParser_Eval: ${VAR} == value 
 lhs = "value", rhs = "value", op = ==
 lhs = "ok", rhs = "ok", op = !=
+make: Bad conditional expression `string == "literal" && no >= 10' in string == "literal" && no >= 10?yes:no
+make: "varmod-ifelse.mk" line 127: .
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-ifelse.mk
diff -u src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.11 src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.12
--- src/usr.bin/make/unit-tests/varmod-ifelse.mk:1.11	Sun Apr 11 13:35:56 2021
+++ src/usr.bin/make/unit-tests/varmod-ifelse.mk	Mon Apr 19 22:05:29 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-ifelse.mk,v 1.11 2021/04/11 13:35:56 rillig Exp $
+# $NetBSD: varmod-ifelse.mk,v 1.12 2021/04/19 22:05:29 rillig Exp $
 #
 # Tests for the ${cond:?then:else} variable modifier, which evaluates either
 # the then-expression or the else-expression, depending on the condition.
@@ -111,5 +111,18 @@ VAR=	value
 .endif
 .MAKEFLAGS: -d0
 
-all:
-	@:;
+# Seen on 2021-04-19 when building external/bsd/tmux with HAVE_LLVM=yes
+# and HAVE_GCC=no.
+#
+# TODO: make should at least describe the part of the condition that is
+#  wrong. In this case it is probably the "no >= 10".  Ideally that should
+#  not matter though since the left-hand side of the '&&' evaluates to false,
+#  thus the right-hand side only needs to be parsed, not evaluated.  Since
+#  this is the modifier ':?', which expands subexpressions before parsing
+#  the condition, the "no >= 10" is probably a parse error since it "can be
+#  seen at compile-time" that the operand types of '>=' don't match.  Only
+#  that the concept of "compile-time" does not really apply here.
+STRING=		string
+NUMBER=		no
+.info ${${STRING} == "literal" && ${NUMBER} >= 10:?yes:no}.
+# XXX: In the diagnostic, the second placeholder is missing the quotes.

Reply via email to