From 876c4e9ae6d39f046cc58de3c114cd24d618bc5c Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 28 Apr 2017 12:50:08 +0000
Subject: [PATCH 01/11] Backport r247371
gcc/ChangeLog:
2017-04-28 Martin Liska <mliska@suse.cz>
PR driver/56469
* coverage.c (coverage_remove_note_file): New function.
* coverage.h: Declare the function.
* toplev.c (finalize): Clean if an error has been seen.
---
gcc/coverage.c | 12 ++++++++++++
gcc/coverage.h | 1 +
gcc/toplev.c | 3 +++
3 files changed, 16 insertions(+)
@@ -767,6 +767,18 @@ coverage_end_function (unsigned lineno_checksum, unsigned cfg_checksum)
}
}
+/* Remove coverage file if opened. */
+
+void
+coverage_remove_note_file (void)
+{
+ if (bbg_file_name)
+ {
+ gcov_close ();
+ unlink (bbg_file_name);
+ }
+}
+
/* Build a coverage variable of TYPE for function FN_DECL. If COUNTER
>= 0 it is a counter array, otherwise it is the function structure. */
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3. If not see
extern void coverage_init (const char *);
extern void coverage_finish (void);
+extern void coverage_remove_note_file (void);
/* Start outputting coverage information for the current
function. */
@@ -1999,6 +1999,9 @@ finalize (bool no_backend)
if (stack_usage_file)
fclose (stack_usage_file);
+ if (seen_error ())
+ coverage_remove_note_file ();
+
if (!no_backend)
{
statistics_fini ();
--
2.13.1