[qfcc] Take special care when aliasing aliased types

When aliasing a type that already has aliases, the top node needs to be
replaced if it is unnamed, or the alias-free branch of the new node
needs to reach around to the alias-free branch of the existing node.
This fixes the bogus param counts in qwaq.
This commit is contained in:
Bill Currie 2020-03-29 11:29:15 +09:00
parent 78962cb205
commit 218cca71b8
2 changed files with 12 additions and 1 deletions

View file

@ -248,7 +248,8 @@ get_type (expr_t *e)
type = e->e.symbol->type;
break;
case ex_temp:
return e->e.temp.type;
type = e->e.temp.type;
break;
case ex_value:
type = e->e.value->type;
break;

View file

@ -529,6 +529,16 @@ alias_type (type_t *type, type_t *alias_chain, const char *name)
alias->meta = ty_alias;
alias->type = type->type;
alias->alignment = type->alignment;
if (type == alias_chain && type->meta == ty_alias) {
// typedef of a type that contains a typedef somewhere
// grab the alias-free branch for type
type = alias_chain->t.alias.aux_type;
if (!alias_chain->name) {
// the other typedef is further inside, so replace the unnamed
// alias node with the typedef
alias_chain = alias_chain->t.alias.full_type;
}
}
alias->t.alias.aux_type = type;
alias->t.alias.full_type = alias_chain;
if (name) {