a few fixes: usual arithmetic conversions were wrong
authorceriel <none@none>
Tue, 20 Feb 1990 13:31:52 +0000 (13:31 +0000)
committerceriel <none@none>
Tue, 20 Feb 1990 13:31:52 +0000 (13:31 +0000)
lang/cem/cemcom.ansi/arith.c
lang/cem/cemcom.ansi/ch3bin.c

index 6d8c032..aed6694 100644 (file)
@@ -109,8 +109,6 @@ arithbalance(e1p, oper, e2p)        /* 3.1.2.5 */
                t2 = int2int(e2p, (int_size<long_size)? long_type : ulong_type);
        else if (t2 == LONG && t1 == INT && u1 && !shifting)    /* ??? */
                t1 = int2int(e1p, (int_size<long_size)? long_type : ulong_type);
-       if (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.
index b86a00b..51eba81 100644 (file)
@@ -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);
        }