[qfcc] Fix some type aliasing bugs

I have no idea why sorting out expression aliasing exposed these type
aliasing bugs, but it did. All tests *build* again (and pass).
This commit is contained in:
Bill Currie 2022-01-08 12:10:30 +09:00
parent 23c9a317f8
commit da210db720

View file

@ -1350,7 +1350,7 @@ append_expr (expr_t *block, expr_t *e)
static symbol_t *
get_struct_field (const type_t *t1, expr_t *e1, expr_t *e2)
{
symtab_t *strct = t1->t.symtab;
symtab_t *strct = unalias_type(t1)->t.symtab;
symbol_t *sym = e2->e.symbol;//FIXME need to check
symbol_t *field;
@ -1375,7 +1375,7 @@ field_expr (expr_t *e1, expr_t *e2)
t1 = get_type (e1);
if (e1->type == ex_error)
return e1;
if (t1->type == ev_entity) {
if (is_entity (t1)) {
symbol_t *field = 0;
if (e2->type == ex_symbol)
@ -1395,7 +1395,8 @@ field_expr (expr_t *e1, expr_t *e2)
return e;
}
}
} else if (t1->type == ev_pointer) {
} else if (is_pointer (t1)) {
t1 = unalias_type (t1);
if (is_struct (t1->t.fldptr.type)) {
symbol_t *field;
@ -1423,8 +1424,7 @@ field_expr (expr_t *e1, expr_t *e2)
e->e.expr.type = pointer_type (ivar->type);
return unary_expr ('.', e);
}
} else if (t1->type == ev_vector || t1->type == ev_quat
|| is_struct (t1)) {
} else if (is_vector (t1) || is_quaternion(t1) || is_struct (t1)) {
symbol_t *field;
field = get_struct_field (t1, e1, e2);
@ -2292,7 +2292,7 @@ array_expr (expr_t *array, expr_t *index)
ind = expr_short (index);
if (is_integer_val (index))
ind = expr_integer (index);
if (array_type->t.func.num_params
if (is_array (array_type)
&& is_constant (index)
&& (ind < array_type->t.array.base
|| ind - array_type->t.array.base >= array_type->t.array.size))
@ -2715,7 +2715,7 @@ cast_expr (type_t *dstType, expr_t *e)
dstType = (type_t *) unalias_type (dstType); //FIXME cast
srcType = get_type (e);
if (dstType == srcType)
if (dstType == unalias_type(srcType))
return e;
if ((dstType == type_default && is_enum (srcType))