cond-eof.mk revision 1.4
1# $NetBSD: cond-eof.mk,v 1.4 2023/06/01 07:27:30 rillig Exp $
2#
3# Tests for parsing the end of '.if' conditions, which are represented as the
4# token TOK_EOF.
5
6# expect-all
7
8
9SIDE_EFFECT=	${:!echo 'side effect' 1>&2!}
10SIDE_EFFECT2=	${:!echo 'side effect 2' 1>&2!}
11
12# In the following conditions, ${SIDE_EFFECT} is the position of the first
13# parse error.  Before cond.c 1.286 from 2021-12-10, it was always fully
14# evaluated, even if it was not necessary to expand the variable expression.
15# These syntax errors are an edge case that does not occur during normal
16# operation.  Still, it is easy to avoid evaluating these expressions, just in
17# case they have side effects.
18# expect+1: Malformed conditional (0 ${SIDE_EFFECT} ${SIDE_EFFECT2})
19.if 0 ${SIDE_EFFECT} ${SIDE_EFFECT2}
20.endif
21# expect+1: Malformed conditional (1 ${SIDE_EFFECT} ${SIDE_EFFECT2})
22.if 1 ${SIDE_EFFECT} ${SIDE_EFFECT2}
23.endif
24# expect+1: Malformed conditional ((0) ${SIDE_EFFECT} ${SIDE_EFFECT2})
25.if (0) ${SIDE_EFFECT} ${SIDE_EFFECT2}
26.endif
27