Thu Jul 30 13:50:27 2020 UTC ()
make(1): add test for indirect unclosed variable

The error message mentions only the original variable name right now.
It's left to the Makefile author to see where the actual unclosed
variable value comes from.  From a usability standpoint that's not
optimal, but everything else would need additional cycles even in the
good cases, or it might have side-effects when evaluating a variable
twice (once to detect the error, and a second time to find out the
details of the error).


(rillig)
diff -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmisc.exp
diff -r1.19 -r1.20 src/usr.bin/make/unit-tests/varmisc.mk

cvs diff -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmisc.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmisc.exp 2020/07/28 17:18:40 1.14
+++ src/usr.bin/make/unit-tests/varmisc.exp 2020/07/30 13:50:27 1.15
@@ -56,15 +56,17 @@ make: Unclosed variable "UNCLOSED" @@ -56,15 +56,17 @@ make: Unclosed variable "UNCLOSED"
56make: Unclosed variable "PATTERN" 56make: Unclosed variable "PATTERN"
57make: Unclosed variable specification (expecting '}') for "UNCLOSED" (value "") modifier M 57make: Unclosed variable specification (expecting '}') for "UNCLOSED" (value "") modifier M
58 58
59make: Unclosed variable "param" 59make: Unclosed variable "param"
60make: Unclosed variable "UNCLOSED." 60make: Unclosed variable "UNCLOSED."
61 61
62 62
63make: Unclosed variable "UNCLOSED.1" 63make: Unclosed variable "UNCLOSED.1"
64 64
65make: Unclosed variable "UNCLOSED.2" 65make: Unclosed variable "UNCLOSED.2"
66 66
67make: Unclosed variable "UNCLOSED.3" 67make: Unclosed variable "UNCLOSED.3"
68 68
 69make: Unclosed variable "UNCLOSED_ORIG"
 70
69varerror-unclosed:end 71varerror-unclosed:end
70exit status 0 72exit status 0

cvs diff -r1.19 -r1.20 src/usr.bin/make/unit-tests/varmisc.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/varmisc.mk 2020/07/28 19:39:43 1.19
+++ src/usr.bin/make/unit-tests/varmisc.mk 2020/07/30 13:50:27 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1# $Id: varmisc.mk,v 1.19 2020/07/28 19:39:43 rillig Exp $ 1# $Id: varmisc.mk,v 1.20 2020/07/30 13:50:27 rillig Exp $
2# 2#
3# Miscellaneous variable tests. 3# Miscellaneous variable tests.
4 4
5all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none \ 5all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none \
6 strftime cmpv manok 6 strftime cmpv manok
7all: save-dollars 7all: save-dollars
8all: export-appended 8all: export-appended
9all: parse-dynamic 9all: parse-dynamic
10all: varerror-unclosed 10all: varerror-unclosed
11 11
12unmatched_var_paren: 12unmatched_var_paren:
13 @echo ${foo::=foo-text} 13 @echo ${foo::=foo-text}
14 14
@@ -184,36 +184,41 @@ GL_TARGET:= ${.TARGET} @@ -184,36 +184,41 @@ GL_TARGET:= ${.TARGET}
184GL_MEMBER:= ${.MEMBER} 184GL_MEMBER:= ${.MEMBER}
185GL_PREFIX:= ${.PREFIX} 185GL_PREFIX:= ${.PREFIX}
186GL_ARCHIVE:= ${.ARCHIVE} 186GL_ARCHIVE:= ${.ARCHIVE}
187GL_ALLSRC:= ${.ALLSRC} 187GL_ALLSRC:= ${.ALLSRC}
188 188
189parse-dynamic: 189parse-dynamic:
190 @echo $@: ${GS_TARGET} ${GS_MEMBER} ${GS_PREFIX} ${GS_ARCHIVE} ${GS_ALLSRC} 190 @echo $@: ${GS_TARGET} ${GS_MEMBER} ${GS_PREFIX} ${GS_ARCHIVE} ${GS_ALLSRC}
191 @echo $@: ${GB_TARGET} ${GB_MEMBER} ${GB_PREFIX} ${GB_ARCHIVE} ${GB_ALLSRC} 191 @echo $@: ${GB_TARGET} ${GB_MEMBER} ${GB_PREFIX} ${GB_ARCHIVE} ${GB_ALLSRC}
192 @echo $@: ${GL_TARGET} ${GL_MEMBER} ${GL_PREFIX} ${GL_ARCHIVE} ${GL_ALLSRC} 192 @echo $@: ${GL_TARGET} ${GL_MEMBER} ${GL_PREFIX} ${GL_ARCHIVE} ${GL_ALLSRC}
193 193
194# Since 2020-07-28, make complains about unclosed variables. 194# Since 2020-07-28, make complains about unclosed variables.
195# Before that, it had not complained about unclosed variables only when 195# Before that, it had not complained about unclosed variables only when
196# parsing the modifiers, but not when parsing the variable name. 196# parsing the modifiers, but not when parsing the variable name.
 197
 198UNCLOSED_INDIR_1= ${UNCLOSED_ORIG
 199UNCLOSED_INDIR_2= ${UNCLOSED_INDIR_1}
 200
197varerror-unclosed: 201varerror-unclosed:
198 @echo $@:begin 202 @echo $@:begin
199 @echo $( 203 @echo $(
200 @echo $(UNCLOSED 204 @echo $(UNCLOSED
201 @echo ${UNCLOSED 205 @echo ${UNCLOSED
202 @echo ${UNCLOSED:M${PATTERN 206 @echo ${UNCLOSED:M${PATTERN
203 @echo ${UNCLOSED.${param 207 @echo ${UNCLOSED.${param
204 @echo $ 208 @echo $
205.for i in 1 2 3 209.for i in 1 2 3
206 @echo ${UNCLOSED.${i} 210 @echo ${UNCLOSED.${i}
207.endfor 211.endfor
 212 @echo ${UNCLOSED_INDIR_2}
208 @echo $@:end 213 @echo $@:end
209 214
210# As of 2020-07-28, .undef only undefines the first variable. 215# As of 2020-07-28, .undef only undefines the first variable.
211# All further variable names are silently ignored. 216# All further variable names are silently ignored.
212# See parse.c, string literal "undef". 217# See parse.c, string literal "undef".
2131= 1 2181= 1
2142= 2 2192= 2
2153= 3 2203= 3
216.undef 1 2 3 221.undef 1 2 3
217.if ${1:U_}${2:U_}${3:U_} != _23 222.if ${1:U_}${2:U_}${3:U_} != _23
218.warning $1$2$3 223.warning $1$2$3
219.endif 224.endif