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: document lint1_type.t_is_enum



details:   https://anonhg.NetBSD.org/src/rev/323b5bf20eb4
branches:  trunk
changeset: 984315:323b5bf20eb4
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Jul 02 18:22:09 2021 +0000

description:
lint: document lint1_type.t_is_enum

Enum types are subject to implicit conversions, as opposed to struct,
union, pointer and function types.

diffstat:

 usr.bin/xlint/common/tyname.c |   8 ++------
 usr.bin/xlint/lint1/lint1.h   |  13 +++++++++++--
 2 files changed, 13 insertions(+), 8 deletions(-)

diffs (56 lines):

diff -r af9e87ead7f1 -r 323b5bf20eb4 usr.bin/xlint/common/tyname.c
--- a/usr.bin/xlint/common/tyname.c     Fri Jul 02 17:14:36 2021 +0000
+++ b/usr.bin/xlint/common/tyname.c     Fri Jul 02 18:22:09 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tyname.c,v 1.42 2021/06/28 10:29:05 rillig Exp $       */
+/*     $NetBSD: tyname.c,v 1.43 2021/07/02 18:22:09 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.42 2021/06/28 10:29:05 rillig Exp $");
+__RCSID("$NetBSD: tyname.c,v 1.43 2021/07/02 18:22:09 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -351,10 +351,6 @@
        if (tp == NULL)
                return "(null)";
 
-       /*
-        * XXX: Why is this necessary, and in which cases does this apply?
-        * Shouldn't the type be an ENUM from the beginning?
-        */
        if ((t = tp->t_tspec) == INT && tp->t_is_enum)
                t = ENUM;
 
diff -r af9e87ead7f1 -r 323b5bf20eb4 usr.bin/xlint/lint1/lint1.h
--- a/usr.bin/xlint/lint1/lint1.h       Fri Jul 02 17:14:36 2021 +0000
+++ b/usr.bin/xlint/lint1/lint1.h       Fri Jul 02 18:22:09 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.108 2021/06/28 08:52:55 rillig Exp $ */
+/* $NetBSD: lint1.h,v 1.109 2021/07/02 18:22:09 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -165,7 +165,16 @@
        bool    t_vararg : 1;   /* prototype with '...' */
        bool    t_typedef : 1;  /* type defined with typedef */
        bool    t_bitfield : 1;
-       bool    t_is_enum : 1;  /* type is (or was) enum (t_enum valid) */
+       /*
+        * Either the type is currently an enum (having t_tspec ENUM), or
+        * it is an integer type (typically INT) that has been implicitly
+        * converted from an enum type.  In both cases, t_enum is valid.
+        *
+        * The information about a former enum type is retained to allow
+        * type checks in expressions such as ((var1 & 0x0001) == var2), to
+        * detect when var1 and var2 are from incompatible enum types.
+        */
+       bool    t_is_enum : 1;
        bool    t_packed : 1;
        union {
                int     _t_dim;         /* dimension (if ARRAY) */



Home | Main Index | Thread Index | Old Index