Unshare typedef definitions if it used more then once.

This commit is contained in:
herman ten brugge 2025-08-03 10:29:16 +02:00
parent 8a0ccbbd94
commit 80bef6162a
2 changed files with 5 additions and 1 deletions

View File

@ -1253,7 +1253,7 @@ static void patch_type(Sym *sym, CType *type)
} else {
if ((sym->type.t & VT_ARRAY) && type->ref->c >= 0) {
/* set array size if it was omitted in extern declaration */
sym->type.ref->c = type->ref->c;
sym->type.ref = type->ref;
}
if ((type->t ^ sym->type.t) & VT_STATIC)
tcc_warning("storage mismatch for redefinition of '%s'",

View File

@ -1767,9 +1767,13 @@ struct complexinit2 cix22 = {
};
typedef int arrtype1[];
arrtype1 sinit19;
arrtype1 sinit20;
arrtype1 sinit19 = {1};
arrtype1 sinit20 = {2,3};
typedef int arrtype2[3];
arrtype2 sinit21;
arrtype2 sinit22;
arrtype2 sinit21 = {4};
arrtype2 sinit22 = {5,6,7};