[qfcc] Fetch sum operand type early

Because component_sum works in-place, using a[i]'s type after setting
c[i] resulting in a null type and thus a segfault.
This commit is contained in:
Bill Currie 2023-08-25 17:26:09 +09:00
parent a46f9a63d2
commit e888f71f8a
2 changed files with 3 additions and 1 deletions

View file

@ -550,6 +550,7 @@ algebra_scope (type_t *type, symtab_t *curscope)
algebra_t *
algebra_get (const type_t *type)
{
type = unalias_type (type);
if (type->type == ev_invalid) {
return type->t.algebra;
} else {

View file

@ -235,8 +235,9 @@ component_sum (int op, expr_t **c, expr_t **a, expr_t **b,
if (get_type (a[i]) != get_type (b[i])) {
internal_error (a[i], "tangled multivec types");
}
auto sum_type = get_type (a[i]);
c[i] = new_binary_expr (op, a[i], b[i]);
c[i]->e.expr.type = get_type (a[i]);
c[i]->e.expr.type = sum_type;
c[i] = fold_constants (c[i]);
} else if (a[i]) {
c[i] = a[i];