You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously, array compound literals such as (int[]){100, 200, 300}
failed with an "Unexpected token" error. Struct compound literals
worked correctly, but array syntax [] was unhandled in the parser.
This change adds proper array compound literal handling, including
scalar and pointer contexts. In scalar context, the literal returns
its first element (e.g. int x = (int[]){100,200}; yields 100). In
pointer context, it allocates and initializes backing storage and
returns the address (e.g. int *p = (int[]){100,200};). Arithmetic
expressions using literals (e.g. 50 + (int[]){100}) also evaluate
correctly.
Additional fixes include:
- Consume missing '{' token for int/char compound literals
- Add return statements to prevent control flow fall-through
- Prevent segfaults in pointer assignments by allocating memory
As a result, shecc now supports array compound literals alongside
existing struct compound literals, improving C99 compatibility and
preserving self-hosting capability.
Known limitations remain: designated initializers and complex
expression combinations are still unsupported.
0 commit comments