Op 25-08-2025 om 18:22 schreef grischka:
On 25.08.2025 09:22, Herman ten Brugge via Tinycc-devel wrote:
It looks like the extern is introducing the problem.
I found a fix for this problem as well. See attachment.
Me thinks you could have more fun if you tried to find the cause
of the problem first. Maybe you will be surprised what it is.
Maybe you can see it like this: Bugs cannot be fixed. Bugs need
to be removed. (Because a fixed bug would still be a bug, no? yes?)
Yes that is why I did not commit it.
It did fix all my problems with external and global syms in the testsuite.
The next problem is with lvalue.
See https://lists.nongnu.org/archive/html/tinycc-devel/2024-11/msg00006.html
Or:
struct test04 { unsigned int a[10]; } obj1, obj2;
(a == 5 ? obj1 : obj2).a[3] = a;
This should not modify obj1 or obj2.
I found a better solution. See below. I am still not commiting it 🙂
Herman
diff --git a/tccgen.c b/tccgen.c
index 67cf6b9..613ed50 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -1261,7 +1261,8 @@ static void patch_type(Sym *sym, CType *type)
}
} else {
- if ((sym->type.t & VT_ARRAY) && type->ref->c >= 0) {
+ if ((sym->type.t & VT_ARRAY) &&
+ sym->type.ref->c < 0 && type->ref->c >= 0) {
/* set array size if it was omitted in extern declaration */
sym->type.ref = type->ref;
}
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel