2021-12-18 07:27:22 +00:00
|
|
|
# $NetBSD: cond-op-or.mk,v 1.8 2021/12/10 19:14:35 rillig Exp $
|
2020-09-05 16:11:04 +00:00
|
|
|
#
|
|
|
|
# Tests for the || operator in .if conditions.
|
|
|
|
|
|
|
|
.if 0 || 0
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !(1 || 0)
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !(0 || 1)
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !(1 || 1)
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
|
2020-09-05 16:11:04 +00:00
|
|
|
# The right-hand side is not evaluated since the left-hand side is already
|
|
|
|
# true.
|
|
|
|
.if 1 || ${UNDEF}
|
|
|
|
.endif
|
|
|
|
|
2021-12-18 07:27:22 +00:00
|
|
|
# When an outer condition makes the inner '||' condition irrelevant, neither
|
|
|
|
# of its operands must be evaluated. This had been wrong in cond.c 1.283 from
|
|
|
|
# 2021-12-09 and was reverted in cond.c 1.284 an hour later.
|
|
|
|
.if 0 && (!defined(UNDEF) || ${UNDEF})
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# Test combinations of outer '&&' with inner '||', to ensure that the operands
|
|
|
|
# of the inner '||' is only evaluated if necessary.
|
|
|
|
DEF= defined
|
|
|
|
.if 0 && (${DEF} || ${UNDEF})
|
|
|
|
.endif
|
|
|
|
.if 0 && (!${DEF} || ${UNDEF})
|
|
|
|
.endif
|
|
|
|
.if 0 && (${UNDEF} || ${UNDEF})
|
|
|
|
.endif
|
|
|
|
.if 0 && (!${UNDEF} || ${UNDEF})
|
|
|
|
.endif
|
|
|
|
.if 1 && (${DEF} || ${UNDEF})
|
|
|
|
.endif
|
|
|
|
.if 1 && (!${DEF} || ${UNDEF})
|
|
|
|
.endif
|
|
|
|
.if 1 && (${UNDEF} || ${UNDEF})
|
|
|
|
.endif
|
|
|
|
.if 1 && (!${UNDEF} || ${UNDEF})
|
|
|
|
.endif
|
|
|
|
|
|
|
|
|
2020-11-07 19:39:21 +00:00
|
|
|
# The || operator may be abbreviated as |. This is not widely known though
|
|
|
|
# and is also not documented in the manual page.
|
|
|
|
|
|
|
|
.if 0 | 0
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
.if !(1 | 0)
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
.if !(0 | 1)
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
.if !(1 | 1)
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# There is no operator |||.
|
|
|
|
.if 0 ||| 0
|
|
|
|
. error
|
|
|
|
.endif
|
|
|
|
|
2020-09-05 16:11:04 +00:00
|
|
|
all:
|
|
|
|
@:;
|