Module Name:    src
Committed By:   rillig
Date:           Sat Jul  2 10:23:38 UTC 2022

Modified Files:
        src/usr.bin/xlint/lint1: tree.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.466 -r1.467 src/usr.bin/xlint/lint1/tree.c

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/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.466 src/usr.bin/xlint/lint1/tree.c:1.467
--- src/usr.bin/xlint/lint1/tree.c:1.466	Fri Jul  1 20:53:13 2022
+++ src/usr.bin/xlint/lint1/tree.c	Sat Jul  2 10:23:38 2022
@@ -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 @@ build_plus_minus(op_t op, bool sys, tnod
 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);
 }
 
 /*

Reply via email to