From 9610788deac044bae7d8dd68762ae390a368c7e7 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 19 Feb 2020 19:16:07 +0900 Subject: [PATCH] Fix some more type aliasing issues Getting there... (I knew this would be a big job) --- tools/qfcc/source/expr.c | 8 ++++---- tools/qfcc/source/qc-parse.y | 2 ++ tools/qfcc/source/type.c | 7 +++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index 691a03162..da96bd5fc 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -1138,9 +1138,9 @@ append_expr (expr_t *block, expr_t *e) } static symbol_t * -get_struct_field (type_t *t1, expr_t *e1, expr_t *e2) +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; @@ -1159,12 +1159,12 @@ get_struct_field (type_t *t1, expr_t *e1, expr_t *e2) expr_t * field_expr (expr_t *e1, expr_t *e2) { - type_t *t1, *t2; + const type_t *t1, *t2; expr_t *e; if (e1->type == ex_error) return e1; - t1 = get_type (e1); + t1 = unalias_type (get_type (e1)); if (t1->type == ev_entity) { symbol_t *field = 0; diff --git a/tools/qfcc/source/qc-parse.y b/tools/qfcc/source/qc-parse.y index 4773eb303..e64bb748e 100644 --- a/tools/qfcc/source/qc-parse.y +++ b/tools/qfcc/source/qc-parse.y @@ -422,6 +422,7 @@ external_decl if (spec.is_typedef) { error (0, "typedef %s is initialized", $1->name); $1->sy_type = sy_type; + $1->type = alias_type ($1->type, $1->name); symtab_addsymbol (current_symtab, $1); } else { initialize_def ($1, $2, current_symtab->space, spec.storage); @@ -435,6 +436,7 @@ external_decl $1->type = find_type (append_type ($1->type, spec.type)); if (spec.is_typedef) { $1->sy_type = sy_type; + $1->type = alias_type ($1->type, $1->name); symtab_addsymbol (current_symtab, $1); } else { $1 = function_symbol ($1, spec.is_overload, 1); diff --git a/tools/qfcc/source/type.c b/tools/qfcc/source/type.c index 2aff5c5d1..2c3064405 100644 --- a/tools/qfcc/source/type.c +++ b/tools/qfcc/source/type.c @@ -897,8 +897,11 @@ type_assignable (const type_t *dst, const type_t *src) if (ret >= 0) return ret; - dst = dst->t.fldptr.type; - src = src->t.fldptr.type; + dst = unalias_type (dst->t.fldptr.type); + src = unalias_type (src->t.fldptr.type); + if (dst == src) { + return 1; + } if (is_void (dst)) return 1; if (is_void (src))