Module Name:    src
Committed By:   rillig
Date:           Sat Apr 10 18:36:28 UTC 2021

Modified Files:
        src/usr.bin/xlint/common: lint.h tyname.c
        src/usr.bin/xlint/lint1: Makefile lint1.h
        src/usr.bin/xlint/lint2: Makefile lint2.h

Log Message:
lint: use distinct struct tags for type_t in lint1 and lint2

Having two similar but still different definitions of 'struct type' is
unnecessarily confusing.  Exchange this confusion for 8 lines of
straight-forward preprocessing code.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/xlint/common/lint.h
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/xlint/common/tyname.c
cvs rdiff -u -r1.66 -r1.67 src/usr.bin/xlint/lint1/Makefile
cvs rdiff -u -r1.93 -r1.94 src/usr.bin/xlint/lint1/lint1.h
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/xlint/lint2/Makefile
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/xlint/lint2/lint2.h

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

Modified files:

Index: src/usr.bin/xlint/common/lint.h
diff -u src/usr.bin/xlint/common/lint.h:1.26 src/usr.bin/xlint/common/lint.h:1.27
--- src/usr.bin/xlint/common/lint.h:1.26	Sun Feb 28 18:51:51 2021
+++ src/usr.bin/xlint/common/lint.h	Sat Apr 10 18:36:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lint.h,v 1.26 2021/02/28 18:51:51 rillig Exp $	*/
+/*	$NetBSD: lint.h,v 1.27 2021/04/10 18:36:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -135,7 +135,11 @@ typedef	struct	ob {
 	char	*o_next;	/* next free byte in buffer */
 } ob_t;
 
-typedef struct type type_t;
+#if defined(IS_LINT1)
+typedef struct lint1_type type_t;
+#else
+typedef struct lint2_type type_t;
+#endif
 
 #include "externs.h"
 

Index: src/usr.bin/xlint/common/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.38 src/usr.bin/xlint/common/tyname.c:1.39
--- src/usr.bin/xlint/common/tyname.c:1.38	Fri Apr  9 19:37:39 2021
+++ src/usr.bin/xlint/common/tyname.c	Sat Apr 10 18:36:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tyname.c,v 1.38 2021/04/09 19:37:39 rillig Exp $	*/
+/*	$NetBSD: tyname.c,v 1.39 2021/04/10 18:36:27 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.38 2021/04/09 19:37:39 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.39 2021/04/10 18:36:27 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -43,7 +43,11 @@ __RCSID("$NetBSD: tyname.c,v 1.38 2021/0
 #include <stdlib.h>
 #include <err.h>
 
-#include PASS
+#if defined(IS_LINT1)
+#include "lint1.h"
+#else
+#include "lint2.h"
+#endif
 
 #ifndef INTERNAL_ERROR
 #define INTERNAL_ERROR(fmt, args...) \

Index: src/usr.bin/xlint/lint1/Makefile
diff -u src/usr.bin/xlint/lint1/Makefile:1.66 src/usr.bin/xlint/lint1/Makefile:1.67
--- src/usr.bin/xlint/lint1/Makefile:1.66	Tue Apr  6 13:17:04 2021
+++ src/usr.bin/xlint/lint1/Makefile	Sat Apr 10 18:36:27 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.66 2021/04/06 13:17:04 rillig Exp $
+#	$NetBSD: Makefile,v 1.67 2021/04/10 18:36:27 rillig Exp $
 
 .include <bsd.own.mk>
 
@@ -18,7 +18,8 @@ YHEADER=
 CWARNFLAGS.clang+=	-Wno-error=implicit-int-float-conversion
 LINTFLAGS+=		-T
 
-CPPFLAGS+=	-I${.CURDIR} -I. -DPASS=\"${PROG}.h\"
+CPPFLAGS+=	-DIS_LINT1
+CPPFLAGS+=	-I${.CURDIR}
 CPPFLAGS+=	${DEBUG:D-DDEBUG}
 
 BINDIR=		/usr/libexec

Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.93 src/usr.bin/xlint/lint1/lint1.h:1.94
--- src/usr.bin/xlint/lint1/lint1.h:1.93	Sat Apr 10 18:06:53 2021
+++ src/usr.bin/xlint/lint1/lint1.h	Sat Apr 10 18:36:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.93 2021/04/10 18:06:53 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.94 2021/04/10 18:36:27 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -148,7 +148,7 @@ typedef	struct {
  * The type of an expression or object. Complex types are formed via t_subt
  * (for arrays, pointers and functions), as well as t_str.
  */
-struct type {
+struct lint1_type {
 	tspec_t	t_tspec;	/* type specifier */
 	bool	t_incomplete_array : 1;
 	bool	t_const : 1;	/* const modifier */
@@ -169,8 +169,9 @@ struct type {
 		u_int	_t_flen : 8;	/* length of bit-field */
 		u_int	_t_foffs : 24;	/* offset of bit-field */
 	} t_b;
-	struct	type *t_subt;	/* element type (arrays), return value
-				   (functions), or type pointer points to */
+	struct	lint1_type *t_subt; /* element type (if ARRAY),
+				 * return value (if FUNC),
+				 * target type (if PTR) */
 };
 
 #define	t_dim	t_u._t_dim

Index: src/usr.bin/xlint/lint2/Makefile
diff -u src/usr.bin/xlint/lint2/Makefile:1.18 src/usr.bin/xlint/lint2/Makefile:1.19
--- src/usr.bin/xlint/lint2/Makefile:1.18	Sat Jan 16 00:09:28 2021
+++ src/usr.bin/xlint/lint2/Makefile	Sat Apr 10 18:36:27 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.18 2021/01/16 00:09:28 rillig Exp $
+#	$NetBSD: Makefile,v 1.19 2021/04/10 18:36:27 rillig Exp $
 
 NOMAN=		# defined
 
@@ -6,6 +6,6 @@ PROG=		lint2
 SRCS=		main2.c hash.c read.c mem.c mem2.c chk.c msg.c emit.c emit2.c \
 		inittyp.c tyname.c
 BINDIR=		/usr/libexec
-CPPFLAGS+=	-DPASS=\"${PROG}.h\" -I${.CURDIR}
+CPPFLAGS+=	-I${.CURDIR}
 
 .include <bsd.prog.mk>

Index: src/usr.bin/xlint/lint2/lint2.h
diff -u src/usr.bin/xlint/lint2/lint2.h:1.13 src/usr.bin/xlint/lint2/lint2.h:1.14
--- src/usr.bin/xlint/lint2/lint2.h:1.13	Fri Feb 19 22:27:49 2021
+++ src/usr.bin/xlint/lint2/lint2.h	Sat Apr 10 18:36:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lint2.h,v 1.13 2021/02/19 22:27:49 rillig Exp $ */
+/* $NetBSD: lint2.h,v 1.14 2021/04/10 18:36:27 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -37,7 +37,7 @@
 /*
  * Types are described by structures of type type_t.
  */
-struct type {
+struct lint2_type {
 	tspec_t	t_tspec;	/* type specifier */
 	bool	t_const : 1;	/* constant */
 	bool	t_volatile : 1;	/* volatile */
@@ -61,11 +61,12 @@ struct type {
 		} _t_uniqpos;		/* unique position, for untagged
 					   untyped STRUCTs, UNIONS, and ENUMs,
 					   if t_isuniqpos */
-		struct	type **_t_args;	/* list of argument types if this
-					   is a prototype */
+		struct	lint2_type **_t_args; /* list of argument types if
+					   this is a prototype */
 	} t_u;
-	struct	type *t_subt;	/* indirected type (array element, pointed to
-				   type, type of return value) */
+	struct	lint2_type *t_subt;	/* element type (if ARRAY),
+					   return type (if FUNC),
+					   target type (if PTR) */
 };
 
 #define	t_dim		t_u._t_dim
@@ -181,7 +182,7 @@ typedef	struct hte {
 	usym_t	*h_usyms;	/* usage info */
 	usym_t	**h_lusym;	/* points to u_next of last usage info */
 	struct	hte *h_link;	/* next hte with same hash function */
-	struct  hte *h_hte;	/* pointer to other htes (for renames */
+	struct  hte *h_hte;	/* pointer to other htes (for renames) */
 } hte_t;
 
 /* maps type indices into pointers to type structs */

Reply via email to