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: only convert the right operand of ...
details: https://anonhg.NetBSD.org/src/rev/af43a7c49c94
branches: trunk
changeset: 368277:af43a7c49c94
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Jul 02 10:23:38 2022 +0000
description:
lint: only convert the right operand of '<<' or '>>' in traditional C
Traditional C says: "Then the right operand is converted to int".
C90 dropped that sentence, probably because it didn't have any effect on
the result or the conditions for undefined behavior.
To stick to the wording of the specification, also convert UINT to INT.
While here, fix the call to 'convert'. The first argument being 'CVT'
means that the conversion comes from a cast-expression instead of an
implicit conversion. This prevents warnings for 'uint64_t << uint64_t'.
Keeping this unnecessary conversion in C90 or later would have generated
warnings for the functions at the bottom of msg_132.c.
diffstat:
usr.bin/xlint/lint1/tree.c | 15 ++++++---------
1 files changed, 6 insertions(+), 9 deletions(-)
diffs (36 lines):
diff -r a02313cdc709 -r af43a7c49c94 usr.bin/xlint/lint1/tree.c
--- a/usr.bin/xlint/lint1/tree.c Sat Jul 02 09:48:18 2022 +0000
+++ b/usr.bin/xlint/lint1/tree.c Sat Jul 02 10:23:38 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tree.c,v 1.466 2022/07/01 20:53:13 rillig Exp $ */
+/* $NetBSD: tree.c,v 1.467 2022/07/02 10:23:38 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
-__RCSID("$NetBSD: tree.c,v 1.466 2022/07/01 20:53:13 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.467 2022/07/02 10:23:38 rillig Exp $");
#endif
#include <float.h>
@@ -3213,13 +3213,10 @@
static tnode_t *
build_bit_shift(op_t op, bool sys, tnode_t *ln, tnode_t *rn)
{
- tspec_t t;
- tnode_t *ntn;
-
- if ((t = rn->tn_type->t_tspec) != INT && t != UINT)
- rn = convert(CVT, 0, gettyp(INT), rn);
- ntn = new_tnode(op, sys, ln->tn_type, ln, rn);
- return ntn;
+
+ if (!allow_c90 && rn->tn_type->t_tspec != INT)
+ rn = convert(NOOP, 0, gettyp(INT), rn);
+ return new_tnode(op, sys, ln->tn_type, ln, rn);
}
/*
Home |
Main Index |
Thread Index |
Old Index