Source-Changes-HG archive

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

[src/trunk]: src tests/lint: remove redundant tests



details:   https://anonhg.NetBSD.org/src/rev/07a907e2e845
branches:  trunk
changeset: 373359:07a907e2e845
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 05 12:25:11 2023 +0000

description:
tests/lint: remove redundant tests

The names of the tests were misleading: 'recursive' should have been
'nested', and the interesting topic in the 'cast' tests was not the cast
but the pointer dereference.

diffstat:

 distrib/sets/lists/tests/mi                      |  12 +++---
 tests/usr.bin/xlint/lint1/Makefile               |   7 +---
 tests/usr.bin/xlint/lint1/c99_init_array.c       |  19 ----------
 tests/usr.bin/xlint/lint1/c99_init_designator.c  |  29 ----------------
 tests/usr.bin/xlint/lint1/d_c99_init.c           |  43 +++++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c |  21 -----------
 tests/usr.bin/xlint/lint1/d_cast_init.c          |  19 ----------
 tests/usr.bin/xlint/lint1/d_cast_init2.c         |  11 ------
 tests/usr.bin/xlint/lint1/lex_integer_ilp32.c    |   6 ++-
 9 files changed, 54 insertions(+), 113 deletions(-)

diffs (257 lines):

diff -r 4647360ac1ad -r 07a907e2e845 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Feb 05 10:57:48 2023 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Feb 05 12:25:11 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1250 2023/01/30 19:51:33 christos Exp $
+# $NetBSD: mi,v 1.1251 2023/02/05 12:25:11 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6424,9 +6424,9 @@
 ./usr/tests/usr.bin/xlint/lint1/c99_atomic.c                   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.exp tests-obsolete          obsolete
-./usr/tests/usr.bin/xlint/lint1/c99_init_array.c               tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/c99_init_array.c               tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/xlint/lint1/c99_init_array.exp             tests-obsolete          obsolete,atf
-./usr/tests/usr.bin/xlint/lint1/c99_init_designator.c          tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/c99_init_designator.c          tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/xlint/lint1/c99_init_designator.exp                tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/xlint/lint1/check-expect.lua               tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_alignof.c                    tests-usr.bin-tests     compattestfile,atf
@@ -6463,10 +6463,10 @@
 ./usr/tests/usr.bin/xlint/lint1/d_c99_union_init4.c            tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_c99_union_init5.c            tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_c9x_array_init.c             tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c         tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c         tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/xlint/lint1/d_cast_fun_array_param.c       tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/xlint/lint1/d_cast_init.c                  tests-usr.bin-tests     compattestfile,atf
-./usr/tests/usr.bin/xlint/lint1/d_cast_init2.c                 tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/d_cast_init.c                  tests-obsolete          obsolete,atf
+./usr/tests/usr.bin/xlint/lint1/d_cast_init2.c                 tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/xlint/lint1/d_cast_lhs.c                   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/d_cast_lhs.exp                 tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/xlint/lint1/d_cast_typeof.c                        tests-usr.bin-tests     compattestfile,atf
diff -r 4647360ac1ad -r 07a907e2e845 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Sun Feb 05 10:57:48 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Sun Feb 05 12:25:11 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.135 2023/01/29 17:02:09 rillig Exp $
+# $NetBSD: Makefile,v 1.136 2023/02/05 12:25:11 rillig Exp $
 
 NOMAN=         # defined
 MAX_MESSAGE=   350             # see lint1/err.c
@@ -23,8 +23,6 @@
 FILES+=                c90.c
 FILES+=                c99_atomic.c
 FILES+=                c99_bool_strict_suppressed.c
-FILES+=                c99_init_array.c
-FILES+=                c99_init_designator.c
 FILES+=                d_alignof.c
 FILES+=                d_bltinoffsetof.c
 FILES+=                d_c99_anon_struct.c
@@ -50,10 +48,7 @@
 FILES+=                d_c99_union_init4.c
 FILES+=                d_c99_union_init5.c
 FILES+=                d_c9x_array_init.c
-FILES+=                d_c9x_recursive_init.c
 FILES+=                d_cast_fun_array_param.c
-FILES+=                d_cast_init.c
-FILES+=                d_cast_init2.c
 FILES+=                d_cast_lhs.c
 FILES+=                d_cast_typeof.c
 FILES+=                d_compound_literals1.c
diff -r 4647360ac1ad -r 07a907e2e845 tests/usr.bin/xlint/lint1/c99_init_array.c
--- a/tests/usr.bin/xlint/lint1/c99_init_array.c        Sun Feb 05 10:57:48 2023 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/*     $NetBSD: c99_init_array.c,v 1.3 2021/07/02 23:29:54 rillig Exp $        */
-# 3 "c99_init_array.c"
-
-/*
- * Test C99-style initialization of arrays.
- */
-
-/* lint1-extra-flags: -p */
-
-// The size of the array is determined by the maximum index, not by the last
-// one mentioned.
-int arr_11[] = { [10] = 10, [0] = 0 };
-typedef int ctassert_11[-(int)(sizeof(arr_11) / sizeof(arr_11[0]))];
-/* expect-1: error: negative array dimension (-11) [20] */
-
-// Without an explicit subscript designator, the subscript counts up.
-int arr_3[] = { [1] = 1, [0] = 0, 1, 2 };
-typedef int ctassert_3[-(int)(sizeof(arr_3) / sizeof(arr_3[0]))];
-/* expect-1: error: negative array dimension (-3) [20] */
diff -r 4647360ac1ad -r 07a907e2e845 tests/usr.bin/xlint/lint1/c99_init_designator.c
--- a/tests/usr.bin/xlint/lint1/c99_init_designator.c   Sun Feb 05 10:57:48 2023 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*     $NetBSD: c99_init_designator.c,v 1.2 2022/01/15 14:22:03 rillig Exp $   */
-# 3 "c99_init_designator.c"
-
-/*
- * Test initialization of structs or unions using designators.
- *
- * See init.c, 'struct designator' and 'struct designation'.
- *
- * C99 6.7.8p6, 6.7.8p7
- */
-
-struct point {
-       int x;
-       int y;
-};
-
-/*
- * Before cgram.y 1.230 from 2021-06-20, the grammar allowed either of the
- * operators '.' or '->' to be used for the designators and had extra code
- * to ensure that only '.' was actually used.
- */
-struct point origin = {
-    .x = 0,
-    /* expect+1: error: syntax error '->' [249] */
-    ->y = 0,
-};
-
-/* Ensure that the parser can recover from the parse error. */
-struct point pythagoras = { 3, 4 };
diff -r 4647360ac1ad -r 07a907e2e845 tests/usr.bin/xlint/lint1/d_c99_init.c
--- a/tests/usr.bin/xlint/lint1/d_c99_init.c    Sun Feb 05 10:57:48 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.c    Sun Feb 05 12:25:11 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_init.c,v 1.42 2022/06/22 19:23:18 rillig Exp $   */
+/*     $NetBSD: d_c99_init.c,v 1.43 2023/02/05 12:25:11 rillig Exp $   */
 # 3 "d_c99_init.c"
 
 /*
@@ -491,3 +491,44 @@
 const char string_initialized_with_braced_literal[] = {
        "initializer",
 };
+
+/* nested struct/union initialization */
+struct outer {
+       int i;
+       char c;
+       union inner {
+               short us;
+               char uc;
+       } u;
+       char *s;
+} struct_containing_union[] = {
+       {
+               .s = "foo",
+               .c = 'b',
+               .u = {
+                       .uc = 'c'
+               }
+       },
+       {
+               .i = 1,
+               .c = 'a',
+               .u = {
+                       .us = 2
+               }
+       },
+};
+
+/*
+ * The expansion of the offsetof macro may dereference a null pointer.
+ * Such expressions are allowed in initializers for objects with
+ * static duration.
+ */
+struct offset_and_data {
+       unsigned long offset;
+       unsigned long data;
+};
+
+struct offset_and_data offset_and_data = {
+       (unsigned long)&(((struct offset_and_data *)0)->data),
+       0,
+};
diff -r 4647360ac1ad -r 07a907e2e845 tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c
--- a/tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c  Sun Feb 05 10:57:48 2023 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-/*     $NetBSD: d_c9x_recursive_init.c,v 1.4 2022/02/27 11:40:30 rillig Exp $  */
-# 3 "d_c9x_recursive_init.c"
-
-/* C99 struct/union member init, with nested union and trailing member */
-union node {
-       void *next;
-       char *data;
-};
-struct foo {
-       int b;
-       union node n;
-       int c;
-};
-
-struct foo f = {
-       .b = 1,
-       .n = {
-           .next = 0,
-       },
-       .c = 1
-};
diff -r 4647360ac1ad -r 07a907e2e845 tests/usr.bin/xlint/lint1/d_cast_init.c
--- a/tests/usr.bin/xlint/lint1/d_cast_init.c   Sun Feb 05 10:57:48 2023 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,19 +0,0 @@
-/*     $NetBSD: d_cast_init.c,v 1.5 2021/07/03 19:34:47 rillig Exp $   */
-# 3 "d_cast_init.c"
-
-/* cast initialization */
-
-typedef unsigned char u_char;
-
-struct sockaddr_x25 {
-       u_char x25_len;
-       u_char x25_family;
-       signed char x25_udata[4];
-};
-
-struct sockaddr_x25 x25_dgmask = {
-    (unsigned char)(unsigned char)(unsigned int)(unsigned long)
-       (&(((struct sockaddr_x25 *)0)->x25_udata[1])),
-    0,
-    { -1, -1, -1, -1 },
-};
diff -r 4647360ac1ad -r 07a907e2e845 tests/usr.bin/xlint/lint1/d_cast_init2.c
--- a/tests/usr.bin/xlint/lint1/d_cast_init2.c  Sun Feb 05 10:57:48 2023 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-/*     $NetBSD: d_cast_init2.c,v 1.3 2021/01/31 14:57:28 rillig Exp $  */
-# 3 "d_cast_init2.c"
-
-/* cast initialization as the rhs of a - operand */
-struct sockaddr_dl {
-       char sdl_data[2];
-};
-
-int npdl_datasize = sizeof(struct sockaddr_dl) -
-                   ((int)((unsigned long)
-                       &((struct sockaddr_dl *)0)->sdl_data[0]));
diff -r 4647360ac1ad -r 07a907e2e845 tests/usr.bin/xlint/lint1/lex_integer_ilp32.c
--- a/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c     Sun Feb 05 10:57:48 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/lex_integer_ilp32.c     Sun Feb 05 12:25:11 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lex_integer_ilp32.c,v 1.5 2022/06/22 19:23:18 rillig Exp $     */
+/*     $NetBSD: lex_integer_ilp32.c,v 1.6 2023/02/05 12:25:11 rillig Exp $     */
 # 3 "lex_integer_ilp32.c"
 
 /*
@@ -37,6 +37,10 @@
 {
        sinku(0);
 
+       sinku(2147483647);
+       sinku(2147483648);
+
+       sinku(2147483648U);
        sinku(4294967295U);
 
        /* expect+1: warning: integer constant out of range [252] */



Home | Main Index | Thread Index | Old Index