make(1): error out on .else with extraneous text
This commit is contained in:
parent
bb1cb5b505
commit
a1af58d13b
|
@ -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 @@ Cond_EvalLine(const char *line)
|
|||
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.");
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
#
|
||||
# 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.
|
||||
|
||||
.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
|
||||
. 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
|
||||
|
|
Loading…
Reference in New Issue