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: fix wrong error message in strict ...
details: https://anonhg.NetBSD.org/src/rev/94bc65906c01
branches: trunk
changeset: 1026289:94bc65906c01
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Nov 16 18:27:04 2021 +0000
description:
lint: fix wrong error message in strict bool mode
This fix only affects the last token before a macro, as well as the last
token in the expanded macro.
diffstat:
tests/usr.bin/xlint/lint1/d_c99_bool_strict.c | 26 ++++++++++++------------
tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp | 2 -
usr.bin/xlint/lint1/cgram.y | 10 ++++++--
3 files changed, 20 insertions(+), 18 deletions(-)
diffs (93 lines):
diff -r 7deb445d48e9 -r 94bc65906c01 tests/usr.bin/xlint/lint1/d_c99_bool_strict.c
--- a/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c Tue Nov 16 17:41:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c Tue Nov 16 18:27:04 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: d_c99_bool_strict.c,v 1.32 2021/11/16 06:55:03 rillig Exp $ */
+/* $NetBSD: d_c99_bool_strict.c,v 1.33 2021/11/16 18:27:04 rillig Exp $ */
# 3 "d_c99_bool_strict.c"
/*
@@ -838,14 +838,14 @@
return;
/*
- * FIXME: At the end of parsing the name 'stdio_stdout', the parser
- * has already looked ahead to the next token, to see whether it is
- * a '(' of a function call. At that point, the parser is no longer
- * in a system header, therefore 'stdio_stdout' is not tn_relaxed,
- * and this information is pushed down to the whole function call
- * expression.
+ * Before cgram.y 1.369 from 2021-11-16, at the end of parsing the
+ * name 'stdio_stdout', the parser already looked ahead to the next
+ * token, to see whether it was the '(' of a function call. At that
+ * point, the parser was no longer in a system header, therefore
+ * 'stdio_stdout' was not tn_relaxed, and this information was pushed
+ * down to the whole function call expression (which was another bug
+ * at that time).
*/
- /* expect+5: error: controlling expression must be bool, not 'int' [333] */
if (ferror(
# 851 "d_c99_bool_strict.c" 3 4
stdio_stdout
@@ -867,12 +867,12 @@
return;
/*
- * A comment following 'stdio_stdout' does not prevent the search for
- * '('. At the point where build_name calls expr_zalloc_tnode, the
- * parser is already in the main file again, thus treating
- * stdio_stdout as not coming from a system header.
+ * Before cgram.y 1.369 from 2021-11-16, the comment following
+ * 'stdio_stdout' did not prevent the search for '('. At the point
+ * where build_name calls expr_zalloc_tnode, the parser was already
+ * in the main file again, thus treating 'stdio_stdout' as not coming
+ * from a system header.
*/
- /* expect+5: error: controlling expression must be bool, not 'int' [333] */
if (ferror(
# 878 "d_c99_bool_strict.c" 3 4
stdio_stdout /* comment */
diff -r 7deb445d48e9 -r 94bc65906c01 tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp Tue Nov 16 17:41:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_bool_strict.exp Tue Nov 16 18:27:04 2021 +0000
@@ -171,5 +171,3 @@
d_c99_bool_strict.c(808): error: controlling expression must be bool, not 'int' [333]
d_c99_bool_strict.c(811): error: operand of '!' must be bool, not 'int' [330]
d_c99_bool_strict.c(814): error: operand of '!' must be bool, not 'int' [330]
-d_c99_bool_strict.c(853): error: controlling expression must be bool, not 'int' [333]
-d_c99_bool_strict.c(880): error: controlling expression must be bool, not 'int' [333]
diff -r 7deb445d48e9 -r 94bc65906c01 usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Tue Nov 16 17:41:23 2021 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Tue Nov 16 18:27:04 2021 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.368 2021/11/16 17:41:23 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.369 2021/11/16 18:27:04 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.368 2021/11/16 17:41:23 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.369 2021/11/16 18:27:04 rillig Exp $");
#endif
#include <limits.h>
@@ -420,10 +420,14 @@
/* K&R 7.1, C90 ???, C99 6.5.1, C11 6.5.1 */
primary_expression:
T_NAME {
- /* XXX really necessary? */
+ bool sys_name, sys_next;
+ sys_name = in_system_header;
if (yychar < 0)
yychar = yylex();
+ sys_next = in_system_header;
+ in_system_header = sys_name;
$$ = build_name(getsym($1), yychar);
+ in_system_header = sys_next;
}
| T_CON {
$$ = build_constant(gettyp($1->v_tspec), $1);
Home |
Main Index |
Thread Index |
Old Index