c++: remove coroutines.exp

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.
This commit is contained in:
Jason Merrill
2025-05-10 11:24:38 -04:00
parent d31ab498b1
commit de3cbcf973
10 changed files with 12 additions and 63 deletions

View File

@@ -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";
}

View File

@@ -1,4 +1,4 @@
// { dg-additional-options "-std=c++17 -w" }
// { dg-additional-options "-std=c++17 -fcoroutines -w" }
#include "coro.h"

View File

@@ -1,4 +1,4 @@
// { dg-additional-options "-std=c++17 -w" }
// { dg-additional-options "-std=c++17 -fcoroutines -w" }
#include "coro.h"

View File

@@ -1,4 +1,4 @@
// { dg-additional-options "-std=c++17 -w" }
// { dg-additional-options "-std=c++17 -fcoroutines -w" }
#include <utility>
#include <type_traits>

View File

@@ -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>

View File

@@ -1,4 +1,4 @@
// { dg-additional-options "-std=c++17 -w" }
// { dg-additional-options "-std=c++17 -fcoroutines -w" }
#include <coroutine>

View File

@@ -1,50 +0,0 @@
# Copyright (C) 2018-2025 Free Software Foundation, Inc.
# Contributed by Iain Sandoe <iain@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

View File

@@ -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"

View File

@@ -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"

View File

@@ -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.