From 1228fe1baf862f6554ffe0451fd0ecc21a4661b7 Mon Sep 17 00:00:00 2001 From: ceriel Date: Tue, 20 Feb 1990 13:31:52 +0000 Subject: [PATCH] a few fixes: usual arithmetic conversions were wrong --- lang/cem/cemcom.ansi/arith.c | 5 +++-- lang/cem/cemcom.ansi/ch3bin.c | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lang/cem/cemcom.ansi/arith.c b/lang/cem/cemcom.ansi/arith.c index 6d8c03236..aed66945a 100644 --- a/lang/cem/cemcom.ansi/arith.c +++ b/lang/cem/cemcom.ansi/arith.c @@ -109,8 +109,6 @@ arithbalance(e1p, oper, e2p) /* 3.1.2.5 */ t2 = int2int(e2p, (int_size long_size) /* sanity check */ - crash("size of int exceeds size of long"); /* If either operand has type long int, the other operand is con- verted to long int. @@ -121,6 +119,9 @@ arithbalance(e1p, oper, e2p) /* 3.1.2.5 */ if (t2 == LONG && t1 != LONG && !shifting) /* ??? */ t1 = int2int(e1p, long_type); + u1 = (*e1p)->ex_type->tp_unsigned; + u2 = (*e2p)->ex_type->tp_unsigned; + /* If either operand has type unsigned int, the other operand is converted to unsigned int. Otherwise, both operands have type int. diff --git a/lang/cem/cemcom.ansi/ch3bin.c b/lang/cem/cemcom.ansi/ch3bin.c index b86a00bdd..51eba8169 100644 --- a/lang/cem/cemcom.ansi/ch3bin.c +++ b/lang/cem/cemcom.ansi/ch3bin.c @@ -315,8 +315,11 @@ mk_binop(expp, oper, expr, commutative) else if (is_fp_cst(expr) && is_fp_cst(ex)) fltcstbin(expp, oper, expr); else { - *expp = (commutative && (expr->ex_depth >= ex->ex_depth - || is_cp_cst(ex))) + *expp = (commutative && + ! (ex->ex_flags & EX_VOLATILE) && + ( expr->ex_depth > ex->ex_depth || + (expr->ex_flags & EX_SIDEEFFECTS) || + is_cp_cst(ex))) ? new_oper(ex->ex_type, expr, oper, ex) : new_oper(ex->ex_type, ex, oper, expr); } -- 2.34.1