mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
Fix case label type conversions.
The previous method made too many assumptions.
This commit is contained in:
parent
fe4df03896
commit
dc7a78b2ff
1 changed files with 12 additions and 7 deletions
|
@ -132,13 +132,18 @@ case_label_expr (switch_block_t *switch_block, expr_t *value)
|
||||||
type_t *val_type = get_type (value);
|
type_t *val_type = get_type (value);
|
||||||
if (!type_assignable (type, get_type (value)))
|
if (!type_assignable (type, get_type (value)))
|
||||||
return error (value, "type mismatch in case label");
|
return error (value, "type mismatch in case label");
|
||||||
if (type != val_type) {
|
if (is_integral (type) && is_integral (val_type)) {
|
||||||
//FIXME shorts?
|
// do nothing
|
||||||
if (type == &type_float)
|
debug (value, "integeral label used in integral switch");
|
||||||
value->e.value.v.float_val = value->e.value.v.integer_val;
|
} else if (is_integral (type) && is_float (val_type)) {
|
||||||
else
|
warning (value, "float label used in integral switch");
|
||||||
value->e.value.v.integer_val = value->e.value.v.float_val;
|
value = new_integer_expr (expr_float (value));
|
||||||
value->e.value.type = type->type;
|
} else if (is_float (type) && is_integral (val_type)) {
|
||||||
|
debug (value, "integeral label used in float switch");
|
||||||
|
value = new_float_expr (expr_integer (value));
|
||||||
|
} else if (is_float (type) && is_float (val_type)) {
|
||||||
|
// do nothing
|
||||||
|
debug (value, "float label used in float switch");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cl->value = value;
|
cl->value = value;
|
||||||
|
|
Loading…
Reference in a new issue