diff options
author | nvachhar <nvachhar@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-05-04 23:45:58 +0000 |
---|---|---|
committer | nvachhar <nvachhar@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-05-04 23:45:58 +0000 |
commit | 21cd990df370bfeb0ed410b024a41176014959ad (patch) | |
tree | ea706642f18ee85392a51bf61e49a74bfbdef8bb /gcc/coverage.c | |
parent | 3e8004a040279c7acce3e8287b8e67583cc7b8dc (diff) | |
download | gcc-21cd990df370bfeb0ed410b024a41176014959ad.tar.gz |
Sanitize the behavior of -Wcoverage-mismatch.
2010-05-04 Neil Vachharajani <nvachhar@google.com>
* doc/invoke.texi (-Wcoverage-mismatch): Updated documentation as
per new semantics.
* opts.c (decode_options): Enable -Werror=coverage-mismatch.
* coverage.c (get_coverage_counts): Always emit a warning. Adjust
conditions for printing notes.
* common.opt (-Wcoverage-mismatch): Allow negative, default to
true, update documentation.
* Makefile.in (coverage.o): Add dependence on DIAGNOSTIC_H and intl.h.
* testsuite/gcc.dg/tree-prof/wcoverage-mismatch.c: Adjusted.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159050 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/coverage.c')
-rw-r--r-- | gcc/coverage.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/gcc/coverage.c b/gcc/coverage.c index e04d22b7a88..addfac90c21 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -46,6 +46,8 @@ along with GCC; see the file COPYING3. If not see #include "tree-iterator.h" #include "cgraph.h" #include "tree-pass.h" +#include "diagnostic.h" +#include "intl.h" #include "gcov-io.c" @@ -357,34 +359,33 @@ get_coverage_counts (unsigned counter, unsigned expected, || entry->summary.num != expected) { static int warned = 0; + bool warning_printed = false; tree id = DECL_ASSEMBLER_NAME (current_function_decl); - if (warn_coverage_mismatch) - warning (OPT_Wcoverage_mismatch, "coverage mismatch for function " - "%qE while reading counter %qs", id, ctr_names[counter]); - else - error ("coverage mismatch for function %qE while reading counter %qs", - id, ctr_names[counter]); - - if (!inhibit_warnings) + warning_printed = + warning_at (input_location, OPT_Wcoverage_mismatch, + "coverage mismatch for function " + "%qE while reading counter %qs", id, ctr_names[counter]); + if (warning_printed) { if (entry->checksum != checksum) - inform (input_location, "checksum is %x instead of %x", entry->checksum, checksum); + inform (input_location, "checksum is %x instead of %x", + entry->checksum, checksum); else inform (input_location, "number of counters is %d instead of %d", entry->summary.num, expected); - } - - if (warn_coverage_mismatch - && !inhibit_warnings - && !warned++) - { - inform (input_location, "coverage mismatch ignored due to -Wcoverage-mismatch"); - inform (input_location, flag_guess_branch_prob - ? "execution counts estimated" - : "execution counts assumed to be zero"); - if (!flag_guess_branch_prob) - inform (input_location, "this can result in poorly optimized code"); + + if (!(errorcount || sorrycount) + && !warned++) + { + inform (input_location, "coverage mismatch ignored"); + inform (input_location, flag_guess_branch_prob + ? G_("execution counts estimated") + : G_("execution counts assumed to be zero")); + if (!flag_guess_branch_prob) + inform (input_location, + "this can result in poorly optimized code"); + } } return NULL; |