Module Name: src Committed By: rillig Date: Fri Dec 17 10:51:45 UTC 2021
Modified Files: src/tests/usr.bin/xlint/lint1: init.c init.exp Log Message: tests/lint: demonstrate another initialization with few braces Seen in Postfix, smtp_proto.c. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/init.c \ src/tests/usr.bin/xlint/lint1/init.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/tests/usr.bin/xlint/lint1/init.c diff -u src/tests/usr.bin/xlint/lint1/init.c:1.5 src/tests/usr.bin/xlint/lint1/init.c:1.6 --- src/tests/usr.bin/xlint/lint1/init.c:1.5 Fri Dec 17 10:33:23 2021 +++ src/tests/usr.bin/xlint/lint1/init.c Fri Dec 17 10:51:45 2021 @@ -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, +}; Index: src/tests/usr.bin/xlint/lint1/init.exp diff -u src/tests/usr.bin/xlint/lint1/init.exp:1.5 src/tests/usr.bin/xlint/lint1/init.exp:1.6 --- src/tests/usr.bin/xlint/lint1/init.exp:1.5 Fri Dec 17 10:33:23 2021 +++ src/tests/usr.bin/xlint/lint1/init.exp Fri Dec 17 10:51:45 2021 @@ -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]