Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: remove unused message 70, add some...



details:   https://anonhg.NetBSD.org/src/rev/d0daa2fcb0e9
branches:  trunk
changeset: 364714:d0daa2fcb0e9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Apr 08 21:29:29 2022 +0000

description:
lint: remove unused message 70, add some more tests

diffstat:

 distrib/sets/lists/tests/mi             |   4 +-
 tests/usr.bin/xlint/lint1/Makefile      |  10 ++++++-
 tests/usr.bin/xlint/lint1/decl_enum.c   |  43 ++++++++++++++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/decl_enum.exp |   6 ++++
 tests/usr.bin/xlint/lint1/msg_042.c     |  14 +++++++---
 tests/usr.bin/xlint/lint1/msg_042.exp   |   2 +-
 tests/usr.bin/xlint/lint1/msg_043.c     |  20 ++++++++++++---
 tests/usr.bin/xlint/lint1/msg_043.exp   |   2 +-
 tests/usr.bin/xlint/lint1/msg_045.c     |  22 +++++++++++++---
 tests/usr.bin/xlint/lint1/msg_045.exp   |   6 +++-
 tests/usr.bin/xlint/lint1/msg_048.c     |  19 +++++++++++++-
 tests/usr.bin/xlint/lint1/msg_048.exp   |   2 +-
 tests/usr.bin/xlint/lint1/msg_069.c     |  11 ++++++--
 tests/usr.bin/xlint/lint1/msg_069.exp   |   5 +++-
 tests/usr.bin/xlint/lint1/msg_070.c     |   6 ++--
 tests/usr.bin/xlint/lint1/msg_070.exp   |   1 -
 usr.bin/xlint/lint1/err.c               |   6 ++--
 17 files changed, 146 insertions(+), 33 deletions(-)

diffs (truncated from 324 to 300 lines):

diff -r 71a77dc221bb -r d0daa2fcb0e9 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Fri Apr 08 20:11:31 2022 +0000
+++ b/distrib/sets/lists/tests/mi       Fri Apr 08 21:29:29 2022 +0000
@@ -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
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Fri Apr 08 21:29:29 2022 +0000
@@ -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.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_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
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/decl_enum.c
--- a/tests/usr.bin/xlint/lint1/decl_enum.c     Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/decl_enum.c     Fri Apr 08 21:29:29 2022 +0000
@@ -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 @@
        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];
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/decl_enum.exp
--- a/tests/usr.bin/xlint/lint1/decl_enum.exp   Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/decl_enum.exp   Fri Apr 08 21:29:29 2022 +0000
@@ -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]
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/msg_042.c
--- a/tests/usr.bin/xlint/lint1/msg_042.c       Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_042.c       Fri Apr 08 21:29:29 2022 +0000
@@ -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] */
+
+/* lint1-extra-flags: -p */
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* expect+1: warning: forward reference to enum type [42] */
+enum forward;
+
+enum forward {
+       defined
+};
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/msg_042.exp
--- a/tests/usr.bin/xlint/lint1/msg_042.exp     Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_042.exp     Fri Apr 08 21:29:29 2022 +0000
@@ -1,1 +1,1 @@
-msg_042.c(6): error: syntax error ':' [249]
+msg_042.c(9): warning: forward reference to enum type [42]
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/msg_043.c
--- a/tests/usr.bin/xlint/lint1/msg_043.c       Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_043.c       Fri Apr 08 21:29:29 2022 +0000
@@ -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] */
+
+/* lint1-extra-flags: -h */
+
+struct s {
+       int member;
+};
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+void
+example(void)
+{
+       /* expect+1: warning: redefinition hides earlier one: s [43] */
+       struct s {
+               int member;
+       };
+}
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/msg_043.exp
--- a/tests/usr.bin/xlint/lint1/msg_043.exp     Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_043.exp     Fri Apr 08 21:29:29 2022 +0000
@@ -1,1 +1,1 @@
-msg_043.c(6): error: syntax error ':' [249]
+msg_043.c(16): warning: redefinition hides earlier one: s [43]
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/msg_045.c
--- a/tests/usr.bin/xlint/lint1/msg_045.c       Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_045.c       Fri Apr 08 21:29:29 2022 +0000
@@ -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] */
+
+/* lint1-flags: -tw */
+
+struct counter {
+       int value;
+};
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+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++;
+}
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/msg_045.exp
--- a/tests/usr.bin/xlint/lint1/msg_045.exp     Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_045.exp     Fri Apr 08 21:29:29 2022 +0000
@@ -1,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]
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/msg_048.c
--- a/tests/usr.bin/xlint/lint1/msg_048.c       Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_048.c       Fri Apr 08 21:29:29 2022 +0000
@@ -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."
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/msg_048.exp
--- a/tests/usr.bin/xlint/lint1/msg_048.exp     Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_048.exp     Fri Apr 08 21:29:29 2022 +0000
@@ -1,1 +1,1 @@
-msg_048.c(6): error: syntax error ':' [249]
+msg_048.c(23): error: syntax error ':' [249]
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/msg_069.c
--- a/tests/usr.bin/xlint/lint1/msg_069.c       Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_069.c       Fri Apr 08 21:29:29 2022 +0000
@@ -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;
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/msg_069.exp
--- a/tests/usr.bin/xlint/lint1/msg_069.exp     Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_069.exp     Fri Apr 08 21:29:29 2022 +0000
@@ -1,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]
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/msg_070.c
--- a/tests/usr.bin/xlint/lint1/msg_070.c       Fri Apr 08 20:11:31 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_070.c       Fri Apr 08 21:29:29 2022 +0000
@@ -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;
diff -r 71a77dc221bb -r d0daa2fcb0e9 tests/usr.bin/xlint/lint1/msg_070.exp
--- a/tests/usr.bin/xlint/lint1/msg_070.exp     Fri Apr 08 20:11:31 2022 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-msg_070.c(6): error: syntax error ':' [249]
diff -r 71a77dc221bb -r d0daa2fcb0e9 usr.bin/xlint/lint1/err.c
--- a/usr.bin/xlint/lint1/err.c Fri Apr 08 20:11:31 2022 +0000
+++ b/usr.bin/xlint/lint1/err.c Fri Apr 08 21:29:29 2022 +0000



Home | Main Index | Thread Index | Old Index