-
Notifications
You must be signed in to change notification settings - Fork 143
Support goto
statement
#307
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
Conversation
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.
Check https://github.com/sysprog21/shecc/blob/master/CONTRIBUTING.md carefully, and you must use clang-format version 18 (not later) to indent.
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.
1 issue found across 6 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="src/lexer.c">
<violation number="1" location="src/lexer.c:88">
Adding this entry expands the keyword table to 18 elements, but NUM_KEYWORDS is still 17, so the loop stops early and the last keyword ("const") is never inserted into KEYWORD_MAP. Update NUM_KEYWORDS so all entries are registered.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Ask questions if you need clarification on any suggestion
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai
to give feedback, ask questions, or re-run the review.
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.
Read https://cbea.ms/git-commit/ and enforce the rules. In addition, append Close #280
at the end of git commit message.
Update |
f88cec8
to
dc49f7a
Compare
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.
Enforce the rules specified in How to Write a Git Commit Message:
af2c003
to
79899e0
Compare
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.
Refine git commit messages into complete English sentences that clearly describe the rationale, while supporting the 'goto' keyword.
79899e0
to
9f7ec88
Compare
c70a663
to
b99b5d3
Compare
07f313f
to
0c21eae
Compare
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.
Please resolve CI failure.
Again, please test it before pushing the remote branch for review.
0c21eae
to
0a1f2f1
Compare
0a1f2f1
to
26850c0
Compare
26850c0
to
0bea9f9
Compare
0bea9f9
to
1b2ff97
Compare
|
||
void add_label(char *name, basic_block_t *bb) | ||
{ | ||
if (label_idx > MAX_LABELS - 1) |
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.
Personally, I would prefer:
if (label_idx >= MAX_LABELS)
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.
Oh, I referred to this.
Enable parsing and analysis of C labels and goto so the compiler can accept common patterns (for example error-handling cleanup) and be more compatible with real-world C code. Provide diagnostics for duplicate, undefined, and unused labels, and warn when a goto can bypass a variable's initialization. Close sysprog21#280
1b2ff97
to
772e540
Compare
Thank @tobiichi3227 for contributing! |
Add goto and label statement support
This PR adds full support for C
goto
statements and labels, integrating them with the parser, IR/CFG, and SSA passes. This enables forward/backward jumps, error-handling patterns, and improves C compatibility (#280).Changes Made
Lexer/Parser:
T_goto
; parse goto identifier; and identifier: labels.IR/CFG:
OP_label
; update text dump and graph dump.SSA/Semantics:
Notes:
Testing
Summary by cubic
Adds C goto and label support across the lexer/parser, IR/CFG, and SSA to enable forward/backward jumps and improve C compatibility. Also adds warnings and errors around labels and unsafe jumps.