This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Feature request: -Wno-unknown-warnings to silently ignore unknown warning control flags.
- From: Oren Ben-Kiki <gcc-oren at ben-kiki dot org>
- To: Andrew Pinski <pinskia at gmail dot com>
- Cc: GCC Mailing List <gcc at gcc dot gnu dot org>
- Date: Thu, 12 Oct 2017 22:41:30 +0300
- Subject: Re: Feature request: -Wno-unknown-warnings to silently ignore unknown warning control flags.
- Authentication-results: sourceware.org; auth=none
- References: <CADJiDhvpdqb3b2+pau3OWmm-x1g+VYBQ4pVTZtbRP7MJGwXvHQ@mail.gmail.com> <CA+=Sn1nr4G9fnHt_iqC_sgrfwDjdrsBC6bg+uBwLjs+9nj3CTg@mail.gmail.com>
On Thu, Oct 12, 2017 at 9:40 PM, Andrew Pinski <pinskia@gmail.com>
> -Wno-unkown-warning has already been handled silently since 4.6.0
> (which was released March 25, 2011):
> https://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Warning-Options.html
>
> When an unrecognized warning option is requested (e.g.,
> -Wunknown-warning), GCC emits a diagnostic stating that the option is
> not recognized. However, if the -Wno- form is used, the behavior is
> slightly different: no diagnostic is produced for -Wno-unknown-warning
> unless other diagnostics are being produced. This allows the use of
> new -Wno- options with old compilers, but if something goes wrong, the
> compiler warns that an unrecognized option is present.
>
True, writing -Wno-some-future-version-warning-option is silently ignored.
But -Wsome-future-version-warning-option currently generates a diagnostic
message. The proposal is to have an explicit `-Wno-unknown-warnings` flag
to suppress this diagnostic message.
The documentation uses `-Wno-unknown-warning` as an example name (instead
of saying something unwieldy like
`-Wno-some-future-version-warning-option`). There's no actual
`-Wno-unknown-warning` option.
Here is a concrete example to make this less abstract: Suppose one wants to
use `-Wsuggest-final-methods`. That's nice but versions 4.* of g++ do not
support this flag; the build tool needs to avoid specifying this command
line option if a 4.* g++ version is used.
The problem isn't specifically about this flag and version; this is just an
example; there are plenty of new useful warnings added in the recent past,
such as (partial list): `-Wnonnull-compare`, `-Wnull-dereference`,
`-Walloc-zero`, `-Wduplicated-cond`, `-Wrestrict`, ...
Thanks,
Oren.