Eric Fiselier | 37b8a37 | 2017-05-31 19:36:59 +0000 | [diff] [blame] | 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.h" |
| 3 | |
| 4 | using namespace std::experimental; |
| 5 | |
| 6 | |
| 7 | struct A { |
| 8 | bool await_ready() { return true; } |
| 9 | int await_resume() { return 42; } |
| 10 | template <typename F> |
| 11 | void await_suspend(F) {} |
| 12 | }; |
| 13 | |
| 14 | |
| 15 | struct coro_t { |
| 16 | struct promise_type { |
| 17 | coro_t get_return_object() { return {}; } |
| 18 | suspend_never initial_suspend() { return {}; } |
| 19 | suspend_never final_suspend() { return {}; } |
| 20 | A yield_value(int) { return {}; } |
| 21 | void return_void() {} |
| 22 | static void unhandled_exception() {} |
| 23 | }; |
| 24 | }; |
| 25 | |
| 26 | coro_t f(int n) { |
| 27 | if (n == 0) |
| 28 | co_return; |
| 29 | co_yield 42; |
| 30 | int x = co_await A{}; |
| 31 | } |
| 32 | |
| 33 | template <class Await> |
| 34 | coro_t g(int n) { |
| 35 | if (n == 0) |
| 36 | co_return; |
| 37 | co_yield 42; |
| 38 | int x = co_await Await{}; |
| 39 | } |
| 40 | |
| 41 | int main() { |
| 42 | f(0); |
| 43 | g<A>(0); |
| 44 | } |