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 message 2...



details:   https://anonhg.NetBSD.org/src/rev/125ad45c3043
branches:  trunk
changeset: 960337:125ad45c3043
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Mar 14 21:44:35 2021 +0000

description:
tests/lint: add test for message 247 for pointer to unnamed struct

diffstat:

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

diffs (34 lines):

diff -r d42c13b791c8 -r 125ad45c3043 tests/usr.bin/xlint/lint1/msg_247.c
--- a/tests/usr.bin/xlint/lint1/msg_247.c       Sun Mar 14 20:41:39 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_247.c       Sun Mar 14 21:44:35 2021 +0000
@@ -1,7 +1,21 @@
-/*     $NetBSD: msg_247.c,v 1.3 2021/02/28 12:40:00 rillig Exp $       */
+/*     $NetBSD: msg_247.c,v 1.4 2021/03/14 21:44:35 rillig Exp $       */
 # 3 "msg_247.c"
 
 // Test for message: pointer cast from '%s' to '%s' may be troublesome [247]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -c */
+
+/* example taken from Xlib.h */
+typedef struct {
+       int id;
+} *PDisplay;
+
+struct Other {
+       int id;
+};
+
+void
+example(struct Other *arg)
+{
+       PDisplay display = (PDisplay)arg;       /* expect: 247 */
+}
diff -r d42c13b791c8 -r 125ad45c3043 tests/usr.bin/xlint/lint1/msg_247.exp
--- a/tests/usr.bin/xlint/lint1/msg_247.exp     Sun Mar 14 20:41:39 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_247.exp     Sun Mar 14 21:44:35 2021 +0000
@@ -1,1 +1,1 @@
-msg_247.c(6): syntax error ':' [249]
+msg_247.c(20): warning: pointer cast from 'pointer to struct Other' to 'pointer to struct <unnamed>' may be troublesome [247]



Home | Main Index | Thread Index | Old Index