https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86134
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jsm28 at gcc dot gnu.org --- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Manuel López-Ibáñez from comment #5) > (In reply to rguent...@suse.de from comment #4) > > fails the compile but with the warning not emitted the error isn't > > emitted. Also we do know the warning is guarded by -Wreturn-type > > so I see no point in warning that it wasn't silenced by > > -Wno-unknown-warning-option? > > I see what you mean: The warning that could have been silenced did not > prevent compilation but the warning about the unknown option did. However, > > 1) Given -Wno-foo, there is no way to know if you actually meant -Wno-foooo > or, -Wfoo is an alias for -Wreturn-type in some other version of GCC. Maybe > you really meant to write -Wno-return-type but you mistyped it as -Wno-foo. > The current behavior means "There is at least one diagnostic that could > have been silenced by -Wno-foo, but this GCC does not recognize -Wfoo, maybe > you gave the wrong option?" > > 2) The warning behaves like any other warning: It gets converted to an error > with -Werror. Imagine an example where GCC gives both a warning [-Wfooo] and > a warning converted to an error [-Werror=foooo], what should we report for > -Wno-fooooo ? > > We can alleviate (2) by giving it a name (clang uses > -Wunknown-warning-option) so that you can do: > > gcc -S -x c -Wall -Werror -Wno-error=return-type > -Wno-error=unknown-warning-option -Wno-foo There is no way to specify that the diagnostic about the unknown -Wno-unknown-warning-option should not be promoted to an error. -Wno-error=unknown-warning-option and variants do not work because the option isn't known. The diagnostic lists [-Werror] so the only option is to disable -Werror. In general I question that we raise a diagnostic at all here but I can live with that. But this diagnostic about unknown options should never be promoted to errors from warnings IMHO. > Another example: > > gcc -S -x c -Wall -Werror -Wno-misleading-identation -Wno-future > > If there is no warning emitted, there is no harm in the above -Wno- options. > > If there is a warning emitted, it will get converted to an error, and GCC > does not know if you actually meant -Wno-misleading-indentation. And maybe > you really want to use -Wno-future for a future -Wfuture enabled by -Wall, > and you don't care but you want the same command-line to work on previous > GCC versions so giving an extra warning (or error) or may be you really > meant the warning used to be called -Wmisleading-identation, but it got > renamed. Sure. But if you come back to my case where I had -Werror and specifically disabled promoting a specific warning to an error then I got what I wanted and there's no point in erroring for the unknown warning option. I guess a solution would be to not emit a warning about the unknown option but a note (using inform). Joseph, do you agree that the following shouldn't fail the compilation? > echo 'int main(){}' | gcc -S -x c -Wno-unknown-warning-option -Wall -Werror > -Wno-error=return-type - <stdin>: In function ‘main’: <stdin>:1:1: warning: control reaches end of non-void function [-Wreturn-type] <stdin>: At top level: cc1: error: unrecognized command line option "-Wno-unknown-warning-option" [-Werror] cc1: all warnings being treated as errors