Sat Feb 20 22:31:20 2021 UTC ()
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.


(rillig)
diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/d_c99_anon_union.c
diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/d_c99_nested_struct.c
diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/d_c99_struct_init.c
diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/d_c99_union_init1.c
diff -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/d_c99_recursive_init.c
diff -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/d_c99_union_init3.c
diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/d_c9x_array_init.c
diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/d_c9x_recursive_init.c

cvs diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/d_c99_anon_union.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/d_c99_anon_union.c 2021/01/31 14:57:28 1.3
+++ src/tests/usr.bin/xlint/lint1/d_c99_anon_union.c 2021/02/20 22:31:20 1.4
@@ -1,19 +1,21 @@ @@ -1,19 +1,21 @@
1/* $NetBSD: d_c99_anon_union.c,v 1.3 2021/01/31 14:57:28 rillig Exp $ */ 1/* $NetBSD: d_c99_anon_union.c,v 1.4 2021/02/20 22:31:20 rillig Exp $ */
2# 3 "d_c99_anon_union.c" 2# 3 "d_c99_anon_union.c"
3 3
4/* struct with only anonymous members */ 4/* struct with only anonymous members */
5 5
6struct foo { 6struct foo {
7 union { 7 union {
8 long loo; 8 long loo;
9 double doo; 9 double doo;
10 }; 10 };
11}; 11};
12 12
 13int printf(const char *, ...);
 14
13int 15int
14main(void) 16main(void)
15{ 17{
16 struct foo *f = 0; 18 struct foo *f = 0;
17 printf("%p\n", &f[1]); 19 printf("%p\n", &f[1]);
18 return 0; 20 return 0;
19} 21}

cvs diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/d_c99_nested_struct.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/d_c99_nested_struct.c 2021/01/31 14:57:28 1.3
+++ src/tests/usr.bin/xlint/lint1/d_c99_nested_struct.c 2021/02/20 22:31:20 1.4
@@ -1,27 +1,36 @@ @@ -1,27 +1,36 @@
1/* $NetBSD: d_c99_nested_struct.c,v 1.3 2021/01/31 14:57:28 rillig Exp $ */ 1/* $NetBSD: d_c99_nested_struct.c,v 1.4 2021/02/20 22:31:20 rillig Exp $ */
2# 3 "d_c99_nested_struct.c" 2# 3 "d_c99_nested_struct.c"
3 3
4/* C99 nested struct init with named and non-named initializers */ 4/* C99 nested struct init with named and non-named initializers */
5typedef struct pthread_mutex_t { 5typedef struct pthread_mutex_t {
6 unsigned int ptm_magic; 6 unsigned int ptm_magic;
7 char ptm_errorcheck; 7 char ptm_errorcheck;
8 8
9 char ptm_pad1[3]; 9 char ptm_pad1[3];
10 10
11 char ptm_interlock; 11 char ptm_interlock;
12 12
13 char ptm_pad2[3]; 13 char ptm_pad2[3];
14 14
15 volatile void *ptm_owner; 15 volatile void *ptm_owner;
16 void *volatile ptm_waiters; 16 void *volatile ptm_waiters;
17 unsigned int ptm_recursed; 17 unsigned int ptm_recursed;
18 void *ptm_spare2; 18 void *ptm_spare2;
19} pthread_mutex_t; 19} pthread_mutex_t;
20 20
21 21
22struct arc4random_global { 22struct arc4random_global {
23 pthread_mutex_t lock; 23 pthread_mutex_t lock;
24} arc4random_global = { 24} arc4random_global = {
25 .lock = { 0x33330003, 0, { 0, 0, 0 }, 0, { 0, 0, 0 }, ((void *)0), 25 .lock = {
26 ((void *)0), 0, ((void *)0) }, 26 0x33330003,
 27 0,
 28 { 0, 0, 0 },
 29 0,
 30 { 0, 0, 0 },
 31 ((void *)0),
 32 ((void *)0),
 33 0,
 34 ((void *)0)
 35 },
27}; 36};

cvs diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/d_c99_struct_init.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/d_c99_struct_init.c 2021/01/31 14:39:31 1.3
+++ src/tests/usr.bin/xlint/lint1/d_c99_struct_init.c 2021/02/20 22:31:20 1.4
@@ -1,13 +1,23 @@ @@ -1,13 +1,23 @@
1/* $NetBSD: d_c99_struct_init.c,v 1.3 2021/01/31 14:39:31 rillig Exp $ */ 1/* $NetBSD: d_c99_struct_init.c,v 1.4 2021/02/20 22:31:20 rillig Exp $ */
2# 3 "d_c99_struct_init.c" 2# 3 "d_c99_struct_init.c"
3 3
4/* C99 struct initialization */ 4/* C99 struct initialization */
5struct { 5struct {
6 int i; 6 int i;
7 char *s; 7 char *s;
8} c[] = { 8} c[] = {
9 { .i = 2, }, 9 {
10 { .s = "foo" }, 10 .i = 2,
11 { .i = 1, .s = "bar" }, 11 },
12 { .s = "foo", .i = -1 }, 12 {
 13 .s = "foo"
 14 },
 15 {
 16 .i = 1,
 17 .s = "bar"
 18 },
 19 {
 20 .s = "foo",
 21 .i = -1
 22 },
13}; 23};

cvs diff -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/d_c99_union_init1.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/d_c99_union_init1.c 2021/01/31 14:39:31 1.3
+++ src/tests/usr.bin/xlint/lint1/d_c99_union_init1.c 2021/02/20 22:31:20 1.4
@@ -1,11 +1,13 @@ @@ -1,11 +1,13 @@
1/* $NetBSD: d_c99_union_init1.c,v 1.3 2021/01/31 14:39:31 rillig Exp $ */ 1/* $NetBSD: d_c99_union_init1.c,v 1.4 2021/02/20 22:31:20 rillig Exp $ */
2# 3 "d_c99_union_init1.c" 2# 3 "d_c99_union_init1.c"
3 3
4/* C99 union initialization */ 4/* GCC-style and C99-style union initialization */
5union { 5union {
6 int i; 6 int i;
7 char *s; 7 char *s;
8} c[] = { 8} c[] = {
9 { i: 1 }, 9 { i: 1 }, /* GCC-style */
10 { s: "foo" } 10 { s: "foo" }, /* GCC-style */
 11 { .i = 1 }, /* C99-style */
 12 { .s = "foo" } /* C99-style */
11}; 13};

cvs diff -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/Attic/d_c99_recursive_init.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/d_c99_recursive_init.c 2021/01/31 14:57:28 1.4
+++ src/tests/usr.bin/xlint/lint1/Attic/d_c99_recursive_init.c 2021/02/20 22:31:20 1.5
@@ -1,16 +1,28 @@ @@ -1,16 +1,28 @@
1/* $NetBSD: d_c99_recursive_init.c,v 1.4 2021/01/31 14:57:28 rillig Exp $ */ 1/* $NetBSD: d_c99_recursive_init.c,v 1.5 2021/02/20 22:31:20 rillig Exp $ */
2# 3 "d_c99_recursive_init.c" 2# 3 "d_c99_recursive_init.c"
3 3
4/* C99 recursive struct/union initialization */ 4/* C99 recursive struct/union initialization */
5struct top { 5struct top {
6 int i; 6 int i;
7 char c; 7 char c;
8 union onion { 8 union onion {
9 short us; 9 short us;
10 char uc; 10 char uc;
11 } u; 11 } u;
12 char *s; 12 char *s;
13} c[] = { 13} c[] = {
14 { .s = "foo", .c = 'b', .u = { .uc = 'c' }}, 14 {
15 { .i = 1, .c = 'a', .u = { .us = 2 }}, 15 .s = "foo",
 16 .c = 'b',
 17 .u = {
 18 .uc = 'c'
 19 }
 20 },
 21 {
 22 .i = 1,
 23 .c = 'a',
 24 .u = {
 25 .us = 2
 26 }
 27 },
16}; 28};

cvs diff -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/d_c99_union_init3.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/d_c99_union_init3.c 2021/01/31 14:57:28 1.4
+++ src/tests/usr.bin/xlint/lint1/d_c99_union_init3.c 2021/02/20 22:31:20 1.5
@@ -1,10 +1,13 @@ @@ -1,10 +1,13 @@
1/* $NetBSD: d_c99_union_init3.c,v 1.4 2021/01/31 14:57:28 rillig Exp $ */ 1/* $NetBSD: d_c99_union_init3.c,v 1.5 2021/02/20 22:31:20 rillig Exp $ */
2# 3 "d_c99_union_init3.c" 2# 3 "d_c99_union_init3.c"
3 3
4/* C99 union initialization */ 4/* C99 struct initialization */
5struct { 5struct {
6 int i[10]; 6 int i[10];
7 char *s; 7 char *s;
8} c[] = { 8} c[] = {
9 {{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, "foo" }, 9 {
 10 { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 },
 11 "foo"
 12 },
10}; 13};

cvs diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/d_c9x_array_init.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/d_c9x_array_init.c 2021/01/31 14:39:31 1.2
+++ src/tests/usr.bin/xlint/lint1/d_c9x_array_init.c 2021/02/20 22:31:20 1.3
@@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
1/* $NetBSD: d_c9x_array_init.c,v 1.2 2021/01/31 14:39:31 rillig Exp $ */ 1/* $NetBSD: d_c9x_array_init.c,v 1.3 2021/02/20 22:31:20 rillig Exp $ */
2# 3 "d_c9x_array_init.c" 2# 3 "d_c9x_array_init.c"
3 3
4/* C9X array initializers */ 4/* GCC-specific array range initializers */
5int foo[256] = { 5int foo[256] = {
6 [2] = 1, 6 [2] = 1,
7 [3] = 2, 7 [3] = 2,
8 [4 ... 5] = 3 8 [4 ... 5] = 3
9}; 9};

cvs diff -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/Attic/d_c9x_recursive_init.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/d_c9x_recursive_init.c 2021/01/31 14:39:31 1.2
+++ src/tests/usr.bin/xlint/lint1/Attic/d_c9x_recursive_init.c 2021/02/20 22:31:20 1.3
@@ -1,19 +1,21 @@ @@ -1,19 +1,21 @@
1/* $NetBSD: d_c9x_recursive_init.c,v 1.2 2021/01/31 14:39:31 rillig Exp $ */ 1/* $NetBSD: d_c9x_recursive_init.c,v 1.3 2021/02/20 22:31:20 rillig Exp $ */
2# 3 "d_c9x_recursive_init.c" 2# 3 "d_c9x_recursive_init.c"
3 3
4/* C9X struct/union member init, with nested union and trailing member */ 4/* C9X struct/union member init, with nested union and trailing member */
5union node { 5union node {
6 void *next; 6 void *next;
7 char *data; 7 char *data;
8}; 8};
9struct foo { 9struct foo {
10 int b; 10 int b;
11 union node n; 11 union node n;
12 int c; 12 int c;
13}; 13};
14 14
15struct foo f = { 15struct foo f = {
16 .b = 1, 16 .b = 1,
17 .n = { .next = 0, }, 17 .n = {
 18 .next = 0,
 19 },
18 .c = 1 20 .c = 1
19}; 21};