From: Tomasz KamiƄski Date: Fri, 31 Jul 2026 14:52:09 +0000 (+0200) Subject: libstdc++: Reject user-defined specializations for coroutine_handle. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b90df55625eb40b05e0628097765d0a2cb368ced;p=thirdparty%2Fgcc.git libstdc++: Reject user-defined specializations for coroutine_handle. The P0912R5, "Merge Coroutines TS into C++20 working draft" that introduced them already included made specializing coroutine_handle ill-formed, no diagnostic required. This is QoI improvment, that produces diagnostic in such situation by decaroting base template with [[_Clang::__no_specializations]]. libstdc++-v3/ChangeLog: * include/std/coroutine: Ignore -Winvalid-specialization in file. (std::coroutine_handle): Add clang::no_specializations attribute. * testsuite/18_support/coroutines/specializations_neg.cc: New test. --- diff --git a/libstdc++-v3/include/std/coroutine b/libstdc++-v3/include/std/coroutine index 7f7295d0fa5..61ca185a1a4 100644 --- a/libstdc++-v3/include/std/coroutine +++ b/libstdc++-v3/include/std/coroutine @@ -35,6 +35,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wc++17-extensions" +#pragma GCC diagnostic ignored "-Winvalid-specialization" #define __glibcxx_want_coroutine #include @@ -195,7 +196,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif template - struct coroutine_handle + struct _GLIBCXX_NO_SPECIALIZATIONS coroutine_handle { // [coroutine.handle.con], construct/reset diff --git a/libstdc++-v3/testsuite/18_support/coroutines/specializations_neg.cc b/libstdc++-v3/testsuite/18_support/coroutines/specializations_neg.cc new file mode 100644 index 00000000000..0e7aabc6b0b --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/coroutines/specializations_neg.cc @@ -0,0 +1,18 @@ +// { dg-do compile { target c++20 } } + +#include + +struct Promise +{}; + +template<> +struct std::coroutine_handle // { dg-error "cannot be specialized" } +{}; + +template +struct PromiseTempl +{}; + +template +struct std::coroutine_handle> // { dg-error "cannot be specialized" } +{};