[qfcc] Put the stack frame exprs into the statements block

dot_expr doesn't follow an expression's next pointer on its own.
make_statements was fine, which is why I didn't notice the mistake until
now.
This commit is contained in:
Bill Currie 2022-01-24 16:44:48 +09:00
parent 739c98fe21
commit 9fc8f14be6
2 changed files with 24 additions and 4 deletions

View file

@ -1419,6 +1419,28 @@ append_expr (expr_t *block, expr_t *e)
return block;
}
expr_t *
prepend_expr (expr_t *block, expr_t *e)
{
if (block->type != ex_block)
internal_error (block, "not a block expression");
if (!e || e->type == ex_error)
return block;
if (e->next)
internal_error (e, "append_expr: expr loop detected");
e->next = block->e.block.head;
block->e.block.head = e;
if (block->e.block.tail == &block->e.block.head) {
block->e.block.tail = &e->next;
}
return block;
}
static symbol_t *
get_struct_field (const type_t *t1, expr_t *e1, expr_t *e2)
{

View file

@ -677,16 +677,14 @@ build_code_function (symbol_t *fsym, expr_t *state_expr, expr_t *statements)
if (options.code.progsversion == PROG_VERSION) {
expr_t *e;
e = new_with_expr (2, LOCALS_REG, new_short_expr (0));
e->next = statements;
e->file = func->def->file;
e->line = func->def->line;
statements = e;
prepend_expr (statements, e);
e = new_adjstk_expr (0, 0);
e->next = statements;
e->file = func->def->file;
e->line = func->def->line;
statements = e;
prepend_expr (statements, e);
func->temp_reg = LOCALS_REG;
for (def_t *def = func->locals->space->defs; def; def = def->next) {