-
Notifications
You must be signed in to change notification settings - Fork 31
Various bug fixes #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Various bug fixes #490
Conversation
1. cc/ir/linearize.rs (lines 1748-1794): Fixed linearize_if() to use current_bb instead of allocated block IDs when linking to merge_bb, with reachability check 2. cc/ir/test_linearize.rs: Added test_nested_if_cfg_linking() which verifies that nested if-else statements produce correct CFG structure with proper parent/child relationships
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements several bug fixes and new features for the C compiler, primarily focusing on GNU extensions and improved C99 compliance. The main additions are statement expressions (({ }) syntax), __builtin_offsetof/offsetof, and various builtin function recognitions, along with fixes for nested if-else CFG linking and enhanced error checking for bitfields, for-loop declarations, and variadic functions.
Key Changes:
- Added support for GNU statement expressions and
__builtin_offsetof/offsetof - Fixed nested if-else CFG linking issues in IR linearization
- Enhanced preprocessor to recognize additional builtins (
__builtin_ctz*,__builtin_clz*,__builtin_popcount*) and report GNU extension support via__has_feature/__has_extension - Added validation and warnings for empty enums, bitfield edge cases, for-loop storage class specifiers, and variadic functions without named parameters
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| cc/token/preprocess.rs | Added builtin function names (ctz, clz, popcount, offsetof, unreachable) and implemented __has_feature/__has_extension to report statement_expressions support |
| cc/parse/parser.rs | Implemented parsing for __builtin_offsetof, statement expressions, added for-loop init declaration validation, enhanced bitfield checks, and added warnings for empty enums and variadic functions |
| cc/parse/ast.rs | Added AST nodes for StmtExpr and OffsetOf expressions with supporting OffsetOfPath enum |
| cc/ir/linearize.rs | Fixed nested if-else CFG linking bug by tracking reachable blocks correctly; added linearization for OffsetOf and StmtExpr |
| cc/ir/test_linearize.rs | Added comprehensive tests for nested control flow, switch statements, loops, goto/labels, pointer arithmetic, floating-point operations, and new features |
| cc/tests/features/stmt_expr.rs | Added integration tests for statement expressions including basic usage, nested expressions, and control flow |
| cc/tests/features/offsetof.rs | Added integration tests for offsetof with basic structs, nested members, and array indexing |
| cc/tests/features/mod.rs | Added module declarations for new test files |
| cc/tests/features/has_feature.rs | Updated tests to verify __has_builtin(offsetof) and __has_feature(statement_expressions) return true |
| cc/doc/BUILTIN.md | Documented __builtin_offsetof and offsetof in the structure layout section |
No description provided.