mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-23 19:01:06 +00:00
Treat aliased values as constant
One step closer to cast address initializers working.
This commit is contained in:
parent
ce9902baed
commit
e4eb793fb3
2 changed files with 17 additions and 1 deletions
|
@ -585,8 +585,20 @@ initialize_def (symbol_t *sym, expr_t *init, defspace_t *space,
|
|||
// fold_constants takes care of int/float conversions
|
||||
append_expr (local_expr, fold_constants (init));
|
||||
} else {
|
||||
int offset = 0;
|
||||
if (!is_constant (init)) {
|
||||
error (init, "non-constant initializier");
|
||||
return;
|
||||
}
|
||||
while ((init->type == ex_uexpr || init->type == ex_expr)
|
||||
&& init->e.expr.op == 'A') {
|
||||
if (init->type == ex_expr) {
|
||||
offset += expr_integer (init->e.expr.e2);
|
||||
}
|
||||
init = init->e.expr.e1;
|
||||
}
|
||||
if (init->type != ex_value) { //FIXME enum etc
|
||||
error (0, "non-constant initializier");
|
||||
internal_error (0, "initializier not a value");
|
||||
return;
|
||||
}
|
||||
if (init->e.value->lltype == ev_pointer
|
||||
|
|
|
@ -777,6 +777,10 @@ new_short_expr (short short_val)
|
|||
int
|
||||
is_constant (expr_t *e)
|
||||
{
|
||||
while ((e->type == ex_uexpr || e->type == ex_expr)
|
||||
&& e->e.expr.op == 'A') {
|
||||
e = e->e.expr.e1;
|
||||
}
|
||||
if (e->type == ex_nil || e->type == ex_value || e->type == ex_labelref
|
||||
|| (e->type == ex_symbol && e->e.symbol->sy_type == sy_const)
|
||||
|| (e->type == ex_symbol && e->e.symbol->sy_type == sy_var
|
||||
|
|
Loading…
Reference in a new issue