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): in lint mode, check for ".else <cond>"



details:   https://anonhg.NetBSD.org/src/rev/c8e22518b957
branches:  trunk
changeset: 956987:c8e22518b957
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Nov 13 09:01:59 2020 +0000

description:
make(1): in lint mode, check for ".else <cond>"

diffstat:

 usr.bin/make/cond.c                        |   8 +++++---
 usr.bin/make/unit-tests/directive-else.exp |  13 ++++++++-----
 usr.bin/make/unit-tests/directive-else.mk  |   4 +++-
 usr.bin/make/unit-tests/objdir-writable.mk |   4 ++--
 4 files changed, 18 insertions(+), 11 deletions(-)

diffs (80 lines):

diff -r 706d3f1e3c01 -r c8e22518b957 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Fri Nov 13 08:35:34 2020 +0000
+++ b/usr.bin/make/cond.c       Fri Nov 13 09:01:59 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.213 2020/11/13 07:52:03 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.214 2020/11/13 09:01:59 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.213 2020/11/13 07:52:03 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.214 2020/11/13 09:01:59 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -1151,7 +1151,9 @@
        p += 2;
        if (is_token(p, "se", 2)) {     /* It is an 'else'. */
 
-           /* TODO: check for extraneous <cond> */
+           if (opts.lint && p[2] != '\0')
+               Parse_Error(PARSE_FATAL,
+                           "The .else directive does not take arguments.");
 
            if (cond_depth == cond_min_depth) {
                Parse_Error(PARSE_FATAL, "if-less else");
diff -r 706d3f1e3c01 -r c8e22518b957 usr.bin/make/unit-tests/directive-else.exp
--- a/usr.bin/make/unit-tests/directive-else.exp        Fri Nov 13 08:35:34 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-else.exp        Fri Nov 13 09:01:59 2020 +0000
@@ -1,8 +1,11 @@
-make: "directive-else.mk" line 10: ok
-make: "directive-else.mk" line 14: ok
-make: "directive-else.mk" line 20: if-less else
-make: "directive-else.mk" line 26: ok
-make: "directive-else.mk" line 27: warning: extra else
+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: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
diff -r 706d3f1e3c01 -r c8e22518b957 usr.bin/make/unit-tests/directive-else.mk
--- a/usr.bin/make/unit-tests/directive-else.mk Fri Nov 13 08:35:34 2020 +0000
+++ b/usr.bin/make/unit-tests/directive-else.mk Fri Nov 13 09:01:59 2020 +0000
@@ -1,7 +1,9 @@
-# $NetBSD: directive-else.mk,v 1.5 2020/11/13 08:35:34 rillig Exp $
+# $NetBSD: directive-else.mk,v 1.6 2020/11/13 09:01:59 rillig Exp $
 #
 # Tests for the .else directive.
 
+.MAKEFLAGS: -dL                        # To enable the check for ".else <cond>"
+
 # The .else directive does not take any arguments.
 # As of 2020-08-29, make doesn't warn about this.
 .if 0
diff -r 706d3f1e3c01 -r c8e22518b957 usr.bin/make/unit-tests/objdir-writable.mk
--- a/usr.bin/make/unit-tests/objdir-writable.mk        Fri Nov 13 08:35:34 2020 +0000
+++ b/usr.bin/make/unit-tests/objdir-writable.mk        Fri Nov 13 09:01:59 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: objdir-writable.mk,v 1.2 2020/11/12 23:53:17 sjg Exp $
+# $NetBSD: objdir-writable.mk,v 1.3 2020/11/13 09:01:59 rillig Exp $
 
 # test checking for writable objdir
 
@@ -22,6 +22,6 @@
        @MAKEOBJDIR=${RO_OBJDIR} ${.MAKE} -r -f /dev/null -C /tmp -V .OBJDIR MAKE_OBJDIR_CHECK_WRITABLE=no
 
 explicit-objdir:
-       @MAKEOBJDIR=/tmp ${.MAKE} -r -f ${MAKEFILE} -C /tmp do-objdir -V .OBJDIR
+       @MAKEOBJDIR=/tmp ${.MAKE} -r -f ${MAKEFILE:tA} -C /tmp do-objdir -V .OBJDIR
 .endif
 



Home | Main Index | Thread Index | Old Index