Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make: do not complain when skipping the conditi...



details:   https://anonhg.NetBSD.org/src/rev/a235238a6a25
branches:  trunk
changeset: 378645:a235238a6a25
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Apr 19 23:51:42 2021 +0000

description:
make: do not complain when skipping the condition 'no >= 10'

Seen in external/bsd/tmux when building with Clang.  See
varmod-ifelse.mk for the detailed story.

diffstat:

 usr.bin/make/cond.c                       |   6 +++---
 usr.bin/make/unit-tests/varmod-ifelse.exp |   4 ++--
 usr.bin/make/unit-tests/varmod-ifelse.mk  |  18 +++++++++---------
 3 files changed, 14 insertions(+), 14 deletions(-)

diffs (73 lines):

diff -r 006327db83f0 -r a235238a6a25 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Mon Apr 19 23:43:14 2021 +0000
+++ b/usr.bin/make/cond.c       Mon Apr 19 23:51:42 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.261 2021/04/04 11:56:43 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.262 2021/04/19 23:51:42 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.261 2021/04/04 11:56:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.262 2021/04/19 23:51:42 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -854,7 +854,7 @@ CondParser_LeafToken(CondParser *par, bo
        arglen = ParseFuncArg(par, &cp, doEval, NULL, &arg);
        cp1 = cp;
        cpp_skip_whitespace(&cp1);
-       if (*cp1 == '=' || *cp1 == '!')
+       if (*cp1 == '=' || *cp1 == '!' || *cp1 == '<' || *cp1 == '>')
                return CondParser_Comparison(par, doEval);
        par->p = cp;
 
diff -r 006327db83f0 -r a235238a6a25 usr.bin/make/unit-tests/varmod-ifelse.exp
--- a/usr.bin/make/unit-tests/varmod-ifelse.exp Mon Apr 19 23:43:14 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-ifelse.exp Mon Apr 19 23:51:42 2021 +0000
@@ -15,8 +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 153: .
+make: "varmod-ifelse.mk" line 153: no.
+make: "varmod-ifelse.mk" line 154: String comparison operator must be either == or !=
 make: Bad conditional expression 'string == "literal" || no >= 10' in 'string == "literal" || no >= 10?yes:no'
 make: "varmod-ifelse.mk" line 154: .
 make: Bad conditional expression 'string == "literal" &&  >= 10' in 'string == "literal" &&  >= 10?yes:no'
diff -r 006327db83f0 -r a235238a6a25 usr.bin/make/unit-tests/varmod-ifelse.mk
--- a/usr.bin/make/unit-tests/varmod-ifelse.mk  Mon Apr 19 23:43:14 2021 +0000
+++ b/usr.bin/make/unit-tests/varmod-ifelse.mk  Mon Apr 19 23:51:42 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-ifelse.mk,v 1.15 2021/04/19 23:43:14 rillig Exp $
+# $NetBSD: varmod-ifelse.mk,v 1.16 2021/04/19 23:51:42 rillig Exp $
 #
 # Tests for the ${cond:?then:else} variable modifier, which evaluates either
 # the then-expression or the else-expression, depending on the condition.
@@ -140,14 +140,14 @@ VAR=      value
 # therefore parsing stopped at the '>', producing the 'Bad conditional
 # expression'.
 #
-# 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.
+# Ideally, the conditional expression would not be expanded before parsing
+# it.  This would allow to write the conditions exactly as seen below.  That
+# change has a high chance of breaking _some_ existing code and would need
+# to be thoroughly tested.
+#
+# Since cond.c 1.262 from 2021-04-20, make reports a more specific error
+# message in situations like these, pointing directly to the specific problem
+# instead of just saying that the whole condition is bad.
 STRING=                string
 NUMBER=                no              # not really a number
 .info ${${STRING} == "literal" && ${NUMBER} >= 10:?yes:no}.



Home | Main Index | Thread Index | Old Index