Conversation
Serialize tests that modify COLUMNS/LINES env vars with a mutex, preventing race conditions when tests run in parallel. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
linearize_init_list_at_offset() used the element enumeration index for
positional field lookup instead of a counter that advances past
designated fields. This caused {.b = 20, 30, 40} to store 30 at field
b's offset instead of field c's. Apply the same current_field_idx
pattern already used in the global init handler (ast_init_list_to_ir).
Fix applies to both struct and array branches of the local init handler.
Add unit tests for both struct and array mixed designated+positional
init, plus a comprehensive 8-section integration torture test covering
function pointers, self-referencing structs, anonymous members, large
structs, nested structs, compound literals, and more.
Move cc-specific testing rules from root CLAUDE.md to cc/CLAUDE.md.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…thon compatibility improvements va_list fixes: - Add is_indirect flag to LocalVarInfo for va_list parameters - va_list params store pointer (8 bytes) not struct (24 bytes) due to array decay - linearize_lvalue loads pointer for indirect locals - linearize_ident handles va_list expression decay for indirect params - Fix emit_va_copy temp register collision when dst_reg is RAX Return type conversion: - Fix return statements to convert expression type to function return type - Ensures 'return -1' in long long function sign-extends correctly Other fixes: - Separate PIE mode from shared library mode for TLS model selection - Fix atomic CAS register clobbering via red zone spilling - Fix large struct member access to return address instead of loading - Add symbol table mutability for array size inference from initializers - Disable SSE intrinsics headers (not yet supported) Tests: - Add unit tests for va_list parameter handling - Add e2e tests for return type conversion, va_list cast - Add PIE/PIC codegen tests - All 62 tests pass
x86_64:
- Fix incorrect operand size (B32 vs actual arg size) when storing
va_arg results to stack locations - caused 64-bit pointers to be
truncated
- Fix missing stack offset adjustment (callee_saved_offset and negation)
when storing to stack - caused stores to wrong locations
aarch64:
- Fix hardcoded B64 size in va_arg stack store to use actual op_size
These bugs were exposed by CPython's Py_BuildValue("(ssss)", ...) which
passes string pointers through a va_list to helper functions, causing
register pressure and stack spills.
Add e2e test for va_arg with string pointers passed through va_list*.
There was a problem hiding this comment.
Pull request overview
This PR updates the cc (pcc) compiler and its test suite to improve GCC/CPython compatibility and fix several correctness issues across parsing, IR linearization, and x86_64 codegen.
Changes:
- Add/extend GCC-compat CLI flag handling (PIE/
-no-pie, linker flag passthrough, reject unsupported-m*) and corresponding integration/unit tests. - Fix/extend initializer handling (incomplete array size inference with designators; better designated/positional init handling; bitfield init packing; compound literal zero-init) and add regression tests.
- Improve codegen/ABI correctness (return type conversion, va_list parameter decay handling, large-aggregate copies, atomic CAS reg-clobber fix, TLS model selection refinements).
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| editors/vi/ui/terminal.rs | Serialize env-var-mutating tests with a global lock. |
| cc/token/preprocess.rs | Centralize __has_attribute supported-attribute list. |
| cc/main.rs | Add PIE/linker passthrough/unsupported -m* flag handling and tests; adjust codegen creation args. |
| cc/arch/codegen.rs | Extend codegen factory/trait with shared-mode flag. |
| cc/arch/x86_64/codegen.rs | Refine GOT/TLS behavior; fix atomic CAS operand clobbering; add shared-mode support. |
| cc/arch/x86_64/features.rs | Fix stack offset handling and temp-reg usage in varargs/TLS helpers. |
| cc/arch/x86_64/float.rs | Fix stack offset handling for FP moves. |
| cc/arch/aarch64/features.rs | Fix store size selection. |
| cc/arch/aarch64/codegen.rs | Implement set_shared_mode as a no-op placeholder. |
| cc/parse/parser.rs | Infer incomplete array sizes using max designator index; update bound symbol types post-inference. |
| cc/parse/expression.rs | Use shared array-size inference for compound literals with incomplete array types. |
| cc/symbol.rs | Add SymbolTable::get_mut for updating bound symbol entries. |
| cc/ir/linearize.rs | Major initializer/codegen correctness work: designator chains, bitfields, va_list decay, large-aggregate copies, return conversions, purity rules. |
| cc/parse/test_parser.rs | Add unit tests for array-size inference with designator initializers. |
| cc/ir/test_linearize.rs | Add extensive regression tests for init/designators/bitfields/va_list/large copies/conditional short-circuiting. |
| cc/tests/* | Add CPython-focused and multiple new codegen/C99/C89/builtin integration tests. |
| cc/include/xmmintrin.h / emmintrin.h | Hard-error out on unsupported SSE/SSE2 intrinsics. |
| cc/CLAUDE.md | Add cc-specific testing rules doc. |
| CLAUDE.md | Remove duplicated cc-specific test checklist items from root doc. |
Gate RIP-relative addressing test to x86_64 only, and replace system header includes with minimal forward declarations in compound literal test to avoid platform-specific header parse failures. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.