make(1): in lint mode, check for ".else <cond>"
This commit is contained in:
parent
eb5fad2de4
commit
ecb0e97ca6
@ -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 @@ Cond_EvalLine(const char *const line)
|
||||
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");
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 @@ ro-objdir:
|
||||
@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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user