44 lines · cpp
1// RUN: %clang_cc1 -triple x86_64-apple-darwin9 %s -std=c++20 -fsyntax-only -Wall -Wextra -Wuninitialized -fblocks2#include "Inputs/std-coroutine.h"3 4using namespace std;5 6struct A {7 bool await_ready() { return true; }8 int await_resume() { return 42; }9 template <typename F>10 void await_suspend(F) {}11};12 13 14struct coro_t {15 struct promise_type {16 coro_t get_return_object() { return {}; }17 suspend_never initial_suspend() { return {}; }18 suspend_never final_suspend() noexcept { return {}; }19 A yield_value(int) { return {}; }20 void return_void() {}21 static void unhandled_exception() {}22 };23};24 25coro_t f(int n) {26 if (n == 0)27 co_return;28 co_yield 42;29 int x = co_await A{};30}31 32template <class Await>33coro_t g(int n) {34 if (n == 0)35 co_return;36 co_yield 42;37 int x = co_await Await{};38}39 40int main() {41 f(0);42 g<A>(0);43}44