Wed Jan 27 00:02:38 2021 UTC ()
make(1): fix irrelevant message in -W mode


(rillig)
diff -r1.532 -r1.533 src/usr.bin/make/parse.c
diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-error.exp
diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/directive-error.mk
diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-warnings-as-errors.mk
diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-warnings-as-errors.exp

cvs diff -r1.532 -r1.533 src/usr.bin/make/parse.c (expand / switch to unified diff)

--- src/usr.bin/make/parse.c 2021/01/26 23:44:56 1.532
+++ src/usr.bin/make/parse.c 2021/01/27 00:02:38 1.533
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: parse.c,v 1.532 2021/01/26 23:44:56 rillig Exp $ */ 1/* $NetBSD: parse.c,v 1.533 2021/01/27 00:02:38 rillig Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1989, 1990, 1993 4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor. 8 * Adam de Boor.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -99,27 +99,27 @@ @@ -99,27 +99,27 @@
99 99
100#include <sys/types.h> 100#include <sys/types.h>
101#include <sys/stat.h> 101#include <sys/stat.h>
102#include <errno.h> 102#include <errno.h>
103#include <stdarg.h> 103#include <stdarg.h>
104#include <stdint.h> 104#include <stdint.h>
105 105
106#include "make.h" 106#include "make.h"
107#include "dir.h" 107#include "dir.h"
108#include "job.h" 108#include "job.h"
109#include "pathnames.h" 109#include "pathnames.h"
110 110
111/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ 111/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
112MAKE_RCSID("$NetBSD: parse.c,v 1.532 2021/01/26 23:44:56 rillig Exp $"); 112MAKE_RCSID("$NetBSD: parse.c,v 1.533 2021/01/27 00:02:38 rillig Exp $");
113 113
114/* types and constants */ 114/* types and constants */
115 115
116/* 116/*
117 * Structure for a file being read ("included file") 117 * Structure for a file being read ("included file")
118 */ 118 */
119typedef struct IFile { 119typedef struct IFile {
120 char *fname; /* name of file (relative? absolute?) */ 120 char *fname; /* name of file (relative? absolute?) */
121 Boolean fromForLoop; /* simulated .include by the .for loop */ 121 Boolean fromForLoop; /* simulated .include by the .for loop */
122 int lineno; /* current line number in file */ 122 int lineno; /* current line number in file */
123 int first_lineno; /* line number of start of text */ 123 int first_lineno; /* line number of start of text */
124 unsigned int cond_depth; /* 'if' nesting when file opened */ 124 unsigned int cond_depth; /* 'if' nesting when file opened */
125 Boolean depending; /* state of doing_depend on EOF */ 125 Boolean depending; /* state of doing_depend on EOF */
@@ -601,33 +601,30 @@ ParseVErrorInternal(FILE *f, const char  @@ -601,33 +601,30 @@ ParseVErrorInternal(FILE *f, const char
601 601
602 (void)fprintf(f, "%s: ", progname); 602 (void)fprintf(f, "%s: ", progname);
603 603
604 if (fname != NULL) 604 if (fname != NULL)
605 PrintLocation(f, fname, lineno); 605 PrintLocation(f, fname, lineno);
606 if (type == PARSE_WARNING) 606 if (type == PARSE_WARNING)
607 (void)fprintf(f, "warning: "); 607 (void)fprintf(f, "warning: ");
608 (void)vfprintf(f, fmt, ap); 608 (void)vfprintf(f, fmt, ap);
609 (void)fprintf(f, "\n"); 609 (void)fprintf(f, "\n");
610 (void)fflush(f); 610 (void)fflush(f);
611 611
612 if (type == PARSE_INFO) 612 if (type == PARSE_INFO)
613 goto print_stack_trace; 613 goto print_stack_trace;
614 if (type == PARSE_FATAL || opts.parseWarnFatal) 614 if (type == PARSE_WARNING && !opts.parseWarnFatal)
615 fatals++; 615 goto print_stack_trace;
616 if (opts.parseWarnFatal && !fatal_warning_error_printed) { 616 fatals++;
617 /* 617 if (type == PARSE_WARNING && !fatal_warning_error_printed) {
618 * FIXME: Also gets printed on .error, even though it 
619 * doesn't apply to it. 
620 */ 
621 Error("parsing warnings being treated as errors"); 618 Error("parsing warnings being treated as errors");
622 fatal_warning_error_printed = TRUE; 619 fatal_warning_error_printed = TRUE;
623 } 620 }
624 621
625print_stack_trace: 622print_stack_trace:
626 PrintStackTrace(); 623 PrintStackTrace();
627} 624}
628 625
629static void 626static void
630ParseErrorInternal(const char *fname, size_t lineno, 627ParseErrorInternal(const char *fname, size_t lineno,
631 ParseErrorLevel type, const char *fmt, ...) 628 ParseErrorLevel type, const char *fmt, ...)
632{ 629{
633 va_list ap; 630 va_list ap;

cvs diff -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-error.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/directive-error.exp 2021/01/26 23:51:20 1.2
+++ src/usr.bin/make/unit-tests/directive-error.exp 2021/01/27 00:02:38 1.3
@@ -1,5 +1,4 @@ @@ -1,5 +1,4 @@
1make: "directive-error.mk" line 11: message 1make: "directive-error.mk" line 13: message
2make: parsing warnings being treated as errors 
3 2
4make: stopped in unit-tests 3make: stopped in unit-tests
5exit status 1 4exit status 1

cvs diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/directive-error.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/directive-error.mk 2021/01/26 23:51:20 1.4
+++ src/usr.bin/make/unit-tests/directive-error.mk 2021/01/27 00:02:38 1.5
@@ -1,11 +1,13 @@ @@ -1,11 +1,13 @@
1# $NetBSD: directive-error.mk,v 1.4 2021/01/26 23:51:20 rillig Exp $ 1# $NetBSD: directive-error.mk,v 1.5 2021/01/27 00:02:38 rillig Exp $
2# 2#
3# Tests for the .error directive, which prints an error message and exits 3# Tests for the .error directive, which prints an error message and exits
4# immediately, unlike other "fatal" parse errors, which continue to parse 4# immediately, unlike other "fatal" parse errors, which continue to parse
5# until the end of the current top-level makefile. 5# until the end of the current top-level makefile.
 6#
 7# See also:
 8# opt-warnings-as-errors.mk
6 9
7# TODO: Implementation 10# Before parse.c 1.532 from 2021-01-27, the ".error" issued an irrelevant
8 11# message saying "parsing warnings being treated as errors".
9# FIXME: The "parsing warnings being treated as errors" is irrelevant. 
10.MAKEFLAGS: -W 12.MAKEFLAGS: -W
11.error message 13.error message

cvs diff -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-warnings-as-errors.mk (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/opt-warnings-as-errors.mk 2020/11/09 20:50:56 1.4
+++ src/usr.bin/make/unit-tests/opt-warnings-as-errors.mk 2021/01/27 00:02:38 1.5
@@ -1,13 +1,18 @@ @@ -1,13 +1,18 @@
1# $NetBSD: opt-warnings-as-errors.mk,v 1.4 2020/11/09 20:50:56 rillig Exp $ 1# $NetBSD: opt-warnings-as-errors.mk,v 1.5 2021/01/27 00:02:38 rillig Exp $
2# 2#
3# Tests for the -W command line option, which turns warnings into errors. 3# Tests for the -W command line option, which turns warnings into errors.
 4#
 5# Even in -W mode, a .warning is not completely equivalent to an .error.
 6# First, the word "warning" is still printed, and second, parsing continues
 7# after a failed warning, whereas it would stop immediately at the first
 8# .error.
4 9
5.MAKEFLAGS: -W 10.MAKEFLAGS: -W
6 11
7.warning message 1 12.warning message 1
8.warning message 2 13.warning message 2
9 14
10_!= echo 'parsing continues' 1>&2 15_!= echo 'parsing continues' 1>&2
11 16
12all: 17all:
13 @:; 18 @:;

cvs diff -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-warnings-as-errors.exp (expand / switch to unified diff)

--- src/usr.bin/make/unit-tests/opt-warnings-as-errors.exp 2020/11/09 20:50:56 1.3
+++ src/usr.bin/make/unit-tests/opt-warnings-as-errors.exp 2021/01/27 00:02:38 1.4
@@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
1make: "opt-warnings-as-errors.mk" line 7: warning: message 1 1make: "opt-warnings-as-errors.mk" line 12: warning: message 1
2make: parsing warnings being treated as errors 2make: parsing warnings being treated as errors
3make: "opt-warnings-as-errors.mk" line 8: warning: message 2 3make: "opt-warnings-as-errors.mk" line 13: warning: message 2
4parsing continues 4parsing continues
5make: Fatal errors encountered -- cannot continue 5make: Fatal errors encountered -- cannot continue
6make: stopped in unit-tests 6make: stopped in unit-tests
7exit status 1 7exit status 1