Module Name: src
Committed By: rillig
Date: Fri Dec 17 11:06:16 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: init.c init.exp
src/usr.bin/xlint/lint1: init.c
Log Message:
lint: fix initialization with few braces from function
Seen in Postfix, smtp_proto.c.
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/xlint/lint1/init.c \
src/tests/usr.bin/xlint/lint1/init.exp
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/xlint/lint1/init.c
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.6 src/tests/usr.bin/xlint/lint1/init.c:1.7
--- src/tests/usr.bin/xlint/lint1/init.c:1.6 Fri Dec 17 10:51:45 2021
+++ src/tests/usr.bin/xlint/lint1/init.c Fri Dec 17 11:06:15 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.6 2021/12/17 10:51:45 rillig Exp $ */
+/* $NetBSD: init.c,v 1.7 2021/12/17 11:06:15 rillig Exp $ */
# 3 "init.c"
/*
@@ -35,7 +35,7 @@ typedef struct {
*
* Seen in external/ibm-public/postfix/dist/src/util/dict.c(624).
*
- * TODO: Properly handle this situation; as of init.c 1.214 from 2021-12-17,
+ * TODO: Properly handle this situation; as of init.c 1.215 from 2021-12-17,
* the below initialization sets in->in_err but shouldn't.
*/
const histogram_entry hgr[] = {
@@ -47,7 +47,7 @@ const histogram_entry hgr[] = {
/*
* 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,
+ * TODO: Properly handle this situation; as of init.c 1.215 from 2021-12-17,
* the below initialization sets in->in_err but shouldn't.
*/
struct {
@@ -60,7 +60,7 @@ struct {
/*
* 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,
+ * TODO: Properly handle this situation; as of init.c 1.215 from 2021-12-17,
* the below initialization sets in->in_err but shouldn't.
*/
void do_nothing(void);
@@ -69,9 +69,6 @@ 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.6 src/tests/usr.bin/xlint/lint1/init.exp:1.7
--- src/tests/usr.bin/xlint/lint1/init.exp:1.6 Fri Dec 17 10:51:45 2021
+++ src/tests/usr.bin/xlint/lint1/init.exp Fri Dec 17 11:06:15 2021
@@ -1,4 +1 @@
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]
Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.214 src/usr.bin/xlint/lint1/init.c:1.215
--- src/usr.bin/xlint/lint1/init.c:1.214 Fri Dec 17 10:33:23 2021
+++ src/usr.bin/xlint/lint1/init.c Fri Dec 17 11:06:15 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: init.c,v 1.214 2021/12/17 10:33:23 rillig Exp $ */
+/* $NetBSD: init.c,v 1.215 2021/12/17 11:06:15 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.214 2021/12/17 10:33:23 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.215 2021/12/17 11:06:15 rillig Exp $");
#endif
#include <stdlib.h>
@@ -936,7 +936,8 @@ initialization_expr(struct initializatio
* in repeating the same check in lint. If needed, support for these
* edge cases could be added, but that would increase the complexity.
*/
- if (is_scalar(tn->tn_type->t_tspec) &&
+ if ((is_scalar(tn->tn_type->t_tspec) ||
+ tn->tn_type->t_tspec == FUNC) &&
(tp->t_tspec == ARRAY || is_struct_or_union(tp->t_tspec)) &&
bl != NULL) {
bl->bl_confused = true;