From a6003ed08a8e82a5c4d4766c668f0132d099a4b3 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 19 Feb 2020 21:04:45 +0900 Subject: [PATCH] Walk qfo alias chain for type size and alignment While the basic type is stored in the alias type record, it's no good for size or alignment as it will give incorrect results for complex types. --- tools/qfcc/source/obj_file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/qfcc/source/obj_file.c b/tools/qfcc/source/obj_file.c index e49d64c46..803f9995c 100644 --- a/tools/qfcc/source/obj_file.c +++ b/tools/qfcc/source/obj_file.c @@ -677,10 +677,10 @@ get_type_size (qfo_t *qfo, pointer_t type) type_def = QFO_POINTER (qfo, qfo_type_space, qfot_type_t, type); switch ((ty_meta_e)type_def->meta) { case ty_alias: + return get_type_size (qfo, type_def->t.alias.aux_type); case ty_none: // field, pointer and function types store their basic type in // the same location. - // alias types store the basic type at the end of the alias chain return pr_type_size[type_def->t.type]; case ty_struct: for (i = size = 0; i < type_def->t.strct.num_fields; i++) @@ -726,11 +726,11 @@ get_type_alignment_log (qfo_t *qfo, pointer_t type) return 0; type_def = QFO_POINTER (qfo, qfo_type_space, qfot_type_t, type); switch ((ty_meta_e)type_def->meta) { - case ty_none: case ty_alias: + return get_type_alignment_log (qfo, type_def->t.alias.aux_type); + case ty_none: // field, pointer and function types store their basic type in // the same location. - // alias types store the basic type at the end of the alias chain return qfo_log2 (ev_types[type_def->t.type]->alignment); case ty_struct: case ty_union: