Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/common lint: for structs and unions, include i...



details:   https://anonhg.NetBSD.org/src/rev/935cd65b01f2
branches:  trunk
changeset: 961081:935cd65b01f2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Apr 09 19:37:39 2021 +0000

description:
lint: for structs and unions, include incompleteness in the type name

This mainly helps to assess the situation where lint warns that a
pointer cast "may be troublesome", see msg_247.exp.

diffstat:

 tests/usr.bin/xlint/lint1/msg_003.exp |  4 ++--
 tests/usr.bin/xlint/lint1/msg_175.exp |  2 +-
 tests/usr.bin/xlint/lint1/msg_247.exp |  2 +-
 usr.bin/xlint/common/tyname.c         |  8 ++++++--
 4 files changed, 10 insertions(+), 6 deletions(-)

diffs (56 lines):

diff -r a8b76728d9cc -r 935cd65b01f2 tests/usr.bin/xlint/lint1/msg_003.exp
--- a/tests/usr.bin/xlint/lint1/msg_003.exp     Fri Apr 09 19:32:12 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_003.exp     Fri Apr 09 19:37:39 2021 +0000
@@ -1,3 +1,3 @@
-msg_003.c(9): warning: 'struct struct_in_argument' declared in argument declaration list [3]
-msg_003.c(10): warning: 'union union_in_argument' declared in argument declaration list [3]
+msg_003.c(9): warning: 'incomplete struct struct_in_argument' declared in argument declaration list [3]
+msg_003.c(10): warning: 'incomplete union union_in_argument' declared in argument declaration list [3]
 msg_003.c(11): warning: 'enum enum_in_argument' declared in argument declaration list [3]
diff -r a8b76728d9cc -r 935cd65b01f2 tests/usr.bin/xlint/lint1/msg_175.exp
--- a/tests/usr.bin/xlint/lint1/msg_175.exp     Fri Apr 09 19:32:12 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_175.exp     Fri Apr 09 19:37:39 2021 +0000
@@ -1,3 +1,3 @@
-msg_175.c(8): error: initialization of incomplete type 'struct incomplete' [175]
+msg_175.c(8): error: initialization of incomplete type 'incomplete struct incomplete' [175]
 msg_175.c(10): error: incomplete structure or union incomplete: incomplete [31]
 msg_175.c(6): warning: struct incomplete never defined [233]
diff -r a8b76728d9cc -r 935cd65b01f2 tests/usr.bin/xlint/lint1/msg_247.exp
--- a/tests/usr.bin/xlint/lint1/msg_247.exp     Fri Apr 09 19:32:12 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/msg_247.exp     Fri Apr 09 19:37:39 2021 +0000
@@ -1,5 +1,5 @@
 msg_247.c(31): warning: pointer cast from 'pointer to struct Other' to 'pointer to struct <unnamed>' may be troublesome [247]
 msg_247.c(70): warning: pointer cast from 'pointer to struct Other' to 'pointer to signed char' may be troublesome [247]
-lhash.h(200): warning: pointer cast from 'pointer to struct lhash_st' to 'pointer to struct lhash_st_OPENSSL_STRING' may be troublesome [247]
+lhash.h(200): warning: pointer cast from 'pointer to incomplete struct lhash_st' to 'pointer to struct lhash_st_OPENSSL_STRING' may be troublesome [247]
        included from msg_247.c(146)
 msg_247.c(134): warning: struct lhash_st never defined [233]
diff -r a8b76728d9cc -r 935cd65b01f2 usr.bin/xlint/common/tyname.c
--- a/usr.bin/xlint/common/tyname.c     Fri Apr 09 19:32:12 2021 +0000
+++ b/usr.bin/xlint/common/tyname.c     Fri Apr 09 19:37:39 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tyname.c,v 1.37 2021/04/02 12:16:50 rillig Exp $       */
+/*     $NetBSD: tyname.c,v 1.38 2021/04/09 19:37:39 rillig Exp $       */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tyname.c,v 1.37 2021/04/02 12:16:50 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.38 2021/04/09 19:37:39 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -354,6 +354,10 @@
        if (tp->t_volatile)
                buf_add(&buf, "volatile ");
 
+#ifdef t_str
+       if ((t == STRUCT || t == UNION) && tp->t_str->sou_incomplete)
+               buf_add(&buf, "incomplete ");
+#endif
        buf_add(&buf, tspec_name(t));
 
        switch (t) {



Home | Main Index | Thread Index | Old Index