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.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wc++17-extensions"
+#pragma GCC diagnostic ignored "-Winvalid-specialization"
#define __glibcxx_want_coroutine
#include <bits/version.h>
#endif
template <typename _Promise>
- struct coroutine_handle
+ struct _GLIBCXX_NO_SPECIALIZATIONS coroutine_handle
{
// [coroutine.handle.con], construct/reset
--- /dev/null
+// { dg-do compile { target c++20 } }
+
+#include <coroutine>
+
+struct Promise
+{};
+
+template<>
+struct std::coroutine_handle<Promise> // { dg-error "cannot be specialized" }
+{};
+
+template<typename>
+struct PromiseTempl
+{};
+
+template<typename T>
+struct std::coroutine_handle<PromiseTempl<T>> // { dg-error "cannot be specialized" }
+{};