support local union, struct, and enum declarations inside functions#363
Open
paulboul1013 wants to merge 1 commit intozenc-lang:mainfrom
Open
support local union, struct, and enum declarations inside functions#363paulboul1013 wants to merge 1 commit intozenc-lang:mainfrom
paulboul1013 wants to merge 1 commit intozenc-lang:mainfrom
Conversation
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.
Description
This PR adds support for local
struct,union, andenumdeclarations inside function and block scope, includingmain().Before this change, Zen C already supported these declarations at top level, but
parse_statement(...)did not recognize them in statement position. That meant code such as local type declarations insidemain()or other function bodies could not be parsed correctly even though the rest of the pipeline already had supporting pieces for handling these nodes.This change updates statement parsing so local
struct,union, andenumdeclarations are accepted inside blocks. It also assigns source tokens to the generated struct/enum AST nodes so debug/source-mapping mode does not emit source mapping warnings for these local declarations.A regression test was added to cover local type declarations in the source-mapping/codegen path.
Type of change
Checklist:
Validation
makebash tests/scripts/run_codegen_tests.sh./zc check tests/compiler/codegen/emit_source_mapping.zc -g --warn-errors