1 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++14 -fcoroutines-ts -fsyntax-only -Wall -Wextra -Wuninitialized -fblocks 2 #include "Inputs/std-coroutine-exp-namespace.h" 3 4 using namespace std::experimental; 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 struct coro_t { 14 struct promise_type { get_return_objectcoro_t::promise_type15 coro_t get_return_object() { return {}; } initial_suspendcoro_t::promise_type16 suspend_never initial_suspend() { return {}; } final_suspendcoro_t::promise_type17 suspend_never final_suspend() noexcept { return {}; } yield_valuecoro_t::promise_type18 A yield_value(int) { return {}; } return_voidcoro_t::promise_type19 void return_void() {} unhandled_exceptioncoro_t::promise_type20 static void unhandled_exception() {} 21 }; 22 }; 23 f(int n)24coro_t f(int n) { 25 if (n == 0) 26 co_return; 27 co_yield 42; 28 int x = co_await A{}; 29 } 30 31 template <class Await> g(int n)32coro_t g(int n) { 33 if (n == 0) 34 co_return; 35 co_yield 42; 36 int x = co_await Await{}; 37 } 38 main()39int main() { 40 f(0); 41 g<A>(0); 42 } 43