This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: Named warnings
Why not adopt what CSS and Xt do? Have a mnemonic but heirarchical
system of naming and categorizing warnings, and let the user specify
any part of the warning to select it? That automatically segregates
the language front ends, standards, and targets; and gives us grouping
functionality. It also allows us to isolate the logic for selecting
warnings if we treat them as "just strings" (i.e. allows for future
creation of a ".gccrc"). Example:
Warnings:
std.c99.proto.missing
std.c99.proto.cast
std.c99.proto.implicit
std.c99.enum.foo
lang.c++.proto.class
lang.c.proto.implicit
Command line options (or pragmas):
-Wproto
-Wno-class (no pun intended)
-Wstd.c99
-Wno-c.proto
GCC's code would go from this:
if (warn_missing_protos)
warn ("missing prototype: %s", foo);
to this:
warn ("std.c99.proto.missing", "missing prototype: %s", foo);
Or potentially (although I don't like this idea):
warn (".proto.missing", "missing prototype: %s", foo);
(so one could say "this warning is independent of standards, langs,
etc" but let the user use -Wstd.c99 to enable/disable it, if the
warning is as listed above).
As for telling the user what the warnings are, perhaps a gcc option
"-fverbose-warnings" would add the warning spec to the warning
message?
foo.c:45: Warning: missing prototype: foo
foo.c:45: Warning[std.c99.proto.missing]: missing prototype: foo
Also, by specifying the warnings as a string in the warn() call, we
could write software to scan the sources and summarize all the
available warnings. We could even specify a comment format, to
preceed the first (or main) occurrence of a warn() call, to document
them:
/* warning[std.c99.proto.missing]
...fill in docs...
*/
We could also handle the "warning classes" (like -Wextra) in the
isolated logic for managing the warnings, perhaps
with some table like this (ignore the syntax):
std.extra = {
std.c99.enum.foo
lang.c.proto.implicit
}
So then -Wstd.extra (or just -Wextra) would enable those warnings as
if they user had listed them all.