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: add more details to error about re...
details: https://anonhg.NetBSD.org/src/rev/6dc4944c7511
branches: trunk
changeset: 1023535:6dc4944c7511
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Sep 12 16:28:44 2021 +0000
description:
lint: add more details to error about redeclaration
Message 27 is triggered by several conditions. The one triggered by
register_vget in sbin/fsck_lfs/vnode.c needs more details than the
others.
diffstat:
distrib/sets/lists/tests/mi | 4 +++-
tests/usr.bin/xlint/lint1/Makefile | 4 ++--
tests/usr.bin/xlint/lint1/msg_027.c | 21 +++------------------
tests/usr.bin/xlint/lint1/msg_027.exp | 3 +--
tests/usr.bin/xlint/lint1/msg_347.c | 29 +++++++++++++++++++++++++++++
tests/usr.bin/xlint/lint1/msg_347.exp | 2 ++
usr.bin/xlint/lint1/decl.c | 9 +++++----
usr.bin/xlint/lint1/err.c | 5 +++--
8 files changed, 48 insertions(+), 29 deletions(-)
diffs (164 lines):
diff -r 0b880798c37c -r 6dc4944c7511 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Sep 12 16:08:14 2021 +0000
+++ b/distrib/sets/lists/tests/mi Sun Sep 12 16:28:44 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1123 2021/09/10 19:40:18 rillig Exp $
+# $NetBSD: mi,v 1.1124 2021/09/12 16:28:44 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -7028,6 +7028,8 @@
./usr/tests/usr.bin/xlint/lint1/msg_345.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_346.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_346.exp tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_347.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/msg_347.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/op_colon.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/op_colon.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/op_shl_lp64.c tests-usr.bin-tests compattestfile,atf
diff -r 0b880798c37c -r 6dc4944c7511 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Sun Sep 12 16:08:14 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Sun Sep 12 16:28:44 2021 +0000
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.110 2021/09/10 19:40:18 rillig Exp $
+# $NetBSD: Makefile,v 1.111 2021/09/12 16:28:45 rillig Exp $
NOMAN= # defined
-MAX_MESSAGE= 346 # see lint1/err.c
+MAX_MESSAGE= 347 # see lint1/err.c
.include <bsd.own.mk>
diff -r 0b880798c37c -r 6dc4944c7511 tests/usr.bin/xlint/lint1/msg_027.c
--- a/tests/usr.bin/xlint/lint1/msg_027.c Sun Sep 12 16:08:14 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_027.c Sun Sep 12 16:28:44 2021 +0000
@@ -1,24 +1,9 @@
-/* $NetBSD: msg_027.c,v 1.4 2021/09/12 16:08:14 rillig Exp $ */
+/* $NetBSD: msg_027.c,v 1.5 2021/09/12 16:28:45 rillig Exp $ */
# 3 "msg_027.c"
// Test for message: redeclaration of %s [27]
extern int identifier(void);
-extern double identifier(void); /* expect: 27 */
-
-/*
- * As of 2021-09-12, lint complains about mismatched types.
- * GCC and Clang accept this.
- *
- * Above:
- * function(pointer to void, int) returning void
- *
- * Below: function(
- * pointer to void,
- * pointer to function(pointer to void, int) returning pointer to double
- * ) returning void
- */
-void function_parameter(void *, double *(void *, int));
-/* expect+1: error: redeclaration of function_parameter [27] */
-void function_parameter(void *fs, double *func(void *, int));
+/* expect+1: error: redeclaration of 'identifier' with type 'function(void) returning double', expected 'function(void) returning int' [347] */
+extern double identifier(void);
diff -r 0b880798c37c -r 6dc4944c7511 tests/usr.bin/xlint/lint1/msg_027.exp
--- a/tests/usr.bin/xlint/lint1/msg_027.exp Sun Sep 12 16:08:14 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_027.exp Sun Sep 12 16:28:44 2021 +0000
@@ -1,2 +1,1 @@
-msg_027.c(8): error: redeclaration of identifier [27]
-msg_027.c(24): error: redeclaration of function_parameter [27]
+msg_027.c(9): error: redeclaration of 'identifier' with type 'function(void) returning double', expected 'function(void) returning int' [347]
diff -r 0b880798c37c -r 6dc4944c7511 tests/usr.bin/xlint/lint1/msg_347.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_347.c Sun Sep 12 16:28:44 2021 +0000
@@ -0,0 +1,29 @@
+/* $NetBSD: msg_347.c,v 1.1 2021/09/12 16:28:45 rillig Exp $ */
+# 3 "msg_347.c"
+
+// Test for message: redeclaration of '%s' with type '%s', expected '%s' [347]
+
+/* lint1-extra-flags: -r */
+
+/*
+ * Message 27 already covers redeclarations, but it doesn't include enough
+ * details to make any sense of it.
+ */
+
+/*
+ * As of 2021-09-12, lint complains about mismatched types.
+ * GCC and Clang accept this.
+ *
+ * Above:
+ * function(pointer to void, int) returning void
+ *
+ * Below: function(
+ * pointer to void,
+ * pointer to function(pointer to void, int) returning pointer to double
+ * ) returning void
+ */
+/* FIXME: the type of the second parameter is not 'int' */
+/* expect+1: previous declaration of function_parameter [260] */
+void function_parameter(void *, double *(void *, int));
+/* expect+1: error: redeclaration of 'function_parameter' with type 'function(pointer to void, pointer to function(pointer to void, int) returning pointer to double) returning void', expected
'function(pointer to void, int) returning void' [347] */
+void function_parameter(void *fs, double *func(void *, int));
diff -r 0b880798c37c -r 6dc4944c7511 tests/usr.bin/xlint/lint1/msg_347.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_347.exp Sun Sep 12 16:28:44 2021 +0000
@@ -0,0 +1,2 @@
+msg_347.c(29): error: redeclaration of 'function_parameter' with type 'function(pointer to void, pointer to function(pointer to void, int) returning pointer to double) returning void', expected
'function(pointer to void, int) returning void' [347]
+msg_347.c(27): previous declaration of function_parameter [260]
diff -r 0b880798c37c -r 6dc4944c7511 usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Sun Sep 12 16:08:14 2021 +0000
+++ b/usr.bin/xlint/lint1/decl.c Sun Sep 12 16:28:44 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.235 2021/09/05 16:15:05 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.236 2021/09/12 16:28:45 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.235 2021/09/05 16:15:05 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.236 2021/09/12 16:28:45 rillig Exp $");
#endif
#include <sys/param.h>
@@ -2081,8 +2081,9 @@
return true;
}
if (!eqtype(rsym->s_type, dsym->s_type, false, false, dowarn)) {
- /* redeclaration of %s */
- error(27, dsym->s_name);
+ /* redeclaration of '%s' with type '%s', expected '%s' */
+ error(347, dsym->s_name,
+ type_name(dsym->s_type), type_name(rsym->s_type));
print_previous_declaration(-1, rsym);
return true;
}
diff -r 0b880798c37c -r 6dc4944c7511 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Sun Sep 12 16:08:14 2021 +0000
+++ b/usr.bin/xlint/lint1/err.c Sun Sep 12 16:28:44 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.144 2021/09/05 16:15:05 rillig Exp $ */
+/* $NetBSD: err.c,v 1.145 2021/09/12 16:28:45 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: err.c,v 1.144 2021/09/05 16:15:05 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.145 2021/09/12 16:28:45 rillig Exp $");
#endif
#include <sys/types.h>
@@ -401,6 +401,7 @@
"bit-field of type plain 'int' has implementation-defined signedness", /* 344 */
"generic selection requires C11 or later", /* 345 */
"call to '%s' effectively discards 'const' from argument", /* 346 */
+ "redeclaration of '%s' with type '%s', expected '%s'", /* 347 */
};
static struct include_level {
Home |
Main Index |
Thread Index |
Old Index