-
Notifications
You must be signed in to change notification settings - Fork 441
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
[#4365] Do not allow --Wdisable
or --Wwarn
to demote errors. Allow --Winfo=diagnostic
to work for diagnostic
s that can be both warnings and errors.
#4366
Conversation
kfcripps
commented
Jan 26, 2024
•
edited
Loading
edited
(I've restarted a failed |
311aaa6
to
ca79a54
Compare
--Wdisable
to disable errors.--Wdisable
or --Wwarn
to demote errors. Allow --Winfo=diagnostic
to work for diagnostic
s that can be both warnings and errors.
I went with the second approach mentioned in #4365 (comment) (and therefore reverted #4197). @dmatousek @vlstill @ajwalton Ready for review. |
f8310d1
to
ab0238b
Compare
Updated the PR based on feedback in #4365 (comment). New output for e.g.
|
ab0238b
to
bd2c6c0
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.
Do not have a strong opinion on this topic but this seems like a good change to me.
lib/error_catalog.h
Outdated
if (pair.first < ErrorType::ERR_MAX) | ||
error = true; | ||
else | ||
otherDiagnostic = true; |
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.
Just return false here? Once otherDiagnostic
is set the result is always false.
lib/error_catalog.h
Outdated
bool otherDiagnostic = false; | ||
for (const auto &pair : errorCatalog) { | ||
if (pair.second == name) { | ||
if (pair.first < ErrorType::ERR_MAX) |
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.
Just a nit, maybe also check that the value is within both ends of the error range.
@@ -231,6 +231,7 @@ class ErrorReporter { | |||
/// @return the action to take for the given diagnostic, falling back to the | |||
/// default action if it wasn't overridden via the command line or a pragma. | |||
DiagnosticAction getDiagnosticAction(cstring diagnostic, DiagnosticAction defaultAction) { | |||
if (defaultAction == DiagnosticAction::Error) return defaultAction; |
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.
Add a comment here that actions for errors can never be overridden. Maybe even return DiagnosticAction::Error
always?
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.
There is a ingnored
typo in the comment below.
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.
Maybe even return
DiagnosticAction::Error
always?
Do you mean like this:
if (defaultAction == DiagnosticAction::Error) return DiagnosticAction::Error;
What is the benefit?
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.
Well, it would make it explicit and one could not circumvent this invariant by passing in another default action. But if someone goes through the trouble of doing that they may have a reason.
// (e.g. "invalid" -> both ERR_INVALID and WARN_INVALID). | ||
bool error = false; | ||
bool otherDiagnostic = false; | ||
for (const auto &pair : errorCatalog) { |
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.
~~Also I feel like the error catalogue should be a map? But this can be done some other time. ~~
Nevermind, it is. But it is not 2-dimensional.
3c429f6
to
5c16c62
Compare
@fruffy I have implemented several of your suggestions. Please let me know if the changes look ok and I will rebase & merge this. |
…ostic is used for a diagnostic that can also be a warning.
5c16c62
to
9a5414f
Compare