mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-18 18:01:13 +00:00
Check the expression type when casting constants.
Not all constant expressions are ex_value. This fixes the bogus errors and ice in paroxysm.
This commit is contained in:
parent
84a68b139e
commit
452728126d
1 changed files with 13 additions and 1 deletions
|
@ -2677,7 +2677,19 @@ cast_expr (type_t *type, expr_t *e)
|
||||||
if (is_array (e_type))
|
if (is_array (e_type))
|
||||||
return address_expr (e, 0, 0);
|
return address_expr (e, 0, 0);
|
||||||
if (is_constant (e) && is_scalar (type) && is_scalar (e_type)) {
|
if (is_constant (e) && is_scalar (type) && is_scalar (e_type)) {
|
||||||
e->e.value = convert_value (e->e.value, type);
|
ex_value_t *val = 0;
|
||||||
|
if (e->type == ex_symbol && e->e.symbol->sy_type == sy_const) {
|
||||||
|
val = e->e.symbol->s.value;
|
||||||
|
} else if (e->type == ex_value) {
|
||||||
|
val = e->e.value;
|
||||||
|
} else if (e->type == ex_nil) {
|
||||||
|
convert_nil (e, type);
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
if (!val)
|
||||||
|
internal_error (e, "unexpected constant expression type");
|
||||||
|
e->e.value = convert_value (val, type);
|
||||||
|
e->type = ex_value;
|
||||||
c = e;
|
c = e;
|
||||||
} else if ((is_float (type) && is_integral (e_type))
|
} else if ((is_float (type) && is_integral (e_type))
|
||||||
|| (is_integral (type) && is_float (e_type))) {
|
|| (is_integral (type) && is_float (e_type))) {
|
||||||
|
|
Loading…
Reference in a new issue