Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/xlint lint: use distinct struct tags for type_t in l...



details:   https://anonhg.NetBSD.org/src/rev/b69f4f617ee9
branches:  trunk
changeset: 961099:b69f4f617ee9
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Apr 10 18:36:27 2021 +0000

description:
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.

diffstat:

 usr.bin/xlint/common/lint.h   |   8 ++++++--
 usr.bin/xlint/common/tyname.c |  10 +++++++---
 usr.bin/xlint/lint1/Makefile  |   5 +++--
 usr.bin/xlint/lint1/lint1.h   |   9 +++++----
 usr.bin/xlint/lint2/Makefile  |   4 ++--
 usr.bin/xlint/lint2/lint2.h   |  15 ++++++++-------
 6 files changed, 31 insertions(+), 20 deletions(-)

diffs (163 lines):

diff -r 99c84f91b979 -r b69f4f617ee9 usr.bin/xlint/common/lint.h
--- a/usr.bin/xlint/common/lint.h       Sat Apr 10 18:06:53 2021 +0000
+++ b/usr.bin/xlint/common/lint.h       Sat Apr 10 18:36:27 2021 +0000
@@ -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 @@
        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"
 
diff -r 99c84f91b979 -r b69f4f617ee9 usr.bin/xlint/common/tyname.c
--- a/usr.bin/xlint/common/tyname.c     Sat Apr 10 18:06:53 2021 +0000
+++ b/usr.bin/xlint/common/tyname.c     Sat Apr 10 18:36:27 2021 +0000
@@ -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 @@
 #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...) \
diff -r 99c84f91b979 -r b69f4f617ee9 usr.bin/xlint/lint1/Makefile
--- a/usr.bin/xlint/lint1/Makefile      Sat Apr 10 18:06:53 2021 +0000
+++ b/usr.bin/xlint/lint1/Makefile      Sat Apr 10 18:36:27 2021 +0000
@@ -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 @@
 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
diff -r 99c84f91b979 -r b69f4f617ee9 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Sat Apr 10 18:06:53 2021 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Sat Apr 10 18:36:27 2021 +0000
@@ -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 @@
  * 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 @@
                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
diff -r 99c84f91b979 -r b69f4f617ee9 usr.bin/xlint/lint2/Makefile
--- a/usr.bin/xlint/lint2/Makefile      Sat Apr 10 18:06:53 2021 +0000
+++ b/usr.bin/xlint/lint2/Makefile      Sat Apr 10 18:36:27 2021 +0000
@@ -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 @@
 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>
diff -r 99c84f91b979 -r b69f4f617ee9 usr.bin/xlint/lint2/lint2.h
--- a/usr.bin/xlint/lint2/lint2.h       Sat Apr 10 18:06:53 2021 +0000
+++ b/usr.bin/xlint/lint2/lint2.h       Sat Apr 10 18:36:27 2021 +0000
@@ -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 @@
                } _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 @@
        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 */



Home | Main Index | Thread Index | Old Index