Ensure alias operands are never nested.

No more than one level of aliasing is ever needed, so strip off any
intervening aliases that show up.
This commit is contained in:
Bill Currie 2012-11-15 15:18:00 +09:00
parent 6621a42da9
commit 095210893f
2 changed files with 7 additions and 1 deletions

View File

@ -149,7 +149,7 @@ add_statement_def_ref (def_t *def, dstatement_t *st, int field)
free_def (a); free_def (a);
} }
if (alias_depth > 1) { if (alias_depth > 1) {
bug (&alias_depth_expr, "alias chain detected: %d %s", internal_error (&alias_depth_expr, "alias chain detected: %d %s",
alias_depth, def->name); alias_depth, def->name);
} }
if (offset_reloc) if (offset_reloc)

View File

@ -784,6 +784,12 @@ expr_alias (sblock_t *sblock, expr_t *e, operand_t **op)
*op = new_operand (op_alias); *op = new_operand (op_alias);
(*op)->type = low_level_type (e->e.expr.type); (*op)->type = low_level_type (e->e.expr.type);
sblock = statement_subexpr (sblock, e->e.expr.e1, &(*op)->o.alias); sblock = statement_subexpr (sblock, e->e.expr.e1, &(*op)->o.alias);
while ((*op)->o.alias->op_type == op_alias) {
operand_t *top = (*op)->o.alias;
(*op)->o.alias = (*op)->o.alias->o.alias;
top->type = op_symbol; // so free_operand won't follow the alias
free_operand (top);
}
return sblock; return sblock;
} }