summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2023-06-24 06:55:34 +0000
committerrillig <rillig@NetBSD.org>2023-06-24 06:55:34 +0000
commitbbbb5a71d99f6eb815bbdf0b789038af407d72ba (patch)
treede74e7d8735a09b7bb2c5151afc86afda9d28e89 /usr.bin
parent96718dd1c216fdb7f83c89fb7440195b2ee88bfa (diff)
lint: add query for redundant 'extern' in function declaration
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/xlint/lint1/decl.c12
-rw-r--r--usr.bin/xlint/lint1/err.c5
2 files changed, 13 insertions, 4 deletions
diff --git a/usr.bin/xlint/lint1/decl.c b/usr.bin/xlint/lint1/decl.c
index 6ca072de5a8..8ace512825f 100644
--- a/usr.bin/xlint/lint1/decl.c
+++ b/usr.bin/xlint/lint1/decl.c
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.317 2023/06/09 15:36:31 rillig Exp $ */
+/* $NetBSD: decl.c,v 1.318 2023/06/24 06:55:34 rillig Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: decl.c,v 1.317 2023/06/09 15:36:31 rillig Exp $");
+__RCSID("$NetBSD: decl.c,v 1.318 2023/06/24 06:55:34 rillig Exp $");
#endif
#include <sys/param.h>
@@ -1942,6 +1942,14 @@ check_extern_declaration(const sym_t *sym)
warning(351, sym->s_type->t_tspec == FUNC ? "" : " 'extern'",
sym->s_name);
}
+ if (any_query_enabled &&
+ sym->s_type->t_tspec == FUNC &&
+ sym->s_scl == EXTERN &&
+ sym->s_def == DECL &&
+ !in_system_header) {
+ /* redundant 'extern' in function declaration of '%s' */
+ query_message(13, sym->s_name);
+ }
}
/* Process a single external or 'static' declarator. */
diff --git a/usr.bin/xlint/lint1/err.c b/usr.bin/xlint/lint1/err.c
index ec542d88ff7..1e6b0aa9ebd 100644
--- a/usr.bin/xlint/lint1/err.c
+++ b/usr.bin/xlint/lint1/err.c
@@ -1,4 +1,4 @@
-/* $NetBSD: err.c,v 1.200 2023/06/22 13:57:44 rillig Exp $ */
+/* $NetBSD: err.c,v 1.201 2023/06/24 06:55:34 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: err.c,v 1.200 2023/06/22 13:57:44 rillig Exp $");
+__RCSID("$NetBSD: err.c,v 1.201 2023/06/24 06:55:34 rillig Exp $");
#endif
#include <limits.h>
@@ -708,6 +708,7 @@ static const char *queries[] = {
"chained assignment with '%s' and '%s'", /* Q10 */
"static variable '%s' in function", /* Q11 */
"comma operator with types '%s' and '%s'", /* Q12 */
+ "redundant 'extern' in function declaration of '%s'", /* Q13 */
};
bool any_query_enabled; /* for optimizing non-query scenarios */