lint: be more precise in message 003 "tag in argument list"

This commit is contained in:
rillig 2021-01-31 09:26:27 +00:00
parent 3cef4b4f94
commit cfd7827cf3
3 changed files with 12 additions and 16 deletions

View File

@ -1,3 +1,3 @@
msg_003.c(9): warning: struct declared in argument declaration list [3] msg_003.c(9): warning: 'struct struct_in_argument' declared in argument declaration list [3]
msg_003.c(10): warning: union declared in argument declaration list [3] msg_003.c(10): warning: 'union union_in_argument' declared in argument declaration list [3]
msg_003.c(11): warning: enum declared in argument declaration list [3] msg_003.c(11): warning: 'enum enum_in_argument' declared in argument declaration list [3]

View File

@ -1,5 +1,5 @@
%{ %{
/* $NetBSD: cgram.y,v 1.157 2021/01/18 19:24:09 rillig Exp $ */ /* $NetBSD: cgram.y,v 1.158 2021/01/31 09:26:27 rillig Exp $ */
/* /*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@ -35,7 +35,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint) #if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: cgram.y,v 1.157 2021/01/18 19:24:09 rillig Exp $"); __RCSID("$NetBSD: cgram.y,v 1.158 2021/01/31 09:26:27 rillig Exp $");
#endif #endif
#include <limits.h> #include <limits.h>
@ -480,18 +480,14 @@ arg_declaration:
/* empty declaration */ /* empty declaration */
warning(2); warning(2);
} else { } else {
tspec_t ts = dcs->d_type->t_tspec; /* '%s' declared in argument declaration list */
/* %s declared in argument declaration list */ warning(3, type_name(dcs->d_type));
warning(3, ts == STRUCT ? "struct" :
(ts == UNION ? "union" : "enum"));
} }
} }
| declspecs deftyp type_init_decls T_SEMI { | declspecs deftyp type_init_decls T_SEMI {
if (dcs->d_nedecl) { if (dcs->d_nedecl) {
tspec_t ts = dcs->d_type->t_tspec; /* '%s' declared in argument declaration list */
/* %s declared in argument declaration list */ warning(3, type_name(dcs->d_type));
warning(3, ts == STRUCT ? "struct" :
(ts == UNION ? "union" : "enum"));
} }
} }
| declmods error | declmods error

View File

@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.72 2021/01/30 21:58:04 rillig Exp $ */ /* $NetBSD: err.c,v 1.73 2021/01/31 09:26:27 rillig Exp $ */
/* /*
* Copyright (c) 1994, 1995 Jochen Pohl * Copyright (c) 1994, 1995 Jochen Pohl
@ -37,7 +37,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint) #if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: err.c,v 1.72 2021/01/30 21:58:04 rillig Exp $"); __RCSID("$NetBSD: err.c,v 1.73 2021/01/31 09:26:27 rillig Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -62,7 +62,7 @@ const char *msgs[] = {
"empty declaration", /* 0 */ "empty declaration", /* 0 */
"old style declaration; add int", /* 1 */ "old style declaration; add int", /* 1 */
"empty declaration", /* 2 */ "empty declaration", /* 2 */
"%s declared in argument declaration list", /* 3 */ "'%s' declared in argument declaration list", /* 3 */
"illegal type combination", /* 4 */ "illegal type combination", /* 4 */
"modifying typedef with '%s'; only qualifiers allowed", /* 5 */ "modifying typedef with '%s'; only qualifiers allowed", /* 5 */
"use 'double' instead of 'long float'", /* 6 */ "use 'double' instead of 'long float'", /* 6 */