From b9de0c34a285aa0e3a7cfffb542732819adafd61 Mon Sep 17 00:00:00 2001 From: lemon Date: Mon, 13 Apr 2026 09:45:28 +0200 Subject: frontend: accept zero size arrays and empty aggregates GNU extension. Previously was overloading arraylength==0 to mean unsized array, now they are distinct with the type flag TFUNKNOWN marking unsized arrays & aggregates. --- test/20-empty.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/20-empty.c (limited to 'test') diff --git a/test/20-empty.c b/test/20-empty.c new file mode 100644 index 0000000..2926185 --- /dev/null +++ b/test/20-empty.c @@ -0,0 +1,28 @@ +/* EXPECT: +sizeof (struct empty) === 0 +sizeof bleh[1] === 0 +sizeof (struct flx0) == sizeof (int) === 1 +sizeof (a) === 0 +sizeof (aa) === 0 +*/ + +void f(){} + +struct empty {}; +extern struct empty bleh[10]; +struct flx0 { int t; int m[0]; }; + +int main() { + int a[] = {}; + int aa[][0] = {}; + struct empty empty = {}; + + extern int printf(const char *, ...); +#define P(x) printf(#x" === %d\n", (int)x) + P(sizeof (struct empty)); + P(sizeof bleh[1]); + P(sizeof (struct flx0) == sizeof (int)); + P(sizeof (a)); + P(sizeof (aa)); +} + -- cgit v1.2.3