Module Name: src
Committed By: rillig
Date: Sun Sep 12 16:28:45 UTC 2021
Modified Files:
src/distrib/sets/lists/tests: mi
src/tests/usr.bin/xlint/lint1: Makefile msg_027.c msg_027.exp
src/usr.bin/xlint/lint1: decl.c err.c
Added Files:
src/tests/usr.bin/xlint/lint1: msg_347.c msg_347.exp
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.1123 -r1.1124 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.110 -r1.111 src/tests/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_027.c \
src/tests/usr.bin/xlint/lint1/msg_027.exp
cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/xlint/lint1/msg_347.c \
src/tests/usr.bin/xlint/lint1/msg_347.exp
cvs rdiff -u -r1.235 -r1.236 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.144 -r1.145 src/usr.bin/xlint/lint1/err.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.1123 src/distrib/sets/lists/tests/mi:1.1124
--- src/distrib/sets/lists/tests/mi:1.1123 Fri Sep 10 19:40:18 2021
+++ src/distrib/sets/lists/tests/mi Sun Sep 12 16:28:44 2021
@@ -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
Index: src/tests/usr.bin/xlint/lint1/Makefile
diff -u src/tests/usr.bin/xlint/lint1/Makefile:1.110 src/tests/usr.bin/xlint/lint1/Makefile:1.111
--- src/tests/usr.bin/xlint/lint1/Makefile:1.110 Fri Sep 10 19:40:18 2021
+++ src/tests/usr.bin/xlint/lint1/Makefile Sun Sep 12 16:28:45 2021
@@ -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>
Index: src/tests/usr.bin/xlint/lint1/msg_027.c
diff -u src/tests/usr.bin/xlint/lint1/msg_027.c:1.4 src/tests/usr.bin/xlint/lint1/msg_027.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_027.c:1.4 Sun Sep 12 16:08:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_027.c Sun Sep 12 16:28:45 2021
@@ -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);
Index: src/tests/usr.bin/xlint/lint1/msg_027.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_027.exp:1.4 src/tests/usr.bin/xlint/lint1/msg_027.exp:1.5
--- src/tests/usr.bin/xlint/lint1/msg_027.exp:1.4 Sun Sep 12 16:08:14 2021
+++ src/tests/usr.bin/xlint/lint1/msg_027.exp Sun Sep 12 16:28:45 2021
@@ -1,2 +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]
Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.235 src/usr.bin/xlint/lint1/decl.c:1.236
--- src/usr.bin/xlint/lint1/decl.c:1.235 Sun Sep 5 16:15:05 2021
+++ src/usr.bin/xlint/lint1/decl.c Sun Sep 12 16:28:45 2021
@@ -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 @@ check_redeclaration(sym_t *dsym, bool *d
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;
}
Index: src/usr.bin/xlint/lint1/err.c
diff -u src/usr.bin/xlint/lint1/err.c:1.144 src/usr.bin/xlint/lint1/err.c:1.145
--- src/usr.bin/xlint/lint1/err.c:1.144 Sun Sep 5 16:15:05 2021
+++ src/usr.bin/xlint/lint1/err.c Sun Sep 12 16:28:45 2021
@@ -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 @@ const char *const msgs[] = {
"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 {
Added files:
Index: src/tests/usr.bin/xlint/lint1/msg_347.c
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_347.c:1.1
--- /dev/null Sun Sep 12 16:28:45 2021
+++ src/tests/usr.bin/xlint/lint1/msg_347.c Sun Sep 12 16:28:45 2021
@@ -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));
Index: src/tests/usr.bin/xlint/lint1/msg_347.exp
diff -u /dev/null src/tests/usr.bin/xlint/lint1/msg_347.exp:1.1
--- /dev/null Sun Sep 12 16:28:45 2021
+++ src/tests/usr.bin/xlint/lint1/msg_347.exp Sun Sep 12 16:28:45 2021
@@ -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]