summaryrefslogtreecommitdiff
path: root/gcc/opts.c
diff options
context:
space:
mode:
authordj <dj@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-18 20:02:42 +0000
committerdj <dj@138bc75d-0d04-0410-961f-82ee72b054a4>2006-01-18 20:02:42 +0000
commit76f02516d92d7110b13140af39499b789ea392da (patch)
treefc2b70d94a779eb0814d5f4a6c95145347b94e16 /gcc/opts.c
parent4f87bd68d2e70bb06e350c16b9ada67c24075380 (diff)
downloadgcc-76f02516d92d7110b13140af39499b789ea392da.tar.gz
* 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=* git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109907 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/opts.c')
-rw-r--r--gcc/opts.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/gcc/opts.c b/gcc/opts.c
index e264b4abcc3..36880862f67 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;