I found these while writing a test case for function summaries.

The coverage.paths field was updated with the wrong count, which would
for function summaries lead obviously wrong output like:
'Prime paths covered:0.00% of -1 (2 of 1 suppressed)'
The numbers in the gcov report itself were fine.

The missing else cause 'No conditions' to be output when it shouldn't:

    Calls executed:50.00% of 2
    Condition outcomes covered:50.00% of 4
    No conditions

I apparently never tried these exact combinations with function
summaries, which are occasionally useful, but I mostly used the
detailed reports.

Bootstrapped and tested on x86_64-linux-gnu, pushed as obvious.

gcc/ChangeLog:

        * gcov.cc (add_path_counts): Read the right field paths.size.
        (function_summary): Add missing else.
---
 gcc/gcov.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/gcov.cc b/gcc/gcov.cc
index ceed689c1c9..bab0f893f03 100644
--- a/gcc/gcov.cc
+++ b/gcc/gcov.cc
@@ -3315,7 +3315,7 @@ add_condition_counts (coverage_info *coverage, const 
block_info *block)
 static void
 add_path_counts (coverage_info &coverage, const function_info &fn)
 {
-  coverage.paths += fn.paths.path_count ();
+  coverage.paths += fn.paths.paths.size ();
   coverage.paths_covered += fn.paths.covered_paths ();
   coverage.paths_suppressed += fn.paths.suppressed_count ();
 }
@@ -3441,7 +3441,7 @@ function_summary (const coverage_info *coverage)
                 format_gcov (coverage->conditions_covered,
                              coverage->conditions, 2),
                 coverage->conditions);
-      if (coverage->conditions && coverage->conditions_suppressed > 0)
+      else if (coverage->conditions && coverage->conditions_suppressed > 0)
        fnotice (stdout, "Condition outcomes covered:%s of %d"
                 " (%d of %d suppressed)\n",
                 format_gcov (coverage->conditions_covered,
-- 
2.47.3

Reply via email to