Cast constants at compile time.

This takes care of the internal error due to aliasing values.
This commit is contained in:
Bill Currie 2012-12-05 22:19:22 +09:00
parent f7e174f3ba
commit c06cd8fcc0

View file

@ -2675,7 +2675,10 @@ cast_expr (type_t *type, expr_t *e)
}
if (is_array (e_type))
return address_expr (e, 0, 0);
if ((is_float (type) && is_integral (e_type))
if (is_constant (e) && is_scalar (type) && is_scalar (e_type)) {
e->e.value = convert_value (e->e.value, type);
c = e;
} else if ((is_float (type) && is_integral (e_type))
|| (is_integral (type) && is_float (e_type))) {
c = new_unary_expr ('C', e);
c->e.expr.type = type;