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 lint: add test for message 124 "il...



details:   https://anonhg.NetBSD.org/src/rev/e0498f93f55a
branches:  trunk
changeset: 1017651:e0498f93f55a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jan 03 15:44:35 2021 +0000

description:
lint: add test for message 124 "illegal pointer combination"

The message may be correct, but it is not helpful in any way.  There are
just too many function pointers that may differ in a very small detail.

Before tyname.c 1.20 from 2021-01-02, the string representation of type
names was often limited to only 63 characters.  Because of this, it made
sense to omit any detail that could need more space than this.  Now that
this limitation is gone, it's reasonable to add more detail to the type
information, especially since that information is readily available.

diffstat:

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

diffs (34 lines):

diff -r 7e049cdbad42 -r e0498f93f55a tests/usr.bin/xlint/lint1/msg_124.c
--- a/tests/usr.bin/xlint/lint1/msg_124.c       Sun Jan 03 15:35:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_124.c       Sun Jan 03 15:44:35 2021 +0000
@@ -1,7 +1,19 @@
-/*     $NetBSD: msg_124.c,v 1.1 2021/01/02 10:22:43 rillig Exp $       */
+/*     $NetBSD: msg_124.c,v 1.2 2021/01/03 15:44:35 rillig Exp $       */
 # 3 "msg_124.c"
 
 // Test for message: illegal pointer combination, op %s [124]
 
-TODO: "Add example code that triggers the above message."
-TODO: "Add example code that almost triggers the above message."
+typedef void(*signal_handler)(int);
+
+typedef signal_handler(*sys_signal)(signal_handler);
+
+typedef int(*printflike)(const char *, ...)
+    __attribute__((format(printf, 1, 2)));
+
+void
+example(int *ptr)
+{
+       signal_handler handler = ptr;
+       sys_signal signal = ptr;
+       printflike printf = ptr;
+}
diff -r 7e049cdbad42 -r e0498f93f55a tests/usr.bin/xlint/lint1/msg_124.exp
--- a/tests/usr.bin/xlint/lint1/msg_124.exp     Sun Jan 03 15:35:00 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_124.exp     Sun Jan 03 15:44:35 2021 +0000
@@ -1,1 +1,3 @@
-msg_124.c(6): syntax error ':' [249]
+msg_124.c(16): warning: illegal pointer combination, op p = p [124]
+msg_124.c(17): warning: illegal pointer combination, op p = p [124]
+msg_124.c(18): warning: illegal pointer combination, op p = p [124]



Home | Main Index | Thread Index | Old Index