diff options
author | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-15 22:31:17 +0000 |
---|---|---|
committer | manu <manu@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-15 22:31:17 +0000 |
commit | 3ba510aa5b8a07f6fa5a2d163354b0ff5b5c7484 (patch) | |
tree | 73dcde30921d36f76037d1d0106b2271a8aa2058 /gcc/opts.c | |
parent | 97e77d8efe0eb7595cc8b0bc8449543acb0b4045 (diff) | |
download | gcc-3ba510aa5b8a07f6fa5a2d163354b0ff5b5c7484.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@122017 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/opts.c')
-rw-r--r-- | gcc/opts.c | 57 |
1 files changed, 32 insertions, 25 deletions
diff --git a/gcc/opts.c b/gcc/opts.c index 1361eb77922..c84bc2a3c35 100644 --- a/gcc/opts.c +++ b/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); +} |