[PATCH] PR 28322 unknown -Wno-* options should cause warnings, not errors

Ian Jackson ijackson@chiark.greenend.org.uk
Thu Jun 5 14:05:00 GMT 2008


Ralf Wildenhues writes ("Re: [PATCH] PR 28322 unknown -Wno-* options should cause warnings, 	not errors"):
> Peter Maydell wrote on Tue, Jun 03, 2008 at 11:45:49PM CEST:
> > You'll only get a warning about an unrecognised -Wno-* if you were going
> > to get some other warning anyway.
> 
> For a configure test, that's even worse!
> 
> How do you write a configure test to find out whether a compiler flag
> (given to you by an innocent user, so it might be a warning flag, or
> whatnot) is actually accepted by the compiler?

With this patch, the intent is that all -Wno-* options are accepted by
the compiler.  So you don't need to test for them - just pass them
regardless.

(If you want to support pre-fix gccs you still need to test but you
can do that in the usual way, because they'll reject them.)

> I can; but my concerns are rather about Autoconf macros which are
> generally useful, like: a macro to check whether a given flag passed to
> it by an innocent user is accepted by the compiler.

For -Wno-*, it is fine for this test to always succeed.

(The bug that Peter Maydell is reporting at the head of this thread is
that -Wno-foobar sometimes changes the exit status from 0 to 1, which
is wrong; the buggy version does indeed cause problems of this kind
for autoconf as well as for the primary situation where it is
relevant.  Peter's fix should be applied.)

> If GCC want's to accept all of -Wno-*, then heck, it should do that
> silently, all the time.  But it should tell its users in changes.html
> that no typo-correction is made available for those flags any more.

That's exactly what this change does (well, what it will do when
Peter's updated change is accepted).

_But_ it has the additional feature that _if_ there are some warnings
emitted which might have been suppressed by -Wno-* options which
weren't recognised, you get a separate note to stderr about it.  That
means you do get the benefit of some typo detection in the usual case
where the -Wno-foobar option is added by a user directly to suppress
an actual warning.

It's true that you don't get typo-correction if you're relying on
autoconf to tell you whether the -Wno-foobar option you've just added
to _your_ gcc in your tree, to suppress a warning that _someone else_
is seeing.  But in that case what's relevant isn't whether _your_ gcc
understands -Wno-foobar, but whether your interlocutor's does - and no
local test is going to be able to discover that.

Ian.



More information about the Gcc-patches mailing list