Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: report proper file name in asserti...
details: https://anonhg.NetBSD.org/src/rev/cbfa5a766784
branches: trunk
changeset: 366556:cbfa5a766784
user: rillig <rillig%NetBSD.org@localhost>
date: Mon May 30 15:13:25 2022 +0000
description:
lint: report proper file name in assertion failures
When given the (obviously malformed) translation unit 'f=({;};}', lint
runs into an assertion failure. It reported this as occurring near
':1'. This location was missing a filename since the input didn't
contain a GCC line number directive such as '# 2 "input.c"'. In GCC mode,
the GCC builtins are loaded first, in which case the reported location
was ':9'.
Fix this by providing proper location information, even for input that
does not come from the GCC C preprocessor.
diffstat:
usr.bin/xlint/lint1/main1.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diffs (38 lines):
diff -r 85e920d628ee -r cbfa5a766784 usr.bin/xlint/lint1/main1.c
--- a/usr.bin/xlint/lint1/main1.c Mon May 30 15:11:45 2022 +0000
+++ b/usr.bin/xlint/lint1/main1.c Mon May 30 15:13:25 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main1.c,v 1.62 2022/05/20 21:18:55 rillig Exp $ */
+/* $NetBSD: main1.c,v 1.63 2022/05/30 15:13:25 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: main1.c,v 1.62 2022/05/20 21:18:55 rillig Exp $");
+__RCSID("$NetBSD: main1.c,v 1.63 2022/05/30 15:13:25 rillig Exp $");
#endif
#include <sys/types.h>
@@ -288,6 +288,9 @@
if (allow_gcc && allow_c90) {
if ((yyin = gcc_builtins()) == NULL)
err(1, "cannot open builtins");
+ curr_pos.p_file = "<gcc-builtins>";
+ curr_pos.p_line = 0;
+ lex_next_line();
yyparse();
(void)fclose(yyin);
}
@@ -295,6 +298,9 @@
/* open the input file */
if ((yyin = fopen(argv[0], "r")) == NULL)
err(1, "cannot open '%s'", argv[0]);
+ curr_pos.p_file = argv[0];
+ curr_pos.p_line = 0;
+ lex_next_line();
yyparse();
(void)fclose(yyin);
Home |
Main Index |
Thread Index |
Old Index