1 // { dg-do run } 2 // { dg-output "coroutine name: MyFoo" } 3 #include <coroutine> 4 #include <cstdio> 5 6 struct pt 7 { 8 using handle_t = std::coroutine_handle<pt>; get_return_objectpt9 auto get_return_object() noexcept { return handle_t::from_promise(*this); } 10 initial_suspendpt11 std::suspend_never initial_suspend () const noexcept { return {}; } final_suspendpt12 std::suspend_never final_suspend () const noexcept { return {}; } return_voidpt13 void return_void() const noexcept {} unhandled_exceptionpt14 void unhandled_exception() const noexcept {} 15 }; 16 17 template <> struct std::coroutine_traits<pt::handle_t> 18 { using promise_type = pt; }; 19 20 static pt::handle_t MyFoo () 21 { 22 printf ("coroutine name: %s\n", __builtin_FUNCTION()); 23 co_return; 24 } 25 26 int main() 27 { 28 MyFoo (); 29 } 30