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: add test for type mism...



details:   https://anonhg.NetBSD.org/src/rev/dccf21a527bf
branches:  trunk
changeset: 960413:dccf21a527bf
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Mar 18 21:20:21 2021 +0000

description:
tests/lint: add test for type mismatch in initialization

Copied and adapted from d_c99_init.c.

diffstat:

 tests/usr.bin/xlint/lint1/msg_185.c   |  18 +++++++++++++++---
 tests/usr.bin/xlint/lint1/msg_185.exp |   2 +-
 2 files changed, 16 insertions(+), 4 deletions(-)

diffs (32 lines):

diff -r 5da229d8444d -r dccf21a527bf tests/usr.bin/xlint/lint1/msg_185.c
--- a/tests/usr.bin/xlint/lint1/msg_185.c       Thu Mar 18 20:58:02 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_185.c       Thu Mar 18 21:20:21 2021 +0000
@@ -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'".
diff -r 5da229d8444d -r dccf21a527bf tests/usr.bin/xlint/lint1/msg_185.exp
--- a/tests/usr.bin/xlint/lint1/msg_185.exp     Thu Mar 18 20:58:02 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_185.exp     Thu Mar 18 21:20:21 2021 +0000
@@ -1,1 +1,1 @@
-msg_185.c(6): syntax error ':' [249]
+msg_185.c(15): initialization type mismatch (pointer to const void) and (double) [185]



Home | Main Index | Thread Index | Old Index