blob: 5bdb232d5307ce1e96c75a402020b4cc0b9adeae [file] [log] [blame]
Eric Fiselier37b8a372017-05-31 19:36:59 +00001// 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
4using namespace std::experimental;
5
6
7struct 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
15struct 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
26coro_t f(int n) {
27 if (n == 0)
28 co_return;
29 co_yield 42;
30 int x = co_await A{};
31}
32
33template <class Await>
34coro_t g(int n) {
35 if (n == 0)
36 co_return;
37 co_yield 42;
38 int x = co_await Await{};
39}
40
41int main() {
42 f(0);
43 g<A>(0);
44}