The --coverage flag is a useful alias for -fprofile-arcs
-ftest-coverage where the latter makes gcc output the .gcno file.
While it makes sense to use -fprofile-arcs without a .gcno file (pgo,
maybe more), it never really makes sense to request -fpath-coverage or
-fcondition-coverage without also wanting the .gcno to interpret the
results.

gcc/ChangeLog:

        * gcc.cc: Imply -ftest-coverage if -fpath-coverage or
        -fcondition-coverage is used.

gcc/testsuite/ChangeLog:

        * g++.dg/gcov/gcov-18.C: Remove --coverage.
        * g++.dg/gcov/gcov-22.C: Likewise.
        * gcc.misc-tests/gcov-19.c: Remove -ftest-coverage.
        * gcc.misc-tests/gcov-29.c: Likewise.
---
 gcc/gcc.cc                             | 1 +
 gcc/testsuite/g++.dg/gcov/gcov-18.C    | 2 +-
 gcc/testsuite/g++.dg/gcov/gcov-22.C    | 2 +-
 gcc/testsuite/gcc.misc-tests/gcov-19.c | 2 +-
 gcc/testsuite/gcc.misc-tests/gcov-29.c | 2 +-
 5 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index eae7f07d962..5e2e1057749 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -1303,6 +1303,7 @@ static const char *cc1_options =
  %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
  %{fsyntax-only:-o %j} %{-param*}\
  %{coverage:-fprofile-arcs -ftest-coverage}\
+ %{fcondition-coverage|fpath-coverage:-ftest-coverage}\
  
%{fprofile-arcs|fcondition-coverage|fpath-coverage|fprofile-generate*|coverage:\
    %{!fprofile-update=single:\
      %{pthread:-fprofile-update=prefer-atomic}}}";
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-18.C 
b/gcc/testsuite/g++.dg/gcov/gcov-18.C
index 063440c881c..d12ce7ec423 100644
--- a/gcc/testsuite/g++.dg/gcov/gcov-18.C
+++ b/gcc/testsuite/g++.dg/gcov/gcov-18.C
@@ -1,4 +1,4 @@
-/* { dg-options "--coverage -fcondition-coverage -std=c++11" } */
+/* { dg-options "-fcondition-coverage -std=c++11" } */
 /* { dg-do run { target native } } */
 /* { dg-skip-if "requires hosted libstdc++ for vector" { ! hostedlib } } */
 
diff --git a/gcc/testsuite/g++.dg/gcov/gcov-22.C 
b/gcc/testsuite/g++.dg/gcov/gcov-22.C
index 69e0728e3e4..892d59d8a71 100644
--- a/gcc/testsuite/g++.dg/gcov/gcov-22.C
+++ b/gcc/testsuite/g++.dg/gcov/gcov-22.C
@@ -1,4 +1,4 @@
-/* { dg-options "--coverage -fpath-coverage" } */
+/* { dg-options "-fpath-coverage" } */
 /* { dg-do compile } */
 
 #include <stdexcept>
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-19.c 
b/gcc/testsuite/gcc.misc-tests/gcov-19.c
index 44e2f135e2a..d817694b4c6 100644
--- a/gcc/testsuite/gcc.misc-tests/gcov-19.c
+++ b/gcc/testsuite/gcc.misc-tests/gcov-19.c
@@ -1,4 +1,4 @@
-/* { dg-options "-fcondition-coverage -ftest-coverage" } */
+/* { dg-options "-fcondition-coverage" } */
 /* { dg-do run { target native } } */
 
 /* Some side effect to stop branches from being pruned.  */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-29.c 
b/gcc/testsuite/gcc.misc-tests/gcov-29.c
index 6528ec63977..28eefd210f3 100644
--- a/gcc/testsuite/gcc.misc-tests/gcov-29.c
+++ b/gcc/testsuite/gcc.misc-tests/gcov-29.c
@@ -1,4 +1,4 @@
-/* { dg-options "--coverage -fpath-coverage" } */
+/* { dg-options "-fpath-coverage" } */
 /* { dg-do run { target native } } */
 
 void
-- 
2.39.5

Reply via email to