From 80bef6162aac355227242fc8b8cb4610df7cd75d Mon Sep 17 00:00:00 2001 From: herman ten brugge Date: Sun, 3 Aug 2025 10:29:16 +0200 Subject: [PATCH] Unshare typedef definitions if it used more then once. --- tccgen.c | 2 +- tests/tcctest.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tccgen.c b/tccgen.c index c25a2243..145d88de 100644 --- a/tccgen.c +++ b/tccgen.c @@ -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'", diff --git a/tests/tcctest.c b/tests/tcctest.c index efc31e26..9f920777 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -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};