aboutsummaryrefslogtreecommitdiff
path: root/gcc/opts-common.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2010-11-12 23:30:42 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2010-11-12 23:30:42 +0000
commitc5fa0890a2a879bc6c240e83ff67036ca46e1a8d (patch)
treeae26a7e8a2fcd55cebd323ad5e45623c076f18d3 /gcc/opts-common.c
parenta4d8c676006f3b672af5088f52160e762aa7a197 (diff)
downloadgcc-c5fa0890a2a879bc6c240e83ff67036ca46e1a8d.zip
gcc-c5fa0890a2a879bc6c240e83ff67036ca46e1a8d.tar.gz
gcc-c5fa0890a2a879bc6c240e83ff67036ca46e1a8d.tar.bz2
opts-common.c (control_warning_option): New.
* opts-common.c (control_warning_option): New. * opts.c (set_default_handlers): New. (decode_options): Use set_default_handlers and control_warning_option. (common_handle_option): Update call to enable_warning_as_error. (enable_warning_as_error): Take gcc_options parameters. Use control_warning_option. * opts.h (set_default_handlers, control_warning_option): Declare. c-family: * c-common.h (c_family_lang_mask): Declare. * c-opts.c (c_family_lang_mask): Make extern. * c-pragma.c (handle_pragma_diagnostic): Use control_warning_option. testsuite: * gcc.dg/pragma-diag-2.c: New test. From-SVN: r166689
Diffstat (limited to 'gcc/opts-common.c')
-rw-r--r--gcc/opts-common.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index c114d4e..cc20410 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -977,3 +977,34 @@ option_flag_var (int opt_index, struct gcc_options *opts)
return NULL;
return (void *)(((char *) opts) + option->flag_var_offset);
}
+
+/* Set a warning option OPT_INDEX (language mask LANG_MASK, option
+ handlers HANDLERS) to have diagnostic kind KIND for option
+ structures OPTS and OPTS_SET and diagnostic context DC (possibly
+ NULL), at location LOC (UNKNOWN_LOCATION for -Werror=). If IMPLY,
+ the warning option in question is implied at this point. This is
+ used by -Werror= and #pragma GCC diagnostic. */
+
+void
+control_warning_option (unsigned int opt_index, int kind, bool imply,
+ location_t loc, unsigned int lang_mask,
+ const struct cl_option_handlers *handlers,
+ struct gcc_options *opts,
+ struct gcc_options *opts_set,
+ diagnostic_context *dc)
+{
+ if (cl_options[opt_index].alias_target != N_OPTS)
+ opt_index = cl_options[opt_index].alias_target;
+ if (opt_index == OPT_SPECIAL_ignore)
+ return;
+ if (dc)
+ diagnostic_classify_diagnostic (dc, opt_index, (diagnostic_t) kind, loc);
+ if (imply)
+ {
+ /* -Werror=foo implies -Wfoo. */
+ if (cl_options[opt_index].var_type == CLVC_BOOLEAN)
+ handle_generated_option (opts, opts_set,
+ opt_index, NULL, 1, lang_mask,
+ kind, loc, handlers, dc);
+ }
+}