aboutsummaryrefslogtreecommitdiff
path: root/gcc/coverage.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/coverage.c')
-rw-r--r--gcc/coverage.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/gcc/coverage.c b/gcc/coverage.c
index 7d82e44..f353c9c 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -245,7 +245,9 @@ read_counts_file (void)
else if (GCOV_TAG_IS_COUNTER (tag) && fn_ident)
{
counts_entry **slot, *entry, elt;
- unsigned n_counts = GCOV_TAG_COUNTER_NUM (length);
+ int read_length = (int)length;
+ length = read_length > 0 ? read_length : 0;
+ unsigned n_counts = GCOV_TAG_COUNTER_NUM (abs (read_length));
unsigned ix;
elt.ident = fn_ident;
@@ -274,8 +276,9 @@ read_counts_file (void)
counts_hash = NULL;
break;
}
- for (ix = 0; ix != n_counts; ix++)
- entry->counts[ix] += gcov_read_counter ();
+ if (read_length > 0)
+ for (ix = 0; ix != n_counts; ix++)
+ entry->counts[ix] = gcov_read_counter ();
}
gcov_sync (offset, length);
if ((is_error = gcov_is_error ()))
@@ -345,8 +348,11 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum,
can do about it. */
return NULL;
}
-
- if (entry->cfg_checksum != cfg_checksum || entry->n_counts != n_counts)
+
+ if (entry->cfg_checksum != cfg_checksum
+ || (counter != GCOV_COUNTER_V_INDIR
+ && counter != GCOV_COUNTER_V_TOPN
+ && entry->n_counts != n_counts))
{
static int warned = 0;
bool warning_printed = false;