a few fixes: usual arithmetic conversions were wrong

This commit is contained in:
ceriel 1990-02-20 13:31:52 +00:00
parent 972d39139d
commit 1228fe1baf
2 changed files with 8 additions and 4 deletions

View file

@ -109,8 +109,6 @@ arithbalance(e1p, oper, e2p) /* 3.1.2.5 */
t2 = int2int(e2p, (int_size<long_size)? long_type : ulong_type); t2 = int2int(e2p, (int_size<long_size)? long_type : ulong_type);
else if (t2 == LONG && t1 == INT && u1 && !shifting) /* ??? */ else if (t2 == LONG && t1 == INT && u1 && !shifting) /* ??? */
t1 = int2int(e1p, (int_size<long_size)? long_type : ulong_type); 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- /* If either operand has type long int, the other operand is con-
verted to long int. verted to long int.
@ -121,6 +119,9 @@ arithbalance(e1p, oper, e2p) /* 3.1.2.5 */
if (t2 == LONG && t1 != LONG && !shifting) /* ??? */ if (t2 == LONG && t1 != LONG && !shifting) /* ??? */
t1 = int2int(e1p, long_type); 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 /* If either operand has type unsigned int, the other operand
is converted to unsigned int. is converted to unsigned int.
Otherwise, both operands have type int. Otherwise, both operands have type int.

View file

@ -315,8 +315,11 @@ mk_binop(expp, oper, expr, commutative)
else if (is_fp_cst(expr) && is_fp_cst(ex)) else if (is_fp_cst(expr) && is_fp_cst(ex))
fltcstbin(expp, oper, expr); fltcstbin(expp, oper, expr);
else { else {
*expp = (commutative && (expr->ex_depth >= ex->ex_depth *expp = (commutative &&
|| is_cp_cst(ex))) ! (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, expr, oper, ex)
: new_oper(ex->ex_type, ex, oper, expr); : new_oper(ex->ex_type, ex, oper, expr);
} }