diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2013-08-07 17:15:25 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2013-08-07 17:15:25 +0000 |
commit | 3c8ca1abdedb2c0663e24e9dc5942280a8c7820f (patch) | |
tree | a6ef18a81b87f68c82fbee29f709245cb1dd5f06 /gcc | |
parent | 6cb784b639c3de7505674b56f542c8b714d7df8a (diff) | |
download | gcc-3c8ca1abdedb2c0663e24e9dc5942280a8c7820f.zip gcc-3c8ca1abdedb2c0663e24e9dc5942280a8c7820f.tar.gz gcc-3c8ca1abdedb2c0663e24e9dc5942280a8c7820f.tar.bz2 |
diagnostic.c (diagnostic_classify_diagnostic): Accept zero index and document its semantics.
* diagnostic.c (diagnostic_classify_diagnostic): Accept zero index and
document its semantics.
(diagnostic_report_diagnostic): Adjust accordingly.
From-SVN: r201574
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/diagnostic.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/warn9.adb | 10 |
4 files changed, 27 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1dd783d..d55f0f4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2013-08-07 Eric Botcazou <ebotcazou@adacore.com> + + * diagnostic.c (diagnostic_classify_diagnostic): Accept zero index and + document its semantics. + (diagnostic_report_diagnostic): Adjust accordingly. + 2013-08-07 David Malcolm <dmalcolm@redhat.com> * config/sparc/sparc.c (insert_pass_work_around_errata): Move diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 3612ca0..dfc11f2 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -554,7 +554,8 @@ default_diagnostic_finalizer (diagnostic_context *context ATTRIBUTE_UNUSED, /* Interface to specify diagnostic kind overrides. Returns the previous setting, or DK_UNSPECIFIED if the parameters are out of - range. */ + range. If OPTION_INDEX is zero, the new setting is for all the + diagnostics. */ diagnostic_t diagnostic_classify_diagnostic (diagnostic_context *context, int option_index, @@ -563,7 +564,7 @@ diagnostic_classify_diagnostic (diagnostic_context *context, { diagnostic_t old_kind; - if (option_index <= 0 + if (option_index < 0 || option_index >= context->n_opts || new_kind >= DK_LAST_DIAGNOSTIC_KIND) return DK_UNSPECIFIED; @@ -695,9 +696,8 @@ diagnostic_report_diagnostic (diagnostic_context *context, /* This tests for #pragma diagnostic changes. */ if (context->n_classification_history > 0) { - int i; /* FIXME: Stupid search. Optimize later. */ - for (i = context->n_classification_history - 1; i >= 0; i --) + for (int i = context->n_classification_history - 1; i >= 0; i --) { if (linemap_location_before_p (line_table, @@ -709,7 +709,9 @@ diagnostic_report_diagnostic (diagnostic_context *context, i = context->classification_history[i].option; continue; } - if (context->classification_history[i].option == diagnostic->option_index) + int option = context->classification_history[i].option; + /* The option 0 is for all the diagnostics. */ + if (option == 0 || option == diagnostic->option_index) { diag_class = context->classification_history[i].kind; if (diag_class != DK_UNSPECIFIED) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ef030b0..ffa5fca 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-08-07 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/warn9.adb: New test. + 2013-08-07 Paolo Carlini <paolo.carlini@oracle.com> PR c++/46206 diff --git a/gcc/testsuite/gnat.dg/warn9.adb b/gcc/testsuite/gnat.dg/warn9.adb new file mode 100644 index 0000000..38f9d71 --- /dev/null +++ b/gcc/testsuite/gnat.dg/warn9.adb @@ -0,0 +1,10 @@ +-- { dg-do compile } +-- { dg-options "-Wuninitialized" } + +pragma Warnings (Off); + +function Warn9 return Integer is + I : Integer; +begin + return I; +end; |