1 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only -Wall -Wextra -Wuninitialized -fblocks 2 #include "Inputs/std-coroutine.h" 3 4 using namespace std; 5 6 struct A { await_readyA7 bool await_ready() { return true; } await_resumeA8 int await_resume() { return 42; } 9 template <typename F> await_suspendA10 void await_suspend(F) {} 11 }; 12 13 14 struct coro_t { 15 struct promise_type { get_return_objectcoro_t::promise_type16 coro_t get_return_object() { return {}; } initial_suspendcoro_t::promise_type17 suspend_never initial_suspend() { return {}; } final_suspendcoro_t::promise_type18 suspend_never final_suspend() noexcept { return {}; } yield_valuecoro_t::promise_type19 A yield_value(int) { return {}; } return_voidcoro_t::promise_type20 void return_void() {} unhandled_exceptioncoro_t::promise_type21 static void unhandled_exception() {} 22 }; 23 }; 24 f(int n)25coro_t f(int n) { 26 if (n == 0) 27 co_return; 28 co_yield 42; 29 int x = co_await A{}; 30 } 31 32 template <class Await> g(int n)33coro_t g(int n) { 34 if (n == 0) 35 co_return; 36 co_yield 42; 37 int x = co_await Await{}; 38 } 39 main()40int main() { 41 f(0); 42 g<A>(0); 43 } 44