cond-op-or.mk revision 1.7 1 # $NetBSD: cond-op-or.mk,v 1.7 2021/12/09 23:57:19 rillig Exp $
2 #
3 # Tests for the || operator in .if conditions.
4
5 .if 0 || 0
6 . error
7 .endif
8
9 .if !(1 || 0)
10 . error
11 .endif
12
13 .if !(0 || 1)
14 . error
15 .endif
16
17 .if !(1 || 1)
18 . error
19 .endif
20
21
22 # The right-hand side is not evaluated since the left-hand side is already
23 # true.
24 .if 1 || ${UNDEF}
25 .endif
26
27 # When an outer condition makes the '||' expression irrelevant, neither of its
28 # operands must be evaluated. This had been wrong in cond.c 1.283 from
29 # 2021-12-09 and was reverted in cond.c 1.284 an hour later.
30 .if 0 && (!defined(UNDEF) || ${UNDEF})
31 .endif
32
33
34 # The || operator may be abbreviated as |. This is not widely known though
35 # and is also not documented in the manual page.
36
37 .if 0 | 0
38 . error
39 .endif
40 .if !(1 | 0)
41 . error
42 .endif
43 .if !(0 | 1)
44 . error
45 .endif
46 .if !(1 | 1)
47 . error
48 .endif
49
50 # There is no operator |||.
51 .if 0 ||| 0
52 . error
53 .endif
54
55 all:
56 @:;
57