Module Name:    src
Committed By:   rillig
Date:           Fri Apr  9 19:37:39 UTC 2021

Modified Files:
        src/tests/usr.bin/xlint/lint1: msg_003.exp msg_175.exp msg_247.exp
        src/usr.bin/xlint/common: tyname.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_003.exp
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_175.exp
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/msg_247.exp
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/xlint/common/tyname.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_003.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_003.exp:1.3 src/tests/usr.bin/xlint/lint1/msg_003.exp:1.4
--- src/tests/usr.bin/xlint/lint1/msg_003.exp:1.3	Sun Jan 31 09:26:27 2021
+++ src/tests/usr.bin/xlint/lint1/msg_003.exp	Fri Apr  9 19:37:39 2021
@@ -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]

Index: src/tests/usr.bin/xlint/lint1/msg_175.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_175.exp:1.5 src/tests/usr.bin/xlint/lint1/msg_175.exp:1.6
--- src/tests/usr.bin/xlint/lint1/msg_175.exp:1.5	Tue Mar 30 15:07:53 2021
+++ src/tests/usr.bin/xlint/lint1/msg_175.exp	Fri Apr  9 19:37:39 2021
@@ -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]

Index: src/tests/usr.bin/xlint/lint1/msg_247.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_247.exp:1.8 src/tests/usr.bin/xlint/lint1/msg_247.exp:1.9
--- src/tests/usr.bin/xlint/lint1/msg_247.exp:1.8	Fri Apr  9 19:32:12 2021
+++ src/tests/usr.bin/xlint/lint1/msg_247.exp	Fri Apr  9 19:37:39 2021
@@ -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]

Index: src/usr.bin/xlint/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.37 src/usr.bin/xlint/common/tyname.c:1.38
--- src/usr.bin/xlint/common/tyname.c:1.37	Fri Apr  2 12:16:50 2021
+++ src/usr.bin/xlint/common/tyname.c	Fri Apr  9 19:37:39 2021
@@ -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 @@ type_name(const type_t *tp)
 	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) {

Reply via email to