I'm working on an implementation for part of the #pragma warning from Visual C++. An example is below:
// regular code here
// Coming across safe code that triggers warnings at level 4
// code that triggers warnings at level 4
// silenced because we set the level to 3 above
The effect of this is to set the global warning level to be 3 for some portion of the file. Each global warning level has associated warnings, kind of like the -Wall and -Wextra parameters. So when the global warning level is 3, only those warnings that have a level <= 3 will be enabled.
The implementation that I am proposing is:
* Have all warnings default to level 1
* Map individual warnings to higher levels via a new mixin in Diagnostic.td
* Add a "current level" to the DiagState class
* Modify DiagState so that the warning level filters out warnings that should be ignored
The attached patch contains a first go. The way it is constructed at the moment, all warnings will be enabled as they are at level 1 and the "current level" defaults to 4.
Also note that the patch contains diffs against some more local changes. I hope that there is still enough context.
The important files in the diff (imo):
I look forward to your comments.
Thanks for your time!
pragma-warning-level.patch (15.1 KB)