Skip to content
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

Fixed start state renaming for p4-14 translation using @packet_entry #3348

Merged
merged 4 commits into from
May 24, 2022

Conversation

MichalKekely
Copy link
Contributor

The issue was that if there was a transition into the start state (for example from one of the @packet_entry states) and @packet_entry used, the compiler renamed the original start state to replace it with a new one. However these transitions into the original start state were not renamed.

* The issue was that if there was a transition into the start state
  (for example from one of the @packet_entry states) and @packet_entry
  used, the compiler renamed the original start state to replace it with
  a new one. However these transitions into the original start state
  were not renamed.
@@ -759,6 +759,18 @@ class InsertCompilerGeneratedStartState: public Transform {
return state;
}

// Rename any path refering to original start state
const IR::Node* postorder(IR::Path* path) override {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this also rename a variable reference if the variable is named "start"?
To be safe this should check the parent context to be a SelectCase, and moreover this to be the child #1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to explicitly check if the path that is being changed is either within:
ParserState->selectExpression<PathExpression>->path
Or:
SelectCase->state<PathExpression>->path

@mihaibudiu mihaibudiu merged commit c609161 into main May 24, 2022
@mihaibudiu mihaibudiu deleted the mkekely/fix_packet_entry_to_start branch May 24, 2022 16:51
github-sajan pushed a commit to github-sajan/p4c that referenced this pull request May 26, 2022
…4lang#3348)

* Fixed start state renaming for p4-14 translation using  @packet_entry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants