8000 Limit warnings about unused things by ChrisDodd · Pull Request #5239 · p4lang/p4c · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Limit warnings about unused things #5239

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ChrisDodd
Copy link
Contributor

when calling RemoveUnused it a loop, only set the 'warn' flag to true on the first iteration. This avoid wantings about things that are used, but only by unused things removed in a previous iteration.

@fruffy fruffy added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Apr 17, 2025
@ChrisDodd ChrisDodd requested review from asl, fruffy and vlstill April 28, 2025 11:41
Copy link
Contributor
@vlstill vlstill left a comment

Choose a reason for hiding this comment

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

It seems this matches behavior of clang and it makes it easier to actually see the directly unused entities. One downside could be no warnings even on removal of control-plane visible entities (if the target allows removing them), but this would only occur if the user chooses to ignore other warnings, so I am not too concerned. So overall I think this makes the compiler output better.

@ChrisDodd
Copy link
Contributor Author

I added a second change here that adds two things:

  • Warnings for declarations that are unused (these were previously not warned about)
  • Suppress warnings for things in "system" header files (core.p4 and arch files)

Having the former without the latter generates a slew of warnings from core.p4, v1model.p4, etc, but necessitates some fixes to the way the system header files are tracked, mostly to make gtests work (as they use hacked-up ways of getting the header files).

@ChrisDodd ChrisDodd requested a review from vlstill April 30, 2025 00:53
@ChrisDodd ChrisDodd changed the title Limit warnings about usused things Limit warnings about unused things May 1, 2025
ChrisDodd added 2 commits May 2, 2025 00:57
when calling RemoveUnused it a loop, only set the 'warn' flag to true
on the first iteration.  This avoid wantings about things that *are*
used, but only by unused things removed in a previous iteration.

Signed-off-by: Chris Dodd <cdodd@nvidia.com>
- supress unused warnings for thing in the arch/core p4include

Signed-off-by: Chris Dodd <cdodd@nvidia.com>
Copy link
Contributor
@vlstill vlstill left a comment

Choose a reason for hiding this comment

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

Looks good, although I did not double-check the declarations are really unused in the test outputs. Please also update the PR name.

@@ -73,7 +73,7 @@ $(BPFNAME).c: $(P4FILE)
echo "*** ERROR: Cannot find $(P4C)"; \
exit 1;\
fi;
$(P4C) --Werror $(P4INCLUDE) --target $(TARGET) -o $@ $< $(P4ARGS)
$(P4C) --Werror --Wdisable=unused $(P4INCLUDE) --target $(TARGET) -o $@ $< $(P4ARGS)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Several of the testcases contain unused actions that previously were not being warned about. With --Werror these become errors which cause the testcases to fail.

@vlstill vlstill requested a review from jafingerhut May 5, 2025 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Topics concerning the core segments of the compiler (frontend, midend, parser)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0