-
Notifications
You must be signed in to change notification settings - Fork 444
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
Contribute DiagnosticCountInPassHook #4629
Conversation
90e367d
to
afb530b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be nice to have an example exercising this hook.
Co-authored-by: Fabian Ruffy <[email protected]>
Let me at it to P4test, the output has to be enabled anyway so it should not break anything. |
has to be activated by -TdiagnosticCountInPass:1 to run
$ ./p4c/p4test -TdiagnosticCountInPass:1 <(printf 'const bit<42> x = -4;\nconst bit<16> y = (bit<16>)x;\nvoid foo() { return 4; }')
/dev/fd/63(1): [--Wwarn=mismatch] warning: -42w4: negative value with unsigned type
const bit<42> x = -4;
^
/dev/fd/63(1): [--Wwarn=mismatch] warning: 16w4398046511100: value does not fit in 16 bits
const bit<42> x = -4;
^
PASS ConstantFolding ~> DoConstantFolding emitted 2 warnings
/dev/fd/63(3): [--Werror=type-error] error: return 4: return expression in function with void return
void foo() { return 4; }
^^^^^^
PASS FrontEnd ~> P4::TypeInference emitted 1 error |
I've further extended this to provide better info in cases like parser errors: $ ./p4c/p4test -TdiagnosticCountInPass:1 <(printf 'const bit<42> x = -4;\nconst bit<16> y = (bit<16>)x\nvoid foo() { return 4; }') /dev/fd/63(3):syntax error, unexpected VOID, expecting ;
void
^^^^
[--Werror=overlimit] error: 1 errors encountered, aborting compilation
PARSER emitted 2 errors |
Any idea what is wrong with the Fedora build?
|
It looks like Fedora GCC switched from 13 to 14 and this instruction now needs an option. |
This is the reason behind #4626. A pass manager hook that is useful for testing (p4test-like) the compiler output or just for the developers to see what passes emit diagnostic messages.
Example output (with the hook in driver added and running with
-TdiagnosticCountInPass:1
):