Fix ICE when const-folding doubles

I really need to rework that system.
This commit is contained in:
Bill Currie 2020-02-23 20:49:56 +09:00
parent 2a39208069
commit ea3af84baa
3 changed files with 14 additions and 1 deletions

View file

@ -612,6 +612,7 @@ void dump_dot_expr (void *e, const char *filename);
void convert_int (expr_t *e);
void convert_short (expr_t *e);
void convert_short_int (expr_t *e);
void convert_double (expr_t *e);
void convert_nil (expr_t *e, struct type_s *t);
expr_t *test_expr (expr_t *e);

View file

@ -148,8 +148,12 @@ convert_to_float (expr_t *e)
case ev_short:
convert_short (e);
return e;
case ev_double:
convert_double (e);
return e;
default:
internal_error (e, 0);
internal_error (e, "bad conversion to float: %d",
e->e.value->lltype);
}
break;
case ex_symbol:

View file

@ -1546,6 +1546,14 @@ convert_short_int (expr_t *e)
e->e.value = new_integer_val (integer_val);
}
void
convert_double (expr_t *e)
{
float float_val = expr_double (e);
e->type = ex_value;
e->e.value = new_float_val (float_val);
}
void
convert_nil (expr_t *e, type_t *t)
{