This is the mail archive of the gcc-patches@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]

PR 26494 -pedantic-errors can be overridden by -W*


:ADDPATCH c/diagnostics:

The handling of Wimplicit-function-declaration is somehow special. The
warning is a pedantic error with -std=c99 -pedantic-errors but if you
use -std=c99 -pedantic -Wimplict-function-declaration, it reverts back
to a warning. I guess that the intention is to be a pedantic warning
with -std=c99 -pedantic (thus, an error with -pedantic-errors) and a
normal warning for -Wimplicit-function-declaration.

However, fixing this is complicated because we do some nasty tricks to
handle the legacy -Werror-implicit-function-declaration.

The following patch fixes the issue and, in addition, removes
-Werror-implicit-function-declaration from the manual while handling
it internally as -Werror=implicit-function-declaration. It also
renames the warning flag mesg_implicit_function_declaration to the
more canonical name warn_implicit_function_declaration.

Bootstrapped and regression tested on i686-pc-linux-gnu.

OK for mainline?

This was intended to appear on GCC 4.2 as a follow-up to the new
-Werror= framework but somehow it got lost. Should I also apply it to
GCC 4.2? (The -Werror= framework is due to appear in GCC 4.2, although
that doesn't seem to be documented in the release notes, nor the
switches to control diagnostics, nor the new diagnostic pragma).


2007-01-26 Manuel Lopez-Ibanez <manu@gcc.gnu.org>


 PR c/26494
 * doc/invoke.texi (Wimplicit-function-declaration): Remove
-Werror-implicit-function-declaration.
 * opts.c (common_handle_option): Move handling of -Werror=* to...
 (enable_warning_as_error): ...here.
 * opts.h (enable_warning_as_error): Declare.
 * c-decl.c (implicit_decl_warning): Emit a pewarn if -std=c99
-pedantic, otherwise emit a warning if
-Wimplicit-function-declaration.
 * c.opt (Wimplicit-function-declaration): Replace
mesg_implicit_function_declaration with
warn_implicit_function_declaration.
 * c-opts.c (c_common_handle_option):
-Werror-implicit-function-declaration is exactly equal as
-Werror=implicit-function-declaration.
 (set_Wimplicit): Replace mesg_implicit_function_declaration with
warn_implicit_function_declaration.
 * c-objc-common.c (c_objc_common_init): Remove flawed logic.

testsuite/

 PR c/26494
 * gcc.dg/Wimplicit-function-declaration.c: New.
 * gcc.dg/Wimplicit-function-declaration-pedantic.c: New.
 * gcc.dg/Wimplicit-function-declaration-error.c: New.

Attachment: wimplicit-function-decl.diff
Description: Text document


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