@@ -1053,7 +1053,8 @@ build_co_await (location_t loc, tree a, suspend_point_kind suspend_kind)
else if (same_type_p (susp_return_type, boolean_type_node))
ok = true;
else if (TREE_CODE (susp_return_type) == RECORD_TYPE
- && CLASS_TYPE_P (susp_return_type))
+ && CLASS_TYPE_P (susp_return_type)
+ && CLASSTYPE_TEMPLATE_INFO (susp_return_type))
{
tree tt = CLASSTYPE_TI_TEMPLATE (susp_return_type);
if (tt == coro_handle_templ)
new file mode 100644
@@ -0,0 +1,18 @@
+// { dg-additional-options "-fsyntax-only -w" }
+
+// Diagnose bad coroutine awatiable type.
+
+#include<coroutine>
+
+struct coro{
+ struct not_a_template{};
+ using promise_type = coro;
+ static constexpr std::suspend_always initial_suspend()noexcept{ return {}; }
+ constexpr bool await_ready()noexcept{ return false; }
+ constexpr not_a_template await_suspend(std::coroutine_handle<>)noexcept{ return{}; }
+ constexpr void await_resume()noexcept{}
+ static coro body()
+ {
+ co_await coro{}; // { dg-error {'await_suspend' must return 'void', 'bool' or a coroutine handle} }
+ }
+};