Coercion from int to float is now always done compile time

This commit is contained in:
ceriel
1988-10-03 10:09:19 +00:00
parent 4cecb6bffb
commit 6b7a135b2b
3 changed files with 25 additions and 3 deletions

View File

@@ -270,9 +270,22 @@ int2float(expp, tp)
/* The expression *expp, which is of some integral type, is
converted to the floating type tp.
*/
register struct expr *exp = *expp;
char buf[32];
fp_used = 1;
*expp = arith2arith(tp, INT2FLOAT, *expp);
if (is_cp_cst(exp)) {
*expp = new_expr();
**expp = *exp;
sprint(buf+1, "%ld", (long)(exp->VL_VALUE));
buf[0] = '-';
exp = *expp;
exp->ex_type = tp;
exp->ex_class = Float;
exp->FL_VALUE = Salloc(buf, (unsigned)strlen(buf)+1) + 1;
exp->FL_DATLAB = 0;
}
else *expp = arith2arith(tp, INT2FLOAT, *expp);
}
float2int(expp, tp)