boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

commit 1609330a4c15372a20e6e3478499d792aaf66f9e
parent 6f39189e57b48699aab8e681d4c6426219a970c0
Author: Ryan Sepassi <rsepassi@gmail.com>
Date:   Sun, 26 Apr 2026 22:36:39 -0700

cc/parse: lock in struct member store fixture (§D.2)

The §D.1 dot/arrow rewrite already covered store via cg-assign on
a cg-push-field result; this fixture adds a width-sensitive variant
(u8 fields with *10/*100 multipliers) so any future regression in
field offset or store width surfaces here, not just in §D.1.

Diffstat:
Mdocs/CC-PUNCHLIST.md | 10++++++----
Atests/cc-parse/37-struct-store.c | 15+++++++++++++++
Atests/cc-parse/37-struct-store.expected-exit | 1+
3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/docs/CC-PUNCHLIST.md b/docs/CC-PUNCHLIST.md @@ -154,10 +154,12 @@ broken. Pick one fix and document it in global lval `la`'s the label, adds `fo`, stashes via indirect slot. Parser `dot` arm replaced. -- [ ] **Struct member store** - - cg: `cc-cg/NN-struct-store.scm` - - parse: `cc-parse/NN-struct-store.c` - - Needs: same primitive plus width-correct stores from §A. +- [x] **Struct member store** + - cg: `cc-cg/37-struct-store.scm` — three u8 fields, distinct + multipliers in the readback to isolate per-field width. + - parse: `cc-parse/37-struct-store.c` + - Done: cg-push-field from §D.1 plus the width-aware store path + from §A.1. No new primitive. - [ ] **Pointer-to-struct (`p->x`)** - cg: `cc-cg/NN-arrow.scm` diff --git a/tests/cc-parse/37-struct-store.c b/tests/cc-parse/37-struct-store.c @@ -0,0 +1,15 @@ +// tests/cc-parse/37-struct-store.c — struct member store via real C +// (§D.2 of docs/CC-PUNCHLIST.md). char-typed fields exercise the +// width-correct store path; distinct multipliers in the readback +// isolate each field, so any offset/width bug yields a wrong sum. +// +// b.a=3; b.b=5; b.c=7; return (b.a + b.b*10 + b.c*100) == 753; -> 1. + +int main() { + struct B { unsigned char a; unsigned char b; unsigned char c; }; + struct B b; + b.a = 3; + b.b = 5; + b.c = 7; + return (b.a + b.b * 10 + b.c * 100) == 753; +} diff --git a/tests/cc-parse/37-struct-store.expected-exit b/tests/cc-parse/37-struct-store.expected-exit @@ -0,0 +1 @@ +1