Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

coroutines.exp was basically only there to add -std=c++20 to all the tests;
removing it lets us use the general support for running tests under multiple
standards.  Doing this revealed that some tests that specifically run in
C++17 mode were relying on -std=c++20 followed by -std=c++17 leaving
flag_coroutines set, which seems unintentional, and different from how we
handle other feature flags.  So this changes that, and adds the missing
 -fcoroutines to those tests.

gcc/testsuite/ChangeLog:

        * g++.dg/coroutines/co-await-syntax-09-convert.C: Add -fcoroutines.
        * g++.dg/coroutines/co-await-syntax-10.C
        * g++.dg/coroutines/co-await-syntax-11.C
        * g++.dg/coroutines/co-await-void_type.C
        * g++.dg/coroutines/co-return-warning-1.C
        * g++.dg/coroutines/ramp-return-a.C
        * g++.dg/coroutines/ramp-return-c.C: Likewise.
        * g++.dg/coroutines/coroutines.exp: Removed.
        * lib/g++-dg.exp: Start at C++20 for coroutines/

gcc/c-family/ChangeLog:

        * c-opts.cc (c_common_post_options): Set flag_coroutines.
        (set_std_cxx20, set_std_cxx23, set_std_cxx26): Not here.
---
 gcc/c-family/c-opts.cc                        | 10 ++--
 .../coroutines/co-await-syntax-09-convert.C   |  2 +-
 .../g++.dg/coroutines/co-await-syntax-10.C    |  2 +-
 .../g++.dg/coroutines/co-await-syntax-11.C    |  2 +-
 .../g++.dg/coroutines/co-await-void_type.C    |  2 +-
 .../g++.dg/coroutines/co-return-warning-1.C   |  2 +-
 .../g++.dg/coroutines/ramp-return-a.C         |  2 +-
 .../g++.dg/coroutines/ramp-return-c.C         |  2 +-
 .../g++.dg/coroutines/coroutines.exp          | 50 -------------------
 gcc/testsuite/lib/g++-dg.exp                  |  1 +
 10 files changed, 12 insertions(+), 63 deletions(-)
 delete mode 100644 gcc/testsuite/g++.dg/coroutines/coroutines.exp

diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index f1c276f07cd..697518637df 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -1215,6 +1215,10 @@ c_common_post_options (const char **pfilename)
   if (cxx_dialect >= cxx20)
     flag_concepts = 1;
 
+  /* Coroutines are also a C++20 feature.  */
+  SET_OPTION_IF_UNSET (&global_options, &global_options_set,
+                      flag_coroutines, cxx_dialect >= cxx20);
+
   /* Enable lifetime extension of range based for temporaries for C++23.  */
   SET_OPTION_IF_UNSET (&global_options, &global_options_set,
                       flag_range_for_ext_temps, cxx_dialect >= cxx23);
@@ -2009,8 +2013,6 @@ set_std_cxx20 (int iso)
   flag_isoc94 = 1;
   flag_isoc99 = 1;
   flag_isoc11 = 1;
-  /* C++20 includes coroutines. */
-  flag_coroutines = true;
   cxx_dialect = cxx20;
   lang_hooks.name = "GNU C++20";
 }
@@ -2027,8 +2029,6 @@ set_std_cxx23 (int iso)
   flag_isoc94 = 1;
   flag_isoc99 = 1;
   flag_isoc11 = 1;
-  /* C++23 includes coroutines.  */
-  flag_coroutines = true;
   cxx_dialect = cxx23;
   lang_hooks.name = "GNU C++23";
 }
@@ -2045,8 +2045,6 @@ set_std_cxx26 (int iso)
   flag_isoc94 = 1;
   flag_isoc99 = 1;
   flag_isoc11 = 1;
-  /* C++26 includes coroutines.  */
-  flag_coroutines = true;
   cxx_dialect = cxx26;
   lang_hooks.name = "GNU C++26";
 }
diff --git a/gcc/testsuite/g++.dg/coroutines/co-await-syntax-09-convert.C 
b/gcc/testsuite/g++.dg/coroutines/co-await-syntax-09-convert.C
index dde0bab00cf..deb3be10f07 100644
--- a/gcc/testsuite/g++.dg/coroutines/co-await-syntax-09-convert.C
+++ b/gcc/testsuite/g++.dg/coroutines/co-await-syntax-09-convert.C
@@ -1,4 +1,4 @@
-//  { dg-additional-options "-std=c++17 -w" }
+//  { dg-additional-options "-std=c++17 -fcoroutines -w" }
 
 #include "coro.h"
 
diff --git a/gcc/testsuite/g++.dg/coroutines/co-await-syntax-10.C 
b/gcc/testsuite/g++.dg/coroutines/co-await-syntax-10.C
index 8304344c826..dfa24a81b94 100644
--- a/gcc/testsuite/g++.dg/coroutines/co-await-syntax-10.C
+++ b/gcc/testsuite/g++.dg/coroutines/co-await-syntax-10.C
@@ -1,4 +1,4 @@
-//  { dg-additional-options "-std=c++17 -w" }
+//  { dg-additional-options "-std=c++17 -fcoroutines -w" }
 
 #include "coro.h"
 
diff --git a/gcc/testsuite/g++.dg/coroutines/co-await-syntax-11.C 
b/gcc/testsuite/g++.dg/coroutines/co-await-syntax-11.C
index 69810ab5caa..acee8885052 100644
--- a/gcc/testsuite/g++.dg/coroutines/co-await-syntax-11.C
+++ b/gcc/testsuite/g++.dg/coroutines/co-await-syntax-11.C
@@ -1,4 +1,4 @@
-//  { dg-additional-options "-std=c++17 -w" }
+//  { dg-additional-options "-std=c++17 -fcoroutines -w" }
 
 #include <utility>
 #include <type_traits>
diff --git a/gcc/testsuite/g++.dg/coroutines/co-await-void_type.C 
b/gcc/testsuite/g++.dg/coroutines/co-await-void_type.C
index 370068fb5cb..f35faaff8f4 100644
--- a/gcc/testsuite/g++.dg/coroutines/co-await-void_type.C
+++ b/gcc/testsuite/g++.dg/coroutines/co-await-void_type.C
@@ -1,4 +1,4 @@
-//  { dg-additional-options "-std=c++17 -fsyntax-only -w" }
+//  { dg-additional-options "-std=c++17 -fsyntax-only -fcoroutines -w" }
 
 #include <coroutine>
 
diff --git a/gcc/testsuite/g++.dg/coroutines/co-return-warning-1.C 
b/gcc/testsuite/g++.dg/coroutines/co-return-warning-1.C
index b2aaba15ae3..ef3948c3f5f 100644
--- a/gcc/testsuite/g++.dg/coroutines/co-return-warning-1.C
+++ b/gcc/testsuite/g++.dg/coroutines/co-return-warning-1.C
@@ -1,4 +1,4 @@
-//  { dg-additional-options "-std=c++17 -w" }
+//  { dg-additional-options "-std=c++17 -fcoroutines -w" }
 
 #include <coroutine>
 
diff --git a/gcc/testsuite/g++.dg/coroutines/ramp-return-a.C 
b/gcc/testsuite/g++.dg/coroutines/ramp-return-a.C
index fcea6f9975f..543f92fdb28 100644
--- a/gcc/testsuite/g++.dg/coroutines/ramp-return-a.C
+++ b/gcc/testsuite/g++.dg/coroutines/ramp-return-a.C
@@ -1,4 +1,4 @@
-//  { dg-additional-options "-std=c++14" }
+//  { dg-additional-options "-std=c++14 -fcoroutines" }
 //  { dg-skip-if "requires hosted libstdc++ for vector in ramp-return.h" { ! 
hostedlib } }
 
 #include "ramp-return.h"
diff --git a/gcc/testsuite/g++.dg/coroutines/ramp-return-c.C 
b/gcc/testsuite/g++.dg/coroutines/ramp-return-c.C
index 0992924b434..d5ea3f9491d 100644
--- a/gcc/testsuite/g++.dg/coroutines/ramp-return-c.C
+++ b/gcc/testsuite/g++.dg/coroutines/ramp-return-c.C
@@ -1,4 +1,4 @@
-//  { dg-additional-options "-std=c++17" }
+//  { dg-additional-options "-std=c++17 -fcoroutines" }
 //  { dg-skip-if "requires hosted libstdc++ for vector in ramp-return.h" { ! 
hostedlib } }
 #define DELETE_COPY_CTOR 1
 #include "ramp-return.h"
diff --git a/gcc/testsuite/g++.dg/coroutines/coroutines.exp 
b/gcc/testsuite/g++.dg/coroutines/coroutines.exp
deleted file mode 100644
index 395e3f73444..00000000000
--- a/gcc/testsuite/g++.dg/coroutines/coroutines.exp
+++ /dev/null
@@ -1,50 +0,0 @@
-#   Copyright (C) 2018-2025 Free Software Foundation, Inc.
-
-# Contributed by Iain Sandoe <i...@sandoe.co.uk> under contract to Facebook.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with GCC; see the file COPYING3.  If not see
-# <http://www.gnu.org/licenses/>.
-
-# Test C++ coroutines, requires c++17; doesn't, at present, seem much 
-# point in repeating these for other versions.
-
-# Load support procs.
-load_lib g++-dg.exp
-
-# If a testcase doesn't have special options, use these.
-global DEFAULT_CXXFLAGS
-if ![info exists DEFAULT_CXXFLAGS] then {
-    set DEFAULT_CXXFLAGS " -pedantic-errors -Wno-long-long"
-}
-
-set DEFAULT_COROFLAGS $DEFAULT_CXXFLAGS
-lappend DEFAULT_COROFLAGS "-std=c++20"
-
-dg-init
-
-# Run the tests.
-# g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] \
-#        "" $DEFAULT_COROFLAGS
-
-foreach test [lsort [find $srcdir/$subdir {*.[CH]}]] {
-    if [runtest_file_p $runtests $test] {
-        set nshort [file tail [file dirname $test]]/[file tail $test]
-        verbose "Testing $nshort $DEFAULT_COROFLAGS" 1
-        dg-test $test "" $DEFAULT_COROFLAGS
-        set testcase [string range $test [string length "$srcdir/"] end]
-    }
-}
-
-# done.
-dg-finish
diff --git a/gcc/testsuite/lib/g++-dg.exp b/gcc/testsuite/lib/g++-dg.exp
index eb7a9714bc4..042a9171c75 100644
--- a/gcc/testsuite/lib/g++-dg.exp
+++ b/gcc/testsuite/lib/g++-dg.exp
@@ -41,6 +41,7 @@ proc g++-std-flags { test } {
 
        set low 0
        # Some directories expect certain minimums.
+       if { [string match "*/coroutines/*" $test] } { set low 20 }
        if { [string match "*/modules/*" $test] } { set low 17 }
 
        # See g++.exp for the initial value of this list.

base-commit: 9a2083f025fae3559474b961943484d764c2e6dd
-- 
2.49.0

Reply via email to