From 29f0e90d9904d8e0965443d4da4c95ddde5edb1e Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Fri, 15 May 2020 17:59:49 -0400 Subject: [PATCH] c++: Enable coroutines with -std=c++20. Now that GCC 10 is out it seems time. People can still choose to disable coroutines with -fno-coroutines. This also switches the coroutines testsuite to run in C++20 mode. The change to coro.h is only necessary for co-await-11-forwarding.C; we could alternatively #include just in that file. gcc/c-family/ChangeLog 2020-05-15 Jason Merrill * c-opts.c (set_std_cxx20): Set flag_coroutines. gcc/testsuite/ChangeLog 2020-05-15 Jason Merrill * g++.dg/coroutines/coro.h: Always #include . * g++.dg/coroutines/coroutines.exp (DEFAULT_COROFLAGS): Use -std=c++20. --- gcc/c-family/ChangeLog | 4 ++++ gcc/c-family/c-opts.c | 7 ++++--- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/coroutines/coro.h | 10 ++-------- gcc/testsuite/g++.dg/coroutines/coroutines.exp | 2 +- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 7bd78c085da..da4be414b6c 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2020-05-15 Jason Merrill + + * c-opts.c (set_std_cxx20): Set flag_coroutines. + 2020-05-13 Jason Merrill * c.opt (std=c++20): Make c++2a the alias. diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index bd617d3df18..7695e88c130 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -1722,7 +1722,7 @@ set_std_cxx17 (int iso) lang_hooks.name = "GNU C++17"; } -/* Set the C++ 202a draft standard (without GNU extensions if ISO). */ +/* Set the C++ 2020 standard (without GNU extensions if ISO). */ static void set_std_cxx20 (int iso) { @@ -1734,9 +1734,10 @@ set_std_cxx20 (int iso) flag_isoc94 = 1; flag_isoc99 = 1; flag_isoc11 = 1; - /* C++20 includes concepts. */ + /* C++20 includes coroutines. */ + flag_coroutines = true; cxx_dialect = cxx20; - lang_hooks.name = "GNU C++17"; /* Pretend C++17 until standardization. */ + lang_hooks.name = "GNU C++20"; } /* Args to -d specify what to dump. Silently ignore diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fb93dbb927b..875ac82fb34 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-05-15 Jason Merrill + + * g++.dg/coroutines/coro.h: Always #include . + * g++.dg/coroutines/coroutines.exp (DEFAULT_COROFLAGS): Use + -std=c++20. + 2020-05-15 Segher Boessenkool * gcc.target/powerpc/vec-gnb-0.c: Use int128 effective target. diff --git a/gcc/testsuite/g++.dg/coroutines/coro.h b/gcc/testsuite/g++.dg/coroutines/coro.h index fccfe418616..02d26602727 100644 --- a/gcc/testsuite/g++.dg/coroutines/coro.h +++ b/gcc/testsuite/g++.dg/coroutines/coro.h @@ -2,20 +2,12 @@ #include -# if __clang__ -# include -# endif - namespace coro = std; #elif __has_include() #include -# if __clang__ -# include -# endif - namespace coro = std::experimental; #else @@ -143,6 +135,8 @@ extern "C" int printf (const char *, ...); #include /* for abort () */ +#include /* for std::forward */ + #ifndef OUTPUT # define PRINT(X) # define PRINTF (void) diff --git a/gcc/testsuite/g++.dg/coroutines/coroutines.exp b/gcc/testsuite/g++.dg/coroutines/coroutines.exp index e7fd4dac461..1bef98ae54d 100644 --- a/gcc/testsuite/g++.dg/coroutines/coroutines.exp +++ b/gcc/testsuite/g++.dg/coroutines/coroutines.exp @@ -29,7 +29,7 @@ if ![info exists DEFAULT_CXXFLAGS] then { } set DEFAULT_COROFLAGS $DEFAULT_CXXFLAGS -lappend DEFAULT_COROFLAGS "-std=c++17" "-fcoroutines" +lappend DEFAULT_COROFLAGS "-std=c++20" dg-init -- 2.30.2