Module Name: src
Committed By: rillig
Date: Mon Sep 14 21:55:53 UTC 2020
Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: opt-debug-lint.exp opt-debug-lint.mk
Log Message:
make(1): fix wrong error for undefined variables in lint mode
To generate a diff of this commit:
cvs rdiff -u -r1.521 -r1.522 src/usr.bin/make/var.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/opt-debug-lint.exp \
src/usr.bin/make/unit-tests/opt-debug-lint.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.521 src/usr.bin/make/var.c:1.522
--- src/usr.bin/make/var.c:1.521 Mon Sep 14 20:43:44 2020
+++ src/usr.bin/make/var.c Mon Sep 14 21:55:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.521 2020/09/14 20:43:44 rillig Exp $ */
+/* $NetBSD: var.c,v 1.522 2020/09/14 21:55:53 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.521 2020/09/14 20:43:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.522 2020/09/14 21:55:53 rillig Exp $");
#define VAR_DEBUG_IF(cond, fmt, ...) \
if (!(DEBUG(VAR) && (cond))) \
@@ -3557,7 +3557,9 @@ Var_Parse(const char **pp, GNode *ctxt,
return VPE_OK;
}
- if ((eflags & VARE_UNDEFERR) && DEBUG(LINT)) {
+ if ((eflags & VARE_UNDEFERR) && (eflags & VARE_WANTRES) &&
+ DEBUG(LINT))
+ {
Parse_Error(PARSE_FATAL, "Variable \"%s\" is undefined",
varname);
free(varname);
Index: src/usr.bin/make/unit-tests/opt-debug-lint.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.6 src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.7
--- src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.6 Mon Sep 14 21:52:49 2020
+++ src/usr.bin/make/unit-tests/opt-debug-lint.exp Mon Sep 14 21:55:53 2020
@@ -1,6 +1,5 @@
make: "opt-debug-lint.mk" line 19: Variable "X" is undefined
make: "opt-debug-lint.mk" line 41: Variable "UNDEF" is undefined
-make: "opt-debug-lint.mk" line 58: Variable "UNDEF" is undefined
make: Fatal errors encountered -- cannot continue
make: stopped in unit-tests
exit status 1
Index: src/usr.bin/make/unit-tests/opt-debug-lint.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.6 src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.7
--- src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.6 Mon Sep 14 21:52:49 2020
+++ src/usr.bin/make/unit-tests/opt-debug-lint.mk Mon Sep 14 21:55:53 2020
@@ -1,4 +1,4 @@
-# $NetBSD: opt-debug-lint.mk,v 1.6 2020/09/14 21:52:49 rillig Exp $
+# $NetBSD: opt-debug-lint.mk,v 1.7 2020/09/14 21:55:53 rillig Exp $
#
# Tests for the -dL command line option, which runs additional checks
# to catch common mistakes, such as unclosed variable expressions.
@@ -52,9 +52,6 @@ ${UNDEF}: ${UNDEF}
# if the variable is indeed defined. Otherwise they are only parsed, and
# for parsing it doesn't make a difference whether the variable is defined
# or not.
-#
-# FIXME: As of 2020-09-14, the following line prints an error message saying
-# that UNDEF is undefined.
.if defined(UNDEF) && exists(${UNDEF})
. error
.endif