lint: remove unused message 70, add some more tests

This commit is contained in:
rillig 2022-04-08 21:29:29 +00:00
parent 6e7f090990
commit 321092b8ae
17 changed files with 146 additions and 33 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: mi,v 1.1190 2022/04/05 23:09:19 rillig Exp $
# $NetBSD: mi,v 1.1191 2022/04/08 21:29:29 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@ -6686,7 +6686,7 @@
./usr/tests/usr.bin/xlint/lint1/msg_069.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_069.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_070.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_070.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_070.exp tests-obsolete obsolete,atf
./usr/tests/usr.bin/xlint/lint1/msg_071.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_071.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/msg_072.c tests-usr.bin-tests compattestfile,atf

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.118 2022/04/05 23:09:19 rillig Exp $
# $NetBSD: Makefile,v 1.119 2022/04/08 21:29:29 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 348 # see lint1/err.c
@ -216,7 +216,7 @@ FILES+= lex_wide_char.c
FILES+= lex_wide_char.exp
FILES+= lex_wide_string.c
FILES+= lex_wide_string.exp
FILES+= ${:U0 ${:U:${:Urange=${MAX_MESSAGE}}}:C,^.$,0&,:C,^..$,0&,:@i@msg_${i}.c msg_${i}.exp@:Nmsg_040.exp:Nmsg_176.exp}
FILES+= ${MSG_FILES}
FILES+= msg_001_c90.c
FILES+= msg_001_c90.exp
FILES+= msg_000_c90.c
@ -266,6 +266,12 @@ FILES+= stmt_goto.exp
FILES+= stmt_if.c
FILES+= stmt_if.exp
MSG_IDS= ${:U0 ${:U:${:Urange=${MAX_MESSAGE}}}:C,^.$,0&,:C,^..$,0&,}
MSG_FILES= ${MSG_IDS:@id@msg_${id}.c ${MSG_NO_EXP.${id}:D:Umsg_${id}.exp}@}
MSG_NO_EXP.040= yes
MSG_NO_EXP.070= yes
MSG_NO_EXP.176= yes
# Note: only works for adding tests.
# To remove a test, the $$mi file must be edited manually.
sync-mi: .PHONY

View File

@ -1,4 +1,4 @@
/* $NetBSD: decl_enum.c,v 1.1 2021/07/15 21:00:05 rillig Exp $ */
/* $NetBSD: decl_enum.c,v 1.2 2022/04/08 21:29:29 rillig Exp $ */
# 3 "decl_enum.c"
/*
@ -17,3 +17,44 @@ enum goto {
A
};
/* expect-1: warning: empty declaration [0] */
/*
* Ensure that nested enum declarations get the value of each enum constant
* right. The variable containing the "current enum value" does not account
* for these nested declarations. Such declarations don't occur in practice
* though.
*/
enum outer {
o1 = sizeof(
enum inner {
i1 = 10000, i2, i3
}
),
/*
* The only attribute that GCC 12 allows for enum constants is
* __deprecated__, and there is no way to smuggle an integer constant
* expression into the attribute. If there were a way, and the
* expression contained an enum declaration, the value of the outer
* enum constant would become the value of the last seen inner enum
* constant. This is because 'enumval' is a simple scalar variable,
* not a stack. If it should ever become necessary to account for
* nested enum declarations, a field should be added in dinfo_t.
*/
o2 __attribute__((__deprecated__)),
o3 = i3
};
/* expect+1: error: negative array dimension (-10000) [20] */
typedef int reveal_i1[-i1];
/* expect+1: error: negative array dimension (-10001) [20] */
typedef int reveal_i2[-i2];
/* expect+1: error: negative array dimension (-10002) [20] */
typedef int reveal_i3[-i3];
/* expect+1: error: negative array dimension (-4) [20] */
typedef int reveal_o1[-o1];
/* expect+1: error: negative array dimension (-5) [20] */
typedef int reveal_o2[-o2];
/* expect+1: error: negative array dimension (-10002) [20] */
typedef int reveal_o3[-o3];

View File

@ -1,3 +1,9 @@
decl_enum.c(11): error: syntax error 'goto' [249]
decl_enum.c(16): error: syntax error 'goto' [249]
decl_enum.c(18): warning: empty declaration [0]
decl_enum.c(49): error: negative array dimension (-10000) [20]
decl_enum.c(51): error: negative array dimension (-10001) [20]
decl_enum.c(53): error: negative array dimension (-10002) [20]
decl_enum.c(56): error: negative array dimension (-4) [20]
decl_enum.c(58): error: negative array dimension (-5) [20]
decl_enum.c(60): error: negative array dimension (-10002) [20]

View File

@ -1,7 +1,13 @@
/* $NetBSD: msg_042.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
/* $NetBSD: msg_042.c,v 1.3 2022/04/08 21:29:29 rillig Exp $ */
# 3 "msg_042.c"
// Test for message: forward reference to enum type [42]
/* Test for message: forward reference to enum type [42] */
TODO: "Add example code that triggers the above message." /* expect: 249 */
TODO: "Add example code that almost triggers the above message."
/* lint1-extra-flags: -p */
/* expect+1: warning: forward reference to enum type [42] */
enum forward;
enum forward {
defined
};

View File

@ -1 +1 @@
msg_042.c(6): error: syntax error ':' [249]
msg_042.c(9): warning: forward reference to enum type [42]

View File

@ -1,7 +1,19 @@
/* $NetBSD: msg_043.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
/* $NetBSD: msg_043.c,v 1.3 2022/04/08 21:29:29 rillig Exp $ */
# 3 "msg_043.c"
// Test for message: redefinition hides earlier one: %s [43]
/* Test for message: redefinition hides earlier one: %s [43] */
TODO: "Add example code that triggers the above message." /* expect: 249 */
TODO: "Add example code that almost triggers the above message."
/* lint1-extra-flags: -h */
struct s {
int member;
};
void
example(void)
{
/* expect+1: warning: redefinition hides earlier one: s [43] */
struct s {
int member;
};
}

View File

@ -1 +1 @@
msg_043.c(6): error: syntax error ':' [249]
msg_043.c(16): warning: redefinition hides earlier one: s [43]

View File

@ -1,7 +1,21 @@
/* $NetBSD: msg_045.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
/* $NetBSD: msg_045.c,v 1.3 2022/04/08 21:29:29 rillig Exp $ */
# 3 "msg_045.c"
// Test for message: base type is really '%s %s' [45]
/* Test for message: base type is really '%s %s' [45] */
TODO: "Add example code that triggers the above message." /* expect: 249 */
TODO: "Add example code that almost triggers the above message."
/* lint1-flags: -tw */
struct counter {
int value;
};
function()
{
/* expect+4: warning: base type is really 'struct counter' [45] */
/* expect+3: warning: declaration introduces new type in ANSI C: union counter [44] */
/* expect+2: error: 'counter' has incomplete type 'incomplete union counter' [31] */
/* expect+1: warning: union counter never defined [234] */
union counter counter;
/* expect+1: warning: illegal member use: value [102] */
counter.value++;
}

View File

@ -1 +1,5 @@
msg_045.c(6): error: syntax error ':' [249]
msg_045.c(18): warning: base type is really 'struct counter' [45]
msg_045.c(18): warning: declaration introduces new type in ANSI C: union counter [44]
msg_045.c(18): error: 'counter' has incomplete type 'incomplete union counter' [31]
msg_045.c(20): warning: illegal member use: value [102]
msg_045.c(18): warning: union counter never defined [234]

View File

@ -1,7 +1,24 @@
/* $NetBSD: msg_048.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
/* $NetBSD: msg_048.c,v 1.3 2022/04/08 21:29:29 rillig Exp $ */
# 3 "msg_048.c"
// Test for message: overflow in enumeration values: %s [48]
/*
* Before decl.c 1.TODO from 2022-04-TODO, the comparison for enum constant
* overflow was done in signed arithmetic, and since 'enumval' wrapped
* around, its value became INT_MIN, at least on platforms where integer
* overflow was defined as 2-complements wrap-around. When comparing
* 'enumval - 1 == TARG_INT_MAX', there was another integer overflow, and
* this one was optimized away by GCC, taking advantage of the undefined
* behavior.
*/
enum int_limits {
MAX_MINUS_2 = 0x7ffffffd,
MAX_MINUS_1,
MAX,
/* TODO: expect: overflow in enumeration values: MIN */
MIN
};
TODO: "Add example code that triggers the above message." /* expect: 249 */
TODO: "Add example code that almost triggers the above message."

View File

@ -1 +1 @@
msg_048.c(6): error: syntax error ':' [249]
msg_048.c(23): error: syntax error ':' [249]

View File

@ -1,7 +1,12 @@
/* $NetBSD: msg_069.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
/* $NetBSD: msg_069.c,v 1.3 2022/04/08 21:29:29 rillig Exp $ */
# 3 "msg_069.c"
// Test for message: inappropriate qualifiers with 'void' [69]
TODO: "Add example code that triggers the above message." /* expect: 249 */
TODO: "Add example code that almost triggers the above message."
/* expect+2: error: void type for 'const_void' [19] */
/* expect+1: warning: inappropriate qualifiers with 'void' */
const void const_void;
/* expect+2: error: void type for 'volatile_void' [19] */
/* expect+1: warning: inappropriate qualifiers with 'void' */
volatile void volatile_void;

View File

@ -1 +1,4 @@
msg_069.c(6): error: syntax error ':' [249]
msg_069.c(8): error: void type for 'const_void' [19]
msg_069.c(8): warning: inappropriate qualifiers with 'void' [69]
msg_069.c(12): error: void type for 'volatile_void' [19]
msg_069.c(12): warning: inappropriate qualifiers with 'void' [69]

View File

@ -1,7 +1,7 @@
/* $NetBSD: msg_070.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */
/* $NetBSD: msg_070.c,v 1.3 2022/04/08 21:29:29 rillig Exp $ */
# 3 "msg_070.c"
// Test for message: %soperand of '%s' is unsigned in ANSI C [70]
/* This message is not used. */
TODO: "Add example code that triggers the above message." /* expect: 249 */
TODO: "Add example code that almost triggers the above message."
int var;

View File

@ -1 +0,0 @@
msg_070.c(6): error: syntax error ':' [249]

View File

@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.158 2022/04/05 23:13:56 rillig Exp $ */
/* $NetBSD: err.c,v 1.159 2022/04/08 21:29:29 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.158 2022/04/05 23:13:56 rillig Exp $");
__RCSID("$NetBSD: err.c,v 1.159 2022/04/08 21:29:29 rillig Exp $");
#endif
#include <sys/types.h>
@ -124,7 +124,7 @@ const char *const msgs[] = {
"cannot return incomplete type", /* 67 */
"typedef already qualified with '%s'", /* 68 */
"inappropriate qualifiers with 'void'", /* 69 */
"%soperand of '%s' is unsigned in ANSI C", /* 70 */
"", /* unused */ /* 70 */
"too many characters in character constant", /* 71 */
"typedef declares no type name", /* 72 */
"empty character constant", /* 73 */