summaryrefslogtreecommitdiff
path: root/gcc/c-family/c-pragma.c
diff options
context:
space:
mode:
authordj <dj@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-21 20:58:57 +0000
committerdj <dj@138bc75d-0d04-0410-961f-82ee72b054a4>2010-06-21 20:58:57 +0000
commit0955be6537c2fd3d21d5a0b385a21fdfc6b5634b (patch)
treebed45f50f0a58fddadbef5bd923786107ade4104 /gcc/c-family/c-pragma.c
parent99820dd9a9a14ed27bc7d1f2f452eb24ebfa6ebe (diff)
downloadgcc-0955be6537c2fd3d21d5a0b385a21fdfc6b5634b.tar.gz
* diagnostic.h (diagnostic_classification_change_t): New.
(diagnostic_context): Add history and push/pop list. (diagnostic_push_diagnostics): Declare. (diagnostic_pop_diagnostics): Declare. * diagnostic.c (diagnostic_classify_diagnostic): Store changes from pragmas in a history chain instead of the global table. (diagnostic_push_diagnostics): New. (diagnostic_pop_diagnostics): New. (diagnostic_report_diagnostic): Scan history chain to find state of diagnostics as of the diagnostic location. * opts.c (set_option): Pass UNKNOWN_LOCATION to diagnostic_classify_diagnostic. (enable_warning_as_error): Likewise. * diagnostic-core.h (DK_POP): Add after "real" diagnostics, for use in the history chain. * c-family/c-pragma.c (handle_pragma_diagnostic): Add push/pop, allow these pragmas anywhere. * doc/extend.texi: Document pragma GCC diagnostic changes. * gcc.dg/pragma-diag-1.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161115 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family/c-pragma.c')
-rw-r--r--gcc/c-family/c-pragma.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c
index ab922696ddd..cea0b267b92 100644
--- a/gcc/c-family/c-pragma.c
+++ b/gcc/c-family/c-pragma.c
@@ -706,12 +706,6 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy))
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%>");
@@ -722,8 +716,18 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy))
kind = DK_WARNING;
else if (strcmp (kind_string, "ignored") == 0)
kind = DK_IGNORED;
+ else if (strcmp (kind_string, "push") == 0)
+ {
+ diagnostic_push_diagnostics (global_dc, input_location);
+ return;
+ }
+ else if (strcmp (kind_string, "pop") == 0)
+ {
+ diagnostic_pop_diagnostics (global_dc, input_location);
+ return;
+ }
else
- GCC_BAD ("expected [error|warning|ignored] after %<#pragma GCC diagnostic%>");
+ GCC_BAD ("expected [error|warning|ignored|push|pop] after %<#pragma GCC diagnostic%>");
token = pragma_lex (&x);
if (token != CPP_STRING)
@@ -733,7 +737,7 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy))
if (strcmp (cl_options[option_index].opt_text, option_string) == 0)
{
/* This overrides -Werror, for example. */
- diagnostic_classify_diagnostic (global_dc, option_index, kind);
+ diagnostic_classify_diagnostic (global_dc, option_index, kind, input_location);
/* 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