Source-Changes-HG archive

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

[src/trunk]: src/tests/usr.bin/xlint/lint1 lint: clean up some of the C99 tests



details:   https://anonhg.NetBSD.org/src/rev/585fb49f10d9
branches:  trunk
changeset: 1018897:585fb49f10d9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Feb 20 22:31:20 2021 +0000

description:
lint: clean up some of the C99 tests

Several C99 tests do not actually test C99 features but instead GCC
features.  All these tests should be double-checked again.

In some other tests, split the initializers into more lines, which makes
it easier to read the debug log corresponding to these tests.  This will
be necessary for reworking the initializer code to actually conform to
C99.

diffstat:

 tests/usr.bin/xlint/lint1/d_c99_anon_union.c     |   4 +++-
 tests/usr.bin/xlint/lint1/d_c99_nested_struct.c  |  15 ++++++++++++---
 tests/usr.bin/xlint/lint1/d_c99_recursive_init.c |  18 +++++++++++++++---
 tests/usr.bin/xlint/lint1/d_c99_struct_init.c    |  20 +++++++++++++++-----
 tests/usr.bin/xlint/lint1/d_c99_union_init1.c    |  10 ++++++----
 tests/usr.bin/xlint/lint1/d_c99_union_init3.c    |   9 ++++++---
 tests/usr.bin/xlint/lint1/d_c9x_array_init.c     |   4 ++--
 tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c |   6 ++++--
 8 files changed, 63 insertions(+), 23 deletions(-)

diffs (180 lines):

diff -r ae5fc23695e1 -r 585fb49f10d9 tests/usr.bin/xlint/lint1/d_c99_anon_union.c
--- a/tests/usr.bin/xlint/lint1/d_c99_anon_union.c      Sat Feb 20 22:18:32 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_anon_union.c      Sat Feb 20 22:31:20 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_anon_union.c,v 1.3 2021/01/31 14:57:28 rillig Exp $      */
+/*     $NetBSD: d_c99_anon_union.c,v 1.4 2021/02/20 22:31:20 rillig Exp $      */
 # 3 "d_c99_anon_union.c"
 
 /* struct with only anonymous members */
@@ -10,6 +10,8 @@
        };
 };
 
+int printf(const char *, ...);
+
 int
 main(void)
 {
diff -r ae5fc23695e1 -r 585fb49f10d9 tests/usr.bin/xlint/lint1/d_c99_nested_struct.c
--- a/tests/usr.bin/xlint/lint1/d_c99_nested_struct.c   Sat Feb 20 22:18:32 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_nested_struct.c   Sat Feb 20 22:31:20 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_nested_struct.c,v 1.3 2021/01/31 14:57:28 rillig Exp $   */
+/*     $NetBSD: d_c99_nested_struct.c,v 1.4 2021/02/20 22:31:20 rillig Exp $   */
 # 3 "d_c99_nested_struct.c"
 
 /* C99 nested struct init with named and non-named initializers */
@@ -22,6 +22,15 @@
 struct arc4random_global {
        pthread_mutex_t lock;
 } arc4random_global = {
-       .lock = { 0x33330003, 0, { 0, 0, 0 }, 0, { 0, 0, 0 }, ((void *)0),
-                 ((void *)0), 0, ((void *)0) },
+       .lock = {
+               0x33330003,
+               0,
+               { 0, 0, 0 },
+               0,
+               { 0, 0, 0 },
+               ((void *)0),
+               ((void *)0),
+               0,
+               ((void *)0)
+       },
 };
diff -r ae5fc23695e1 -r 585fb49f10d9 tests/usr.bin/xlint/lint1/d_c99_recursive_init.c
--- a/tests/usr.bin/xlint/lint1/d_c99_recursive_init.c  Sat Feb 20 22:18:32 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_recursive_init.c  Sat Feb 20 22:31:20 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_recursive_init.c,v 1.4 2021/01/31 14:57:28 rillig Exp $  */
+/*     $NetBSD: d_c99_recursive_init.c,v 1.5 2021/02/20 22:31:20 rillig Exp $  */
 # 3 "d_c99_recursive_init.c"
 
 /* C99 recursive struct/union initialization */
@@ -11,6 +11,18 @@
        } u;
        char *s;
 } c[] = {
-       { .s = "foo", .c = 'b', .u = { .uc = 'c' }},
-       { .i = 1, .c = 'a', .u = { .us = 2 }},
+       {
+               .s = "foo",
+               .c = 'b',
+               .u = {
+                       .uc = 'c'
+               }
+       },
+       {
+               .i = 1,
+               .c = 'a',
+               .u = {
+                       .us = 2
+               }
+       },
 };
diff -r ae5fc23695e1 -r 585fb49f10d9 tests/usr.bin/xlint/lint1/d_c99_struct_init.c
--- a/tests/usr.bin/xlint/lint1/d_c99_struct_init.c     Sat Feb 20 22:18:32 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_struct_init.c     Sat Feb 20 22:31:20 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_struct_init.c,v 1.3 2021/01/31 14:39:31 rillig Exp $     */
+/*     $NetBSD: d_c99_struct_init.c,v 1.4 2021/02/20 22:31:20 rillig Exp $     */
 # 3 "d_c99_struct_init.c"
 
 /* C99 struct initialization */
@@ -6,8 +6,18 @@
        int i;
        char *s;
 } c[] = {
-       { .i =  2, },
-       { .s =  "foo" },
-       { .i =  1, .s = "bar" },
-       { .s =  "foo", .i = -1 },
+       {
+               .i =  2,
+       },
+       {
+               .s =  "foo"
+       },
+       {
+               .i =  1,
+               .s = "bar"
+       },
+       {
+               .s =  "foo",
+               .i = -1
+       },
 };
diff -r ae5fc23695e1 -r 585fb49f10d9 tests/usr.bin/xlint/lint1/d_c99_union_init1.c
--- a/tests/usr.bin/xlint/lint1/d_c99_union_init1.c     Sat Feb 20 22:18:32 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_union_init1.c     Sat Feb 20 22:31:20 2021 +0000
@@ -1,11 +1,13 @@
-/*     $NetBSD: d_c99_union_init1.c,v 1.3 2021/01/31 14:39:31 rillig Exp $     */
+/*     $NetBSD: d_c99_union_init1.c,v 1.4 2021/02/20 22:31:20 rillig Exp $     */
 # 3 "d_c99_union_init1.c"
 
-/* C99 union initialization */
+/* GCC-style and C99-style union initialization */
 union {
        int i;
        char *s;
 } c[] = {
-       { i: 1 },
-       { s: "foo" }
+       { i: 1 },               /* GCC-style */
+       { s: "foo" },           /* GCC-style */
+       { .i = 1 },             /* C99-style */
+       { .s = "foo" }          /* C99-style */
 };
diff -r ae5fc23695e1 -r 585fb49f10d9 tests/usr.bin/xlint/lint1/d_c99_union_init3.c
--- a/tests/usr.bin/xlint/lint1/d_c99_union_init3.c     Sat Feb 20 22:18:32 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_union_init3.c     Sat Feb 20 22:31:20 2021 +0000
@@ -1,10 +1,13 @@
-/*     $NetBSD: d_c99_union_init3.c,v 1.4 2021/01/31 14:57:28 rillig Exp $     */
+/*     $NetBSD: d_c99_union_init3.c,v 1.5 2021/02/20 22:31:20 rillig Exp $     */
 # 3 "d_c99_union_init3.c"
 
-/* C99 union initialization */
+/* C99 struct initialization */
 struct {
        int i[10];
        char *s;
 } c[] = {
-       {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, "foo" },
+       {
+               { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
+               "foo"
+       },
 };
diff -r ae5fc23695e1 -r 585fb49f10d9 tests/usr.bin/xlint/lint1/d_c9x_array_init.c
--- a/tests/usr.bin/xlint/lint1/d_c9x_array_init.c      Sat Feb 20 22:18:32 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c9x_array_init.c      Sat Feb 20 22:31:20 2021 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: d_c9x_array_init.c,v 1.2 2021/01/31 14:39:31 rillig Exp $      */
+/*     $NetBSD: d_c9x_array_init.c,v 1.3 2021/02/20 22:31:20 rillig Exp $      */
 # 3 "d_c9x_array_init.c"
 
-/* C9X array initializers */
+/* GCC-specific array range initializers */
 int foo[256] = {
        [2] = 1,
        [3] = 2,
diff -r ae5fc23695e1 -r 585fb49f10d9 tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c
--- a/tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c  Sat Feb 20 22:18:32 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c  Sat Feb 20 22:31:20 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c9x_recursive_init.c,v 1.2 2021/01/31 14:39:31 rillig Exp $  */
+/*     $NetBSD: d_c9x_recursive_init.c,v 1.3 2021/02/20 22:31:20 rillig Exp $  */
 # 3 "d_c9x_recursive_init.c"
 
 /* C9X struct/union member init, with nested union and trailing member */
@@ -14,6 +14,8 @@
 
 struct foo f = {
        .b = 1,
-       .n = { .next = 0, },
+       .n = {
+           .next = 0,
+       },
        .c = 1
 };



Home | Main Index | Thread Index | Old Index