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 tests/lint: demonstrate another in...



details:   https://anonhg.NetBSD.org/src/rev/a5181c80aa44
branches:  trunk
changeset: 1027725:a5181c80aa44
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Dec 17 10:51:45 2021 +0000

description:
tests/lint: demonstrate another initialization with few braces

Seen in Postfix, smtp_proto.c.

diffstat:

 tests/usr.bin/xlint/lint1/init.c   |  22 +++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/init.exp |   3 +++
 2 files changed, 24 insertions(+), 1 deletions(-)

diffs (41 lines):

diff -r 63342a0b8f33 -r a5181c80aa44 tests/usr.bin/xlint/lint1/init.c
--- a/tests/usr.bin/xlint/lint1/init.c  Fri Dec 17 10:33:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/init.c  Fri Dec 17 10:51:45 2021 +0000
@@ -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 @@
 } 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 -r 63342a0b8f33 -r a5181c80aa44 tests/usr.bin/xlint/lint1/init.exp
--- a/tests/usr.bin/xlint/lint1/init.exp        Fri Dec 17 10:33:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/init.exp        Fri Dec 17 10:51:45 2021 +0000
@@ -1,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]



Home | Main Index | Thread Index | Old Index