Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): error out on .else with extraneous text



details:   https://anonhg.NetBSD.org/src/rev/eec7dd8709e3
branches:  trunk
changeset: 1017166:eec7dd8709e3
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Dec 14 22:17:11 2020 +0000

description:
make(1): error out on .else with extraneous text

diffstat:

 usr.bin/make/cond.c                        |   6 +++---
 usr.bin/make/unit-tests/directive-else.exp |  16 ++++++++--------
 usr.bin/make/unit-tests/directive-else.mk  |  15 +++++++++------
 3 files changed, 20 insertions(+), 17 deletions(-)

diffs (90 lines):

diff -r af72465f6886 -r eec7dd8709e3 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Mon Dec 14 21:56:17 2020 +0000
+++ b/usr.bin/make/cond.c       Mon Dec 14 22:17:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.225 2020/12/14 21:56:17 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.226 2020/12/14 22:17:11 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -94,7 +94,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.225 2020/12/14 21:56:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.226 2020/12/14 22:17:11 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -1193,7 +1193,7 @@
                p += 2;
                if (is_token(p, "se", 2)) {     /* It is an 'else'. */
 
-                       if (opts.lint && p[2] != '\0')
+                       if (p[2] != '\0')
                                Parse_Error(PARSE_FATAL,
                                            "The .else directive "
                                            "does not take arguments.");
diff -r af72465f6886 -r eec7dd8709e3 usr.bin/make/unit-tests/directive-else.exp
--- a/usr.bin/make/unit-tests/directive-else.exp        Mon Dec 14 21:56:17 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-else.exp        Mon Dec 14 22:17:11 2020 +0000
@@ -1,11 +1,11 @@
-make: "directive-else.mk" line 11: The .else directive does not take arguments.
-make: "directive-else.mk" line 12: ok
-make: "directive-else.mk" line 16: ok
-make: "directive-else.mk" line 17: The .else directive does not take arguments.
-make: "directive-else.mk" line 22: if-less else
-make: "directive-else.mk" line 28: ok
-make: "directive-else.mk" line 29: warning: extra else
-make: "directive-else.mk" line 42: The .else directive does not take arguments.
+make: "directive-else.mk" line 14: The .else directive does not take arguments.
+make: "directive-else.mk" line 15: ok
+make: "directive-else.mk" line 19: ok
+make: "directive-else.mk" line 21: The .else directive does not take arguments.
+make: "directive-else.mk" line 26: if-less else
+make: "directive-else.mk" line 32: ok
+make: "directive-else.mk" line 33: warning: extra else
+make: "directive-else.mk" line 45: The .else directive does not take arguments.
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r af72465f6886 -r eec7dd8709e3 usr.bin/make/unit-tests/directive-else.mk
--- a/usr.bin/make/unit-tests/directive-else.mk Mon Dec 14 21:56:17 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-else.mk Mon Dec 14 22:17:11 2020 +0000
@@ -1,19 +1,23 @@
-# $NetBSD: directive-else.mk,v 1.6 2020/11/13 09:01:59 rillig Exp $
+# $NetBSD: directive-else.mk,v 1.7 2020/12/14 22:17:11 rillig Exp $
 #
 # Tests for the .else directive.
-
-.MAKEFLAGS: -dL                        # To enable the check for ".else <cond>"
+#
+# Since 2020-11-13, an '.else' followed by extraneous text generates a parse
+# error in -dL (lint) mode.
+#
+# Since 2020-12-15, an '.else' followed by extraneous text always generates
+# a parse error.
 
-# The .else directive does not take any arguments.
-# As of 2020-08-29, make doesn't warn about this.
 .if 0
 .  warning must not be reached
+# The .else directive does not take any arguments.
 .else 123
 .  info ok
 .endif
 
 .if 1
 .  info ok
+# The .else directive does not take any arguments.
 .else 123
 .  warning must not be reached
 .endif
@@ -37,7 +41,6 @@
 .endif
 
 # A variable expression does count as an argument, even if it is empty.
-# XXX: This should be a parse error.
 .if 0
 .else ${:U}
 .endif



Home | Main Index | Thread Index | Old Index