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.
This commit is contained in:
parent
a12d67d575
commit
24fb524bea
@ -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, bool doEval)
|
||||
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;
|
||||
|
||||
|
@ -15,8 +15,8 @@ CondParser_Eval: ${ ${:U\$}{VAR} == value :?ok:bad} != "ok"
|
||||
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'
|
||||
|
@ -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}.
|
||||
|
Loading…
x
Reference in New Issue
Block a user