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

No error for extern objects with constructor name matching a different type #435

Closed
jafingerhut opened this issue Apr 5, 2017 · 3 comments

Comments

@jafingerhut
Copy link
Contributor

Happened across this while puzzling through what TYPE meant in the grammar rule for constructor method declarations. I don't think this is a high priority issue, but wanted to file one in case someone else thought it was worth a change in the compiler. See comments inside myExtern1 in the attached program.
wrong-constructor-name.p4.txt

@jafingerhut
Copy link
Contributor Author

Additional comment/question -- the latest P4_16 draft spec says: "Extern declarations can only appear in architecture model libraries specific to a target." p4c doesn't seem to enforce this. Does that statement look correct?

If architecture model libraries are in #include files, it doesn't seem like there is even a very straightforward way for the compiler to enforce that restriction?

@mihaibudiu
Copy link
Contributor

Indeed, the compiler cannot enforce this.
We may want to remove this phrase from the spec; Netronome has this use for extern declarations where they indicate user-supplied functions in C which are linked to the P4 program. In this case users can write new extern declarations. Maybe we should add a special annotations to indicate to the back-end that it does not need to understand them.

@jafingerhut
Copy link
Contributor Author

Confirmed that the test case now gives an error message for the thing that looks like a constructor, but has a different type name than the extern object it is within. Thanks, Mihai.

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

No branches or pull requests

2 participants