re PR c/26494 (-pedantic-errors can be overridden by -W*)
2007-02-15 Manuel Lopez-Ibanez <manu@gcc.gnu.org> PR c/26494 * doc/invoke.texi (Warning Options): Remove -Werror-implicit-function-declaration. (Wimplicit-function-declaration): Update description. * 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): Unless -Wno-implicit-function-declaration is given, emit a pedwarn if -std=c99 or 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_common_post_options): -Wimplict-function-declaration is enabled by default by -std=c99, otherwise is disabled by default. * c-objc-common.c (c_objc_common_init): Remove flawed logic. testsuite/ * gcc.dg/Wimplicit-function-declaration-c89.c: New. * gcc.dg/Wimplicit-function-declaration-c89-default.c: New. * gcc.dg/Wimplicit-function-declaration-c89-pedantic.c: New. * gcc.dg/Wimplicit-function-declaration-c99.c: New. * gcc.dg/Wimplicit-function-declaration-c99-pedantic.c: New. * gcc.dg/Werror-implicit-function-declaration.c: New. From-SVN: r122017
This commit is contained in:
parent
214931020b
commit
dc90f45b24
|
@ -1,3 +1,27 @@
|
|||
2007-02-15 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
|
||||
|
||||
PR c/26494
|
||||
* doc/invoke.texi (Warning Options): Remove
|
||||
-Werror-implicit-function-declaration.
|
||||
(Wimplicit-function-declaration): Update description.
|
||||
* 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): Unless
|
||||
-Wno-implicit-function-declaration is given, emit a pedwarn if
|
||||
-std=c99 or 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_common_post_options): -Wimplict-function-declaration is enabled
|
||||
by default by -std=c99, otherwise is disabled by default.
|
||||
* c-objc-common.c (c_objc_common_init): Remove flawed logic.
|
||||
|
||||
2007-02-15 Eric Botcazou <ebotcazou@adacore.com>
|
||||
|
||||
* gimplify.c (gimplify_modify_expr): During gimplification, attach a
|
||||
|
|
18
gcc/c-decl.c
18
gcc/c-decl.c
|
@ -2376,18 +2376,16 @@ pushdecl_top_level (tree x)
|
|||
static void
|
||||
implicit_decl_warning (tree id, tree olddecl)
|
||||
{
|
||||
void (*diag) (const char *, ...) ATTRIBUTE_GCC_CDIAG(1,2);
|
||||
switch (mesg_implicit_function_declaration)
|
||||
if (warn_implicit_function_declaration)
|
||||
{
|
||||
case 0: return;
|
||||
case 1: diag = warning0; break;
|
||||
case 2: diag = error; break;
|
||||
default: gcc_unreachable ();
|
||||
if (flag_isoc99)
|
||||
pedwarn (G_("implicit declaration of function %qE"), id);
|
||||
else
|
||||
warning (OPT_Wimplicit_function_declaration,
|
||||
G_("implicit declaration of function %qE"), id);
|
||||
if (olddecl)
|
||||
locate_old_decl (olddecl, inform);
|
||||
}
|
||||
|
||||
diag (G_("implicit declaration of function %qE"), id);
|
||||
if (olddecl)
|
||||
locate_old_decl (olddecl, diag);
|
||||
}
|
||||
|
||||
/* Generate an implicit declaration for identifier FUNCTIONID as a
|
||||
|
|
|
@ -135,16 +135,6 @@ c_objc_common_init (void)
|
|||
want an enhanced ObjC implementation. */
|
||||
diagnostic_format_decoder (global_dc) = &c_tree_printer;
|
||||
|
||||
/* If still unspecified, make it match -std=c99
|
||||
(allowing for -pedantic-errors). */
|
||||
if (mesg_implicit_function_declaration < 0)
|
||||
{
|
||||
if (flag_isoc99)
|
||||
mesg_implicit_function_declaration = flag_pedantic_errors ? 2 : 1;
|
||||
else
|
||||
mesg_implicit_function_declaration = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
18
gcc/c-opts.c
18
gcc/c-opts.c
|
@ -451,8 +451,10 @@ c_common_handle_option (size_t scode, const char *arg, int value)
|
|||
global_dc->warning_as_error_requested = value;
|
||||
break;
|
||||
|
||||
case OPT_Werror_implicit_function_declaration:
|
||||
mesg_implicit_function_declaration = 2;
|
||||
case OPT_Werror_implicit_function_declaration:
|
||||
/* For backward compatibility, this is the same as
|
||||
-Werror=implicit-function-declaration. */
|
||||
enable_warning_as_error ("implicit-function-declaration", value, CL_C | CL_ObjC);
|
||||
break;
|
||||
|
||||
case OPT_Wformat:
|
||||
|
@ -1079,6 +1081,10 @@ c_common_post_options (const char **pfilename)
|
|||
"-Wformat-security ignored without -Wformat");
|
||||
}
|
||||
|
||||
/* -Wimplicit-function-declaration is enabled by default for C99. */
|
||||
if (warn_implicit_function_declaration == -1)
|
||||
warn_implicit_function_declaration = flag_isoc99;
|
||||
|
||||
/* C99 requires special handling of complex multiplication and division;
|
||||
-ffast-math and -fcx-limited-range are handled in process_options. */
|
||||
if (flag_isoc99)
|
||||
|
@ -1570,13 +1576,7 @@ set_Wimplicit (int on)
|
|||
{
|
||||
warn_implicit = on;
|
||||
warn_implicit_int = on;
|
||||
if (on)
|
||||
{
|
||||
if (mesg_implicit_function_declaration != 2)
|
||||
mesg_implicit_function_declaration = 1;
|
||||
}
|
||||
else
|
||||
mesg_implicit_function_declaration = 0;
|
||||
warn_implicit_function_declaration = on;
|
||||
}
|
||||
|
||||
/* Args to -d specify what to dump. Silently ignore
|
||||
|
|
|
@ -194,7 +194,7 @@ C ObjC C++ ObjC++
|
|||
|
||||
Werror-implicit-function-declaration
|
||||
C ObjC RejectNegative Warning
|
||||
Make implicit function declarations an error
|
||||
This switch is deprecated; use -Werror=implicit-function-declaration instead
|
||||
|
||||
Wfloat-equal
|
||||
C ObjC C++ ObjC++ Var(warn_float_equal) Warning
|
||||
|
@ -235,7 +235,7 @@ Wimplicit
|
|||
C ObjC C++ ObjC++ Warning
|
||||
|
||||
Wimplicit-function-declaration
|
||||
C ObjC Var(mesg_implicit_function_declaration) Init(-1) Warning
|
||||
C ObjC Var(warn_implicit_function_declaration) Init(-1) Warning
|
||||
Warn about implicit function declarations
|
||||
|
||||
Wimplicit-int
|
||||
|
|
|
@ -229,7 +229,7 @@ Objective-C and Objective-C++ Dialects}.
|
|||
-Wconversion -Wcoverage-mismatch -Wno-deprecated-declarations @gol
|
||||
-Wdisabled-optimization -Wno-div-by-zero @gol
|
||||
-Wempty-body -Wno-endif-labels @gol
|
||||
-Werror -Werror-* -Werror-implicit-function-declaration @gol
|
||||
-Werror -Werror=* @gol
|
||||
-Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
|
||||
-Wno-format-extra-args -Wformat-nonliteral @gol
|
||||
-Wformat-security -Wformat-y2k @gol
|
||||
|
@ -2626,13 +2626,13 @@ Warn when a declaration does not specify a type.
|
|||
This warning is enabled by @option{-Wall}.
|
||||
|
||||
@item -Wimplicit-function-declaration
|
||||
@itemx -Werror-implicit-function-declaration
|
||||
@opindex Wimplicit-function-declaration
|
||||
@opindex Werror-implicit-function-declaration
|
||||
Give a warning (or error) whenever a function is used before being
|
||||
declared. The form @option{-Wno-error-implicit-function-declaration}
|
||||
is not supported.
|
||||
This warning is enabled by @option{-Wall} (as a warning, not an error).
|
||||
@opindex Wno-implicit-function-declaration
|
||||
Give a warning whenever a function is used before being declared. In
|
||||
C99 mode (@option{-std=c99} or @option{-std=gnu99}), this warning is
|
||||
enabled by default and it is made into an error by
|
||||
@option{-pedantic-errors}. This warning is also enabled by
|
||||
@option{-Wall}.
|
||||
|
||||
@item -Wimplicit
|
||||
@opindex Wimplicit
|
||||
|
|
57
gcc/opts.c
57
gcc/opts.c
|
@ -1067,31 +1067,7 @@ common_handle_option (size_t scode, const char *arg, int value,
|
|||
break;
|
||||
|
||||
case OPT_Werror_:
|
||||
{
|
||||
char *new_option;
|
||||
int option_index;
|
||||
|
||||
new_option = XNEWVEC (char, strlen (arg) + 2);
|
||||
new_option[0] = 'W';
|
||||
strcpy (new_option+1, arg);
|
||||
option_index = find_opt (new_option, lang_mask);
|
||||
if (option_index == N_OPTS)
|
||||
{
|
||||
error ("-Werror-%s: No option -%s", arg, new_option);
|
||||
}
|
||||
else
|
||||
{
|
||||
int kind = value ? DK_ERROR : DK_WARNING;
|
||||
diagnostic_classify_diagnostic (global_dc, option_index, kind);
|
||||
|
||||
/* -Werror=foo implies -Wfoo. */
|
||||
if (cl_options[option_index].var_type == CLVC_BOOLEAN
|
||||
&& cl_options[option_index].flag_var
|
||||
&& kind == DK_ERROR)
|
||||
*(int *) cl_options[option_index].flag_var = 1;
|
||||
free (new_option);
|
||||
}
|
||||
}
|
||||
enable_warning_as_error (arg, value, lang_mask);
|
||||
break;
|
||||
|
||||
case OPT_Wextra:
|
||||
|
@ -1607,3 +1583,34 @@ get_option_state (int option, struct cl_option_state *state)
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Enable a warning option as an error. This is used by -Werror= and
|
||||
also by legacy Werror-implicit-function-declaration. */
|
||||
|
||||
void
|
||||
enable_warning_as_error (const char *arg, int value, unsigned int lang_mask)
|
||||
{
|
||||
char *new_option;
|
||||
int option_index;
|
||||
|
||||
new_option = XNEWVEC (char, strlen (arg) + 2);
|
||||
new_option[0] = 'W';
|
||||
strcpy (new_option + 1, arg);
|
||||
option_index = find_opt (new_option, lang_mask);
|
||||
if (option_index == N_OPTS)
|
||||
{
|
||||
error ("-Werror=%s: No option -%s", arg, new_option);
|
||||
}
|
||||
else
|
||||
{
|
||||
int kind = value ? DK_ERROR : DK_WARNING;
|
||||
diagnostic_classify_diagnostic (global_dc, option_index, kind);
|
||||
|
||||
/* -Werror=foo implies -Wfoo. */
|
||||
if (cl_options[option_index].var_type == CLVC_BOOLEAN
|
||||
&& cl_options[option_index].flag_var
|
||||
&& kind == DK_ERROR)
|
||||
*(int *) cl_options[option_index].flag_var = 1;
|
||||
}
|
||||
free (new_option);
|
||||
}
|
||||
|
|
|
@ -104,4 +104,6 @@ extern void decode_options (unsigned int argc, const char **argv);
|
|||
extern int option_enabled (int opt_idx);
|
||||
extern bool get_option_state (int, struct cl_option_state *);
|
||||
|
||||
extern void enable_warning_as_error (const char *arg, int value,
|
||||
unsigned int lang_mask);
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
2007-02-15 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
|
||||
|
||||
PR c/26494
|
||||
* gcc.dg/Wimplicit-function-declaration-c89.c: New.
|
||||
* gcc.dg/Wimplicit-function-declaration-c89-default.c: New.
|
||||
* gcc.dg/Wimplicit-function-declaration-c89-pedantic.c: New.
|
||||
* gcc.dg/Wimplicit-function-declaration-c99.c: New.
|
||||
* gcc.dg/Wimplicit-function-declaration-c99-pedantic.c: New.
|
||||
* gcc.dg/Werror-implicit-function-declaration.c: New.
|
||||
|
||||
2007-02-15 Manuel Lopez-Ibanez <manu@gcc.gnu.org>
|
||||
|
||||
PR c++/28943
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=c89 -Werror-implicit-function-declaration" } */
|
||||
|
||||
void f(void)
|
||||
{
|
||||
puts("Hello"); /* { dg-error "error: implicit declaration of function" } */
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=c89" } */
|
||||
|
||||
void f(void)
|
||||
{
|
||||
puts("Hello"); /* { dg-bogus "warning: implicit declaration of function" } */
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=c89 -pedantic-errors -Wimplicit-function-declaration" } */
|
||||
|
||||
void f(void)
|
||||
{
|
||||
puts("Hello"); /* { dg-warning "warning: implicit declaration of function" } */
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=c89 -Wimplicit-function-declaration" } */
|
||||
|
||||
void f(void)
|
||||
{
|
||||
puts("Hello"); /* { dg-warning "warning: implicit declaration of function" } */
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=c99 -pedantic-errors -Wall" } */
|
||||
|
||||
void f(void)
|
||||
{
|
||||
puts("Hello"); /* { dg-error "error: implicit declaration of function" } */
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=c99" } */
|
||||
|
||||
void f(void)
|
||||
{
|
||||
puts("Hello"); /* { dg-warning "warning: implicit declaration of function" } */
|
||||
}
|
Loading…
Reference in New Issue