diff options
| author | rillig <rillig@NetBSD.org> | 2021-12-17 10:51:45 +0000 |
|---|---|---|
| committer | rillig <rillig@NetBSD.org> | 2021-12-17 10:51:45 +0000 |
| commit | b9c85f0a2ec3e2bdf2f4f4a582ef2db4e7cf9e6b (patch) | |
| tree | 723d95e53c108f93928ba215181afbbc5f5d7471 /tests | |
| parent | 14bba30deb0418a07d343502e64397ecfdc66bc6 (diff) | |
tests/lint: demonstrate another initialization with few braces
Seen in Postfix, smtp_proto.c.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/usr.bin/xlint/lint1/init.c | 22 | ||||
| -rw-r--r-- | tests/usr.bin/xlint/lint1/init.exp | 3 |
2 files changed, 24 insertions, 1 deletions
diff --git a/tests/usr.bin/xlint/lint1/init.c b/tests/usr.bin/xlint/lint1/init.c index c3968c55e53..7b20b53d30e 100644 --- a/tests/usr.bin/xlint/lint1/init.c +++ b/tests/usr.bin/xlint/lint1/init.c @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.5 2021/12/17 10:33:23 rillig Exp $ */ +/* $NetBSD: init.c,v 1.6 2021/12/17 10:51:45 rillig Exp $ */ # 3 "init.c" /* @@ -55,3 +55,23 @@ struct { } points[] = { 0, 0, 3, 0, 0, 4, 3, 4 }; + + +/* + * Initialization with fewer braces than usual, must still be accepted. + * + * TODO: Properly handle this situation; as of init.c 1.214 from 2021-12-17, + * the below initialization sets in->in_err but shouldn't. + */ +void do_nothing(void); + +struct { + void (*action_1) (void); + void (*action_2) (void); +} actions[1] = { + /* expect+1: error: cannot initialize 'struct <unnamed>' from 'pointer to function(void) returning void' [185] */ + do_nothing, + /* expect+2: error: too many array initializers, expected 1 [173] */ + /* expect+1: error: cannot initialize 'struct <unnamed>' from 'pointer to function(void) returning void' [185] */ + do_nothing, +}; diff --git a/tests/usr.bin/xlint/lint1/init.exp b/tests/usr.bin/xlint/lint1/init.exp index 0abd8b77ef9..acf801980a9 100644 --- a/tests/usr.bin/xlint/lint1/init.exp +++ b/tests/usr.bin/xlint/lint1/init.exp @@ -1 +1,4 @@ init.c(16): error: empty array declaration: empty_array_with_initializer [190] +init.c(73): error: cannot initialize 'struct <unnamed>' from 'pointer to function(void) returning void' [185] +init.c(76): error: too many array initializers, expected 1 [173] +init.c(76): error: cannot initialize 'struct <unnamed>' from 'pointer to function(void) returning void' [185] |
