Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the front-end to evaluate and enforce _Static_assert at CIL-time (including inside structs), and adds regression tests for passing/failing asserts.
Changes:
- Represent struct members as a richer
struct_declAST to include_Static_assertinside struct/union bodies. - Evaluate
_Static_assertexpressions during CABS→CIL conversion and error out on failure / non-constant conditions. - Add new regression tests for failing
_Static_assertcases (global/local/struct).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
test/testcil.pl |
Registers new failing _Static_assert tests in the C11 run suite. |
test/small1/c11-static-assert.c |
Expands the passing static-assert coverage (including message-less form). |
test/small1/c11-static-assert-fail1.c |
New failing global _Static_assert test. |
test/small1/c11-static-assert-fail2.c |
New failing local _Static_assert test. |
test/small1/c11-static-assert-fail3.c |
New failing struct-member _Static_assert test. |
src/frontc/cabs.ml |
Adds struct_decl node and makes _Static_assert message optional. |
src/frontc/cparser.mly |
Parses struct-member _Static_assert and supports C23 message-less form. |
src/frontc/cabsvisit.ml |
Visits the new struct_decl AST shape and _Static_assert expressions. |
src/frontc/cabs2cil.ml |
Enforces _Static_assert by constant-folding and erroring on failure. |
src/frontc/cprint.ml |
Prints _Static_assert with optional message, including inside structs. |
src/frontc/patch.ml |
Updates patch unification to account for struct_decl nodes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…e in struct_decl_list Already handled by base case. Also allowed static_assert_declaration without semicolon, which is wrong.
Static asserts always end with one.
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.
Closes #65.
This makes it much easier to write some tests, e.g. for #207.