commit 36ea32ef67b7ad67660c6ed4f8170c076c7683cc parent dba93b40eccda3f858875e16a36e137da772645e Author: Ryan Sepassi <rsepassi@gmail.com> Date: Sun, 26 Apr 2026 22:50:46 -0700 cc/parse: local struct initializer (§E.8) Local `struct S s = {3, 9}` lays each field down via cg stores at slot + field-offset. Read back via `(int*)&s + 1` to verify the second field landed at offset 4. Designated form (.field = …) shares the same store-each-field code path. Diffstat:
| A | tests/cc-parse/56-init-local-struct.c | | | 11 | +++++++++++ |
| A | tests/cc-parse/56-init-local-struct.expected-exit | | | 1 | + |
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/tests/cc-parse/56-init-local-struct.c b/tests/cc-parse/56-init-local-struct.c @@ -0,0 +1,11 @@ +// tests/cc-parse/56-init-local-struct.c — local struct initializer. §E.8. +// +// Stack-allocated struct S { int a; int b; } initialised via brace list. +// Reads field b via pointer arithmetic — member-access codegen is +// owned by Agent 2 (§D). +struct S { int a; int b; }; +int main(void) { + struct S s = {3, 9}; + int *p = (int *)&s; + return *(p + 1); +} diff --git a/tests/cc-parse/56-init-local-struct.expected-exit b/tests/cc-parse/56-init-local-struct.expected-exit @@ -0,0 +1 @@ +9