diff options
author | dj <dj@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-18 20:02:42 +0000 |
---|---|---|
committer | dj <dj@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-18 20:02:42 +0000 |
commit | 76f02516d92d7110b13140af39499b789ea392da (patch) | |
tree | fc2b70d94a779eb0814d5f4a6c95145347b94e16 /gcc/c-pragma.c | |
parent | 4f87bd68d2e70bb06e350c16b9ada67c24075380 (diff) | |
download | gcc-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/c-pragma.c')
-rw-r--r-- | gcc/c-pragma.c | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/gcc/c-pragma.c b/gcc/c-pragma.c index 554e57f932b..5256758d94b 100644 --- a/gcc/c-pragma.c +++ b/gcc/c-pragma.c @@ -1,6 +1,6 @@ /* Handle #pragma, system V.4 style. Supports #pragma weak and #pragma pack. - Copyright (C) 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 - Free Software Foundation, Inc. + Copyright (C) 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006 Free Software Foundation, Inc. This file is part of GCC. @@ -36,7 +36,8 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #include "tm_p.h" #include "vec.h" #include "target.h" - +#include "diagnostic.h" +#include "opts.h" #define GCC_BAD(gmsgid) \ do { warning (OPT_Wpragmas, gmsgid); return; } while (0) @@ -668,6 +669,53 @@ handle_pragma_visibility (cpp_reader *dummy ATTRIBUTE_UNUSED) #endif +static void +handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy)) +{ + const char *kind_string, *option_string; + unsigned int option_index; + enum cpp_ttype token; + diagnostic_t kind; + tree x; + + if (cfun) + { + error ("#pragma GCC diagnostic not allowed inside functions"); + return; + } + + token = pragma_lex (&x); + if (token != CPP_NAME) + GCC_BAD ("missing [error|warning|ignored] after %<#pragma GCC diagnostic%>"); + kind_string = IDENTIFIER_POINTER (x); + if (strcmp (kind_string, "error") == 0) + kind = DK_ERROR; + else if (strcmp (kind_string, "warning") == 0) + kind = DK_WARNING; + else if (strcmp (kind_string, "ignored") == 0) + kind = DK_IGNORED; + else + GCC_BAD ("expected [error|warning|ignored] after %<#pragma GCC diagnostic%>"); + + token = pragma_lex (&x); + if (token != CPP_STRING) + GCC_BAD ("missing option after %<#pragma GCC diagnostic%> kind"); + option_string = TREE_STRING_POINTER (x); + for (option_index = 0; option_index < cl_options_count; option_index++) + if (strcmp (cl_options[option_index].opt_text, option_string) == 0) + { + /* This overrides -Werror, for example. */ + diagnostic_classify_diagnostic (global_dc, option_index, kind); + /* This makes sure the option is enabled, like -Wfoo would do. */ + if (cl_options[option_index].var_type == CLVC_BOOLEAN + && cl_options[option_index].flag_var + && kind != DK_IGNORED) + *(int *) cl_options[option_index].flag_var = 1; + return; + } + GCC_BAD ("unknown option after %<#pragma GCC diagnostic%> kind"); +} + /* A vector of registered pragma callbacks. */ DEF_VEC_O (pragma_handler); @@ -767,6 +815,8 @@ init_pragma (void) c_register_pragma ("GCC", "visibility", handle_pragma_visibility); #endif + c_register_pragma ("GCC", "diagnostic", handle_pragma_diagnostic); + c_register_pragma (0, "redefine_extname", handle_pragma_redefine_extname); c_register_pragma (0, "extern_prefix", handle_pragma_extern_prefix); |