From 485faa29449884a1e756d0e6e7edbc3a650b6e08 Mon Sep 17 00:00:00 2001 From: George Koehler Date: Mon, 16 Sep 2019 21:35:38 -0400 Subject: [PATCH] Remove extra conversion of shift count in ACK C. Given `long long o1` and `unsigned int o2`, then `o1 << o2` was converting o2 to long long and then to int. Remove the first conversion and just convert o2 to int. --- lang/cem/cemcom.ansi/arith.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lang/cem/cemcom.ansi/arith.c b/lang/cem/cemcom.ansi/arith.c index 21a86faf3..654ea6dc2 100644 --- a/lang/cem/cemcom.ansi/arith.c +++ b/lang/cem/cemcom.ansi/arith.c @@ -143,7 +143,11 @@ void arithbalance(register struct expr **e1p, int oper, register struct expr **e converted to the signed type, else both operands are converted to an unsigned type. */ - if (t1 == LNGLNG && u1 && (t2 != LNGLNG || !u2)) + if (shifting) { + /* In shifts like o1 << o2, never convert o1, + and let ch3bin() convert o2 to int. + */ + } else if (t1 == LNGLNG && u1 && (t2 != LNGLNG || !u2)) convert2 = ulnglng_type; else if (t2 == LNGLNG && u2 && (t1 != LNGLNG || !u1)) convert1 = ulnglng_type; @@ -180,7 +184,7 @@ void arithbalance(register struct expr **e1p, int oper, register struct expr **e else if (t2 == LONG && t1 != LONG) convert1 = long_type; - if (convert1 && !shifting) /* ??? */ + if (convert1) t1 = int2int(e1p, convert1); if (convert2) t2 = int2int(e2p, convert2);