On Wed, Jan 28, 2026 at 8:49 PM Jørgen Kvalsvik <[email protected]> wrote:
>
> 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.
I'm not sure we want to do this via specs processing. There's
now EnabledBy() that can be used in common.opt on -ftest-coverage.
Richard.
> 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 6b6f6f87c52..21010efb867 100644
> --- a/gcc/gcc.cc
> +++ b/gcc/gcc.cc
> @@ -1320,6 +1320,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 10578ec1865..945728a35e7 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 } */
> /* { 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 17d6dde87c6..f555fede4fc 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 } */
>
> /* 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 5e3f0a914e5..ced21db8316 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 } */
>
> void
> --
> 2.47.3
>