summaryrefslogtreecommitdiff
path: root/gcc/opts-common.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-12 23:30:42 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-11-12 23:30:42 +0000
commitc123f04d23179030bf2209e4068a640e0243c866 (patch)
treeae26a7e8a2fcd55cebd323ad5e45623c076f18d3 /gcc/opts-common.c
parent3c6c0e40fd80e2cd4909ef171f9a92efb5c6f348 (diff)
downloadgcc-c123f04d23179030bf2209e4068a640e0243c866.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166689 138bc75d-0d04-0410-961f-82ee72b054a4
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 c114d4e1f04..cc20410544c 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);
+ }
+}