[qfcc] Unalias types before checking for equality

Fixes a bogus redefinition when going from struct declaration to
typedef.
This commit is contained in:
Bill Currie 2021-12-22 00:19:36 +09:00
parent f1d097c0c4
commit bdc9e9c39f
3 changed files with 11 additions and 1 deletions

View file

@ -181,6 +181,7 @@ int is_func (const type_t *type) __attribute__((pure));
int is_string (const type_t *type) __attribute__((pure)); int is_string (const type_t *type) __attribute__((pure));
int type_compatible (const type_t *dst, const type_t *src) __attribute__((pure)); int type_compatible (const type_t *dst, const type_t *src) __attribute__((pure));
int type_assignable (const type_t *dst, const type_t *src); int type_assignable (const type_t *dst, const type_t *src);
int type_same (const type_t *dst, const type_t *src) __attribute__((pure));
int type_size (const type_t *type) __attribute__((pure)); int type_size (const type_t *type) __attribute__((pure));
void init_types (void); void init_types (void);

View file

@ -529,7 +529,7 @@ initialize_def (symbol_t *sym, expr_t *init, defspace_t *space,
reloc_t *relocs = 0; reloc_t *relocs = 0;
if (check && check->table == current_symtab) { if (check && check->table == current_symtab) {
if (check->sy_type != sy_var || check->type != sym->type) { if (check->sy_type != sy_var || !type_same (check->type, sym->type)) {
error (0, "%s redefined", sym->name); error (0, "%s redefined", sym->name);
} else { } else {
// is var and same type // is var and same type

View file

@ -1066,6 +1066,15 @@ type_assignable (const type_t *dst, const type_t *src)
return 0; return 0;
} }
int
type_same (const type_t *dst, const type_t *src)
{
dst = unalias_type (dst);
src = unalias_type (src);
return dst == src;
}
int int
type_size (const type_t *type) type_size (const type_t *type)
{ {