diff options
| -rw-r--r-- | tests/usr.bin/xlint/lint1/queries.c | 12 | ||||
| -rw-r--r-- | tests/usr.bin/xlint/lint1/t_usage.sh | 8 | ||||
| -rw-r--r-- | usr.bin/xlint/lint1/decl.c | 12 | ||||
| -rw-r--r-- | usr.bin/xlint/lint1/err.c | 5 |
4 files changed, 26 insertions, 11 deletions
diff --git a/tests/usr.bin/xlint/lint1/queries.c b/tests/usr.bin/xlint/lint1/queries.c index 01c2d06fe53..4c3873def98 100644 --- a/tests/usr.bin/xlint/lint1/queries.c +++ b/tests/usr.bin/xlint/lint1/queries.c @@ -1,4 +1,4 @@ -/* $NetBSD: queries.c,v 1.15 2023/06/22 13:57:44 rillig Exp $ */ +/* $NetBSD: queries.c,v 1.16 2023/06/24 06:55:34 rillig Exp $ */ # 3 "queries.c" /* @@ -15,7 +15,7 @@ * such as casts between arithmetic types. */ -/* lint1-extra-flags: -q 1,2,3,4,5,6,7,8,9,10,11,12 -X 351 */ +/* lint1-extra-flags: -q 1,2,3,4,5,6,7,8,9,10,11,12,13 -X 351 */ typedef unsigned char u8_t; typedef unsigned short u16_t; @@ -156,7 +156,7 @@ Q6(int i) i = (int)i + 1; } -extern void *allocate(void); +void *allocate(void); void Q7(void) @@ -397,6 +397,12 @@ Q12(void) u16 += u8, u32 += u16; } +/* expect+1: redundant 'extern' in function declaration of 'extern_Q13' [Q13] */ +extern void extern_Q13(void); +void extern_Q13(void); +/* expect+1: redundant 'extern' in function declaration of 'extern_Q13' [Q13] */ +extern void extern_Q13(void), *extern_ptr; + /* * Since queries do not affect the exit status, force a warning to make this * test conform to the general expectation that a test that produces output diff --git a/tests/usr.bin/xlint/lint1/t_usage.sh b/tests/usr.bin/xlint/lint1/t_usage.sh index 4a976d795c7..ade5f88093d 100644 --- a/tests/usr.bin/xlint/lint1/t_usage.sh +++ b/tests/usr.bin/xlint/lint1/t_usage.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_usage.sh,v 1.5 2023/06/22 13:57:44 rillig Exp $ +# $NetBSD: t_usage.sh,v 1.6 2023/06/24 06:55:34 rillig Exp $ # # Copyright (c) 2023 The NetBSD Foundation, Inc. # All rights reserved. @@ -97,13 +97,13 @@ enable_queries_body() # The largest known query. atf_check \ - "$lint1" -q 12 code.c /dev/null + "$lint1" -q 13 code.c /dev/null # Larger than the largest known query. atf_check \ -s 'exit:1' \ - -e "inline:lint1: invalid query ID '13'\n" \ - "$lint1" -q 13 code.c /dev/null + -e "inline:lint1: invalid query ID '14'\n" \ + "$lint1" -q 14 code.c /dev/null # Whitespace is not allowed before a query ID. atf_check \ 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 */ |
