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: demonstrate wrong type...



details:   https://anonhg.NetBSD.org/src/rev/7814630377bb
branches:  trunk
changeset: 372903:7814630377bb
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Jan 03 22:02:20 2023 +0000

description:
tests/lint: demonstrate wrong type for '?:' expressions

diffstat:

 tests/usr.bin/xlint/lint1/op_colon.c |  58 ++++++++++++++++++++++++++++++++++-
 1 files changed, 56 insertions(+), 2 deletions(-)

diffs (81 lines):

diff -r 21fd54944be4 -r 7814630377bb tests/usr.bin/xlint/lint1/op_colon.c
--- a/tests/usr.bin/xlint/lint1/op_colon.c      Tue Jan 03 21:14:14 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/op_colon.c      Tue Jan 03 22:02:20 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: op_colon.c,v 1.3 2022/06/17 18:54:53 rillig Exp $      */
+/*     $NetBSD: op_colon.c,v 1.4 2023/01/03 22:02:20 rillig Exp $      */
 # 3 "op_colon.c"
 
 /*
@@ -7,12 +7,18 @@
 
 /* lint1-extra-flags: -p */
 
-void sink(void *);
+struct unknown {
+       int member;
+};
+
+void
+sink(struct unknown *);
 
 void
 test_merge_qualifiers(_Bool cond, int *p, const int *c, volatile int *v,
                      const volatile int *cv)
 {
+       /* expect+1: ... 'pointer to int' ... */
        sink(cond ? p : p);
        /* expect+1: ... 'pointer to const int' ... */
        sink(cond ? p : c);
@@ -48,3 +54,51 @@
        /* expect+1: ... 'pointer to const volatile int' ... */
        sink(cond ? cv : cv);
 }
+
+void
+c99_6_5_15_p8(
+    _Bool cond,
+    const void *c_vp,
+    void *vp,
+    const int *c_ip,
+    volatile int *v_ip,
+    int *ip,
+    const char *c_cp
+)
+{
+       /* FIXME: expect+2: ... 'pointer to const void' ... */
+       /* FIXME: expect+2: ... 'pointer to const void' ... */
+       /* expect+2: ... 'pointer to const int' ... */
+       /* expect+2: ... 'pointer to const int' ... */
+       sink(cond ? c_vp : c_ip);
+       sink(cond ? c_ip : c_vp);
+
+       /* expect+2: ... 'pointer to volatile int' ... */
+       /* expect+2: ... 'pointer to volatile int' ... */
+       sink(cond ? v_ip : 0);
+       sink(cond ? 0 : v_ip);
+
+       /* expect+2: ... 'pointer to const volatile int' ... */
+       /* expect+2: ... 'pointer to const volatile int' ... */
+       sink(cond ? c_ip : v_ip);
+       sink(cond ? v_ip : c_ip);
+
+       /* FIXME: expect+2: ... 'pointer to const void' ... */
+       /* FIXME: expect+2: ... 'pointer to const void' ... */
+       /* expect+2: ... 'pointer to const char' ... */
+       /* expect+2: ... 'pointer to const char' ... */
+       sink(cond ? vp : c_cp);
+       sink(cond ? c_cp : vp);
+
+       /* expect+2: ... 'pointer to const int' ... */
+       /* expect+2: ... 'pointer to const int' ... */
+       sink(cond ? ip : c_ip);
+       sink(cond ? c_ip : ip);
+
+       /* FIXME: expect+2: ... 'pointer to void' ... */
+       /* FIXME: expect+2: ... 'pointer to void' ... */
+       /* expect+2: ... 'pointer to int' ... */
+       /* expect+2: ... 'pointer to int' ... */
+       sink(cond ? vp : ip);
+       sink(cond ? ip : vp);
+}



Home | Main Index | Thread Index | Old Index