Module Name:    src
Committed By:   rillig
Date:           Thu Mar 18 21:20:21 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_185.c msg_185.exp

Log Message:
tests/lint: add test for type mismatch in initialization

Copied and adapted from d_c99_init.c.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_185.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_185.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/msg_185.c
diff -u src/tests/usr.bin/xlint/lint1/msg_185.c:1.3 src/tests/usr.bin/xlint/lint1/msg_185.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_185.c:1.3	Mon Feb 22 15:09:50 2021
+++ src/tests/usr.bin/xlint/lint1/msg_185.c	Thu Mar 18 21:20:21 2021
@@ -1,7 +1,19 @@
-/*	$NetBSD: msg_185.c,v 1.3 2021/02/22 15:09:50 rillig Exp $	*/
+/*	$NetBSD: msg_185.c,v 1.4 2021/03/18 21:20:21 rillig Exp $	*/
 # 3 "msg_185.c"
 
 // Test for message: initialization type mismatch (%s) and (%s) [185]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+typedef struct any {
+	const void *value;
+} any;
+
+void use(const void *);
+
+void
+initialization_with_redundant_braces(any arg)
+{
+	any local = { 3.0 };	/* expect: 185 */
+	use(&arg);
+}
+
+// TODO: message 185 needs to be reworded to "cannot initialize '%s' from '%s'".

Index: src/tests/usr.bin/xlint/lint1/msg_185.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_185.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_185.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_185.exp:1.1	Sat Jan  2 10:22:43 2021
+++ src/tests/usr.bin/xlint/lint1/msg_185.exp	Thu Mar 18 21:20:21 2021
@@ -1 +1 @@
-msg_185.c(6): syntax error ':' [249]
+msg_185.c(15): initialization type mismatch (pointer to const void) and (double) [185]

Reply via email to