shecc
shecc copied to clipboard
struct compound literal initialization
This PR is a work-in-progress for issue #299.
- Fixes the offset bug in compound literal initialization by adjusting the source address by +4 bytes in parser.c.
- Verified with simple test: x=10, y=20, z=30 now works.
- Not final — needs feedback and further investigation.
Summary by cubic
Fix struct compound literal initialization in the parser so fields are assigned correctly instead of being shifted. Adds explicit brace-initializer emission and corrects assignment handling, addressing issue #299.
-
Bug Fixes
- Parse (struct/union T){...} and typedef structs, allocating a temp struct and writing each field.
- Add emit_struct_brace_initializer to compute field addresses and write values with correct sizes.
- On assignment from a struct literal, copy from source address +4 in 4-byte chunks to avoid the offset bug.