Module Name:    src
Committed By:   rillig
Date:           Thu Jan 21 14:08:09 UTC 2021

Modified Files:
        src/usr.bin/make: cond.c
        src/usr.bin/make/unit-tests: cond-token-plain.exp cond-token-plain.mk

Log Message:
make(1): demonstrate parse error without error message in conditional


To generate a diff of this commit:
cvs rdiff -u -r1.246 -r1.247 src/usr.bin/make/cond.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-token-plain.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-token-plain.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/cond.c
diff -u src/usr.bin/make/cond.c:1.246 src/usr.bin/make/cond.c:1.247
--- src/usr.bin/make/cond.c:1.246	Thu Jan 21 13:51:24 2021
+++ src/usr.bin/make/cond.c	Thu Jan 21 14:08:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.246 2021/01/21 13:51:24 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.247 2021/01/21 14:08:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.246 2021/01/21 13:51:24 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.247 2021/01/21 14:08:09 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -467,8 +467,16 @@ CondParser_String(CondParser *par, Boole
 			    &str);
 			/* TODO: handle errors */
 			if (str.str == var_Error) {
-				if (parseResult == VPR_ERR)
+				if (parseResult == VPR_ERR) {
+					/*
+					 * FIXME: Even if an error occurs,
+					 * there is no guarantee that it is
+					 * reported.
+					 *
+					 * See cond-token-plain.mk $$$$$$$$.
+					 */
 					par->printedError = TRUE;
+				}
 				/*
 				 * XXX: Can there be any situation in which
 				 * a returned var_Error requires freeIt?

Index: src/usr.bin/make/unit-tests/cond-token-plain.exp
diff -u src/usr.bin/make/unit-tests/cond-token-plain.exp:1.6 src/usr.bin/make/unit-tests/cond-token-plain.exp:1.7
--- src/usr.bin/make/unit-tests/cond-token-plain.exp:1.6	Thu Jan 21 13:52:32 2021
+++ src/usr.bin/make/unit-tests/cond-token-plain.exp	Thu Jan 21 14:08:09 2021
@@ -49,6 +49,7 @@ CondParser_Eval: \\
 make: "cond-token-plain.mk" line 168: Now the variable '\\' is defined.
 CondParser_Eval: "unquoted\"quoted" != unquoted"quoted
 lhs = "unquoted"quoted", rhs = "unquoted"quoted", op = !=
+CondParser_Eval: $$$$$$$$ != ""
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/cond-token-plain.mk
diff -u src/usr.bin/make/unit-tests/cond-token-plain.mk:1.9 src/usr.bin/make/unit-tests/cond-token-plain.mk:1.10
--- src/usr.bin/make/unit-tests/cond-token-plain.mk:1.9	Thu Jan 21 13:52:32 2021
+++ src/usr.bin/make/unit-tests/cond-token-plain.mk	Thu Jan 21 14:08:09 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-token-plain.mk,v 1.9 2021/01/21 13:52:32 rillig Exp $
+# $NetBSD: cond-token-plain.mk,v 1.10 2021/01/21 14:08:09 rillig Exp $
 #
 # Tests for plain tokens (that is, string literals without quotes)
 # in .if conditions.
@@ -177,6 +177,14 @@ ${:U\\\\}=	backslash
 .  error
 .endif
 
+# FIXME: In CondParser_String, Var_Parse returns var_Error without a
+# corresponding error message.
+.if $$$$$$$$ != ""
+.  error
+.else
+.  error
+.endif
+
 # See cond-token-string.mk for similar tests where the condition is enclosed
 # in "quotes".
 

Reply via email to