Module Name:    src
Committed By:   rillig
Date:           Fri Jul  2 18:22:09 UTC 2021

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

Log Message:
lint: document lint1_type.t_is_enum

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


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/xlint/common/tyname.c
cvs rdiff -u -r1.108 -r1.109 src/usr.bin/xlint/lint1/lint1.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/tyname.c
diff -u src/usr.bin/xlint/common/tyname.c:1.42 src/usr.bin/xlint/common/tyname.c:1.43
--- src/usr.bin/xlint/common/tyname.c:1.42	Mon Jun 28 10:29:05 2021
+++ src/usr.bin/xlint/common/tyname.c	Fri Jul  2 18:22:09 2021
@@ -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 @@ type_name(const type_t *tp)
 	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;
 

Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.108 src/usr.bin/xlint/lint1/lint1.h:1.109
--- src/usr.bin/xlint/lint1/lint1.h:1.108	Mon Jun 28 08:52:55 2021
+++ src/usr.bin/xlint/lint1/lint1.h	Fri Jul  2 18:22:09 2021
@@ -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 @@ struct lint1_type {
 	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) */

Reply via email to