Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kfcripps
Copy link
Contributor

@kfcripps kfcripps commented Jul 16, 2025

testdata/p4_16_samples_outputs/issue5331_srcinfo.p4 got removed in #5334 (the explicit cast warning got removed and I didn't have another test case for #5333 at that time). Now I've found a new slightly different test case for #5333, so I'm adding it back.

@kfcripps kfcripps requested review from ChrisDodd and asl July 16, 2025 22:33
Copy link
Contributor

@ChrisDodd ChrisDodd left a comment

Choose a reason for hiding this comment

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

Looks like this testcase shows there's still room for improving the warning message

@@ -0,0 +1,3 @@
issue5331_srcinfo.p4(4): [--Wwarn=overflow] warning: x << 18: shifting value with 16 bits by 18
__e(y);
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't the clearest warning, but it is not clear what should in it -- the 18 comes from inlining and constant folding a call, so there are multiple places in the code that are relevant. At the very least, though, it should identify the point in the code that has the shift (line 8)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before #5333, the warning looked like this:

tmp.p4(8): [--Wwarn=overflow] warning: x << 18: shifting value with 16 bits by 18
        a3(x << (9 + y));
           ^^^^^^^^^^^^

Should #5333 actually be propagating the source info of the argument?

Copy link
Contributor

Choose a reason for hiding this comment

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

That is definitely better, so maybe #5333 should be doing less. The source info on the shift operation itself should not be changing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe #5333 should only copy the source info if it is not already set to something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@asl Please comment

@kfcripps kfcripps added this pull request to the merge queue Jul 17, 2025
Merged via the queue into p4lang:main with commit bd618c5 Jul 17, 2025
22 checks passed
@kfcripps kfcripps deleted the 5331-srcinfo-testcase branch July 17, 2025 01:26
@fruffy fruffy added the infrastructure Topics related to code style and build and test infrastructure. label Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure Topics related to code style and build and test infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants