Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 lint: in strict bool mode, make (flag & ...
details: https://anonhg.NetBSD.org/src/rev/2cc1b1cd279c
branches: trunk
changeset: 380039:2cc1b1cd279c
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Jul 02 21:22:26 2021 +0000
description:
lint: in strict bool mode, make (flag & FLAG) simpler
This is a tiny change in an edge case that does not occur in practice,
which is that the left-hand side of the '&' is explicitly cast to an
enum type. The apparent "loss of information" from the deleted comment
has already been explained in the previous commit.
diffstat:
usr.bin/xlint/lint1/ckbool.c | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
diffs (35 lines):
diff -r 518877d9dd80 -r 2cc1b1cd279c usr.bin/xlint/lint1/ckbool.c
--- a/usr.bin/xlint/lint1/ckbool.c Fri Jul 02 18:52:20 2021 +0000
+++ b/usr.bin/xlint/lint1/ckbool.c Fri Jul 02 21:22:26 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ckbool.c,v 1.5 2021/07/02 18:52:20 rillig Exp $ */
+/* $NetBSD: ckbool.c,v 1.6 2021/07/02 21:22:26 rillig Exp $ */
/*-
* Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: ckbool.c,v 1.5 2021/07/02 18:52:20 rillig Exp $");
+__RCSID("$NetBSD: ckbool.c,v 1.6 2021/07/02 21:22:26 rillig Exp $");
#endif
#include <string.h>
@@ -229,14 +229,8 @@ is_typeok_bool_operand(const tnode_t *tn
/* For enums that are used as bit sets, allow "flags & FLAG". */
if (tn->tn_op == BITAND &&
tn->tn_left->tn_op == CVT &&
- tn->tn_left->tn_type->t_tspec == INT && !tn->tn_left->tn_cast &&
- tn->tn_left->tn_left->tn_type->t_tspec == ENUM &&
- /*
- * XXX: Somehow the type information got lost here. The type
- * of the enum constant on the right-hand side should still be
- * ENUM, but is INT.
- */
- tn->tn_right->tn_type->t_tspec == INT)
+ tn->tn_left->tn_type->t_is_enum &&
+ tn->tn_right->tn_type->t_is_enum)
return true;
return false;
Home |
Main Index |
Thread Index |
Old Index