[qfcc] Update switch tables for compound initializers

Forgot to do a full test build (Machine.r found it)
This commit is contained in:
Bill Currie 2020-03-11 23:52:12 +09:00
parent 5d349efe78
commit e4caf50ee1
3 changed files with 9 additions and 5 deletions

View file

@ -371,6 +371,8 @@ init_elements (struct def_s *def, expr_t *eles)
dummy.offset = def->offset + element->offset;
g = D_POINTER (pr_type_t, &dummy);
if (c->type == ex_labelref) {
// reloc_def_* use only the def's offset and space, so dummy
// is ok
reloc_def_op (c->e.labelref.label, &dummy);
continue;
} else if (c->type == ex_value) {

View file

@ -536,7 +536,7 @@ statement_get_targetlist (statement_t *s)
sblock_t **target_list;
int count = 0, i;
def_t *table = 0;
expr_t *e;
element_t *e;
if (statement_is_cond (s)) {
count = 1;
@ -555,9 +555,9 @@ statement_get_targetlist (statement_t *s)
} else if (statement_is_jumpb (s)) {
if (table->alias)
internal_error (0, "aliased jump table");
e = table->initializer->e.block.head; //FIXME check!!!
e = table->initializer->e.compound.head; //FIXME check!!!
for (i = 0; i < count; e = e->next, i++)
target_list[i] = e->e.labelref.label->dest;
target_list[i] = e->expr->e.labelref.label->dest;
}
return target_list;
}

View file

@ -337,11 +337,13 @@ build_switch (expr_t *sw, case_node_t *tree, int op, expr_t *sw_val,
const char *table_name = new_label_name ();
int i;
expr_t *range = binary_expr ('-', tree->high, tree->low);
expr_t *label;
table_init = new_block_expr ();
table_init = new_compound_init ();
for (i = 0; i <= high - low; i++) {
tree->labels[i]->e.label.used++;
append_expr (table_init, address_expr (tree->labels[i], 0, 0));
label = address_expr (tree->labels[i], 0, 0);
append_element (table_init, new_element (label, 0));
}
table_sym = new_symbol_type (table_name,
array_type (&type_integer,