From 79cf599406a6a51e2fdd47810fdba89e04cbf1cc Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Wed, 18 Jan 2006 15:02:42 -0500 Subject: c-pragma.c (handle_pragma_diagnostic): New. * c-pragma.c (handle_pragma_diagnostic): New. (init_pragma): Register it. * doc/extend.texi: Document it. * diagnostic.def: Add DK_UNSPECIFIED and DK_IGNORED. * diagnostic.h (diagnostic_classify_diagnostic): Declare. (diagnostic_context): Add classify_diagnostic[]. * diagnostic.c (diagnostic_count_diagnostic): Don't count warnings as errors if they're overridden to DK_WARNING. (diagnostic_initialize): Initialize classify_diagnostic[]. (diagnostic_set_kind_override): New. (diagnostic_report_diagnostic): Check for kind changes. * opts.c (common_handle_option): Take lang_mask. Update callers. Handle OPT_Werror_. * common.opt (Werror=): New. * doc/invoke.texi: Document -Werror=* From-SVN: r109907 --- gcc/opts.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'gcc/opts.c') diff --git a/gcc/opts.c b/gcc/opts.c index e264b4a..3688086 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1,5 +1,5 @@ /* Command line option handling. - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Neil Booth. This file is part of GCC. @@ -102,7 +102,8 @@ const char **in_fnames; unsigned num_in_fnames; static size_t find_opt (const char *, int); -static int common_handle_option (size_t scode, const char *arg, int value); +static int common_handle_option (size_t scode, const char *arg, int value, + unsigned int lang_mask); static void handle_param (const char *); static void set_Wextra (int); static unsigned int handle_option (const char **argv, unsigned int lang_mask); @@ -405,7 +406,7 @@ handle_option (const char **argv, unsigned int lang_mask) result = 0; if (result && (option->flags & CL_COMMON)) - if (common_handle_option (opt_index, arg, value) == 0) + if (common_handle_option (opt_index, arg, value, lang_mask) == 0) result = 0; if (result && (option->flags & CL_TARGET)) @@ -719,7 +720,8 @@ decode_options (unsigned int argc, const char **argv) VALUE assigned to a variable, it happens automatically. */ static int -common_handle_option (size_t scode, const char *arg, int value) +common_handle_option (size_t scode, const char *arg, int value, + unsigned int lang_mask) { enum opt_code code = (enum opt_code) scode; @@ -759,6 +761,32 @@ common_handle_option (size_t scode, const char *arg, int value) set_Wextra (value); break; + case OPT_Werror_: + { + char *new_option; + int option_index; + new_option = (char *) xmalloc (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; + } + } + break; + case OPT_Wextra: set_Wextra (value); break; -- cgit v1.1