This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Suppressing specific compiler warnings


Matt Austern <austern@apple.com> writes:

> My claim is that, as things stand now, warnings do not have names.
> The characteristics that I claim names should have:
>   - Names should be brief tags.  I claim that brevity and uniformity
>   are more important than looking friendly as English text: maybe
>   something like 'iafter' for this one, for example.
>   - Names should be printed as part of the warning text.
>   - Names should appear in the index of the documentation.  That way,
>   a user who sees a warning message can look it up by name and get
>   more detailed information on what it means.
>   - Names should be used in command-line options and pragmas in a
>   uniform way.  That way, a user who sees a warning message can
>   immediately know how to enable and disable it.
>   - Names should be stable from release to release, even if the text
>   of the warning varies.

This is pretty much exactly what the DEC/Compaq/whatever it's called
today compiler does. Example:

falk@juist:/tmp% cat test.c
f() {
    char a, x[2];
    x[2] = a++ + a++;
}
falk@juist:/tmp% ccc -O -c -W -Wall test.c
cc: Info: test.c, line 1: The declaration of the function f has an empty parameter list.  If the function has parameters, they should be declared here; if it has no parameters, "void" should be specified in the parameter list. (noparmlist)
f() {
^
cc: Info: test.c, line 3: In this statement, an array is being accessed outside the bounds specified for the array type. (subscrbounds)
    x[2] = a++ + a++;
------^
cc: Warning: test.c, line 3: In this statement, the expression "x[2]=a+++a++" modifies the variable "a" more than once without an intervening sequence point.  This behavior is undefined. (undefvarmod)
    x[2] = a++ + a++;
----^
cc: Info: test.c, line 1: Non-void function "f" with implicit return type int does not contain a return statement. (impfncmssngret)
f() {
^
cc: Info: test.c, line 4: The last statement in non-void function "f" is not a return statement. (impfncfalloff)
}
^

You can for example turn off a warning with -msg_disable noparmlist,
or make it fatal with -msg_fatal noparmlist. Works quite well IMHO.

-- 
	Falk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]