diff options
| author | 2026-04-13 09:45:28 +0200 | |
|---|---|---|
| committer | 2026-04-13 09:45:28 +0200 | |
| commit | b9de0c34a285aa0e3a7cfffb542732819adafd61 (patch) | |
| tree | 55d54912f64f521da36240167934287ec26a4ee4 /test | |
| parent | db576fab9f4eed8591c332d8353eed26c517ff36 (diff) | |
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.
Diffstat (limited to 'test')
| -rw-r--r-- | test/20-empty.c | 28 |
1 files changed, 28 insertions, 0 deletions
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)); +} + |