coro-ret-void.cpp
1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// RUN: %clang_cc1 -std=c++14 -fcoroutines-ts -triple=x86_64-unknown-linux-gnu -emit-llvm %s -o - -disable-llvm-passes | FileCheck %s
#include "Inputs/coroutine.h"
namespace coro = std::experimental::coroutines_v1;
struct coro1 {
struct promise_type {
coro1 get_return_object();
coro::suspend_never initial_suspend();
coro::suspend_never final_suspend() noexcept;
void return_void();
};
};
coro1 f() {
co_await coro::suspend_never{};
}
// CHECK-LABEL: define void @_Z1fv(
// CHECK: call void @_ZNSt12experimental13coroutines_v113suspend_never12await_resumeEv(%"struct.std::experimental::coroutines_v1::suspend_never"*
// CHECK: call void @_ZN5coro112promise_type11return_voidEv(%"struct.coro1::promise_type"* %__promise)
struct A {
A();
~A();
};
coro1 f2() {
co_return (void) A{};
}
// CHECK-LABEL: define void @_Z2f2v(
// CHECK: call void @_ZN1AC1Ev(%struct.A* %[[AVar:.*]])
// CHECK-NEXT: call void @_ZN1AD1Ev(%struct.A* %[[AVar]])
// CHECK-NEXT: call void @_ZN5coro112promise_type11return_voidEv(%"struct.coro1::promise_type"*
struct coro2 {
struct promise_type {
coro2 get_return_object();
coro::suspend_never initial_suspend();
coro::suspend_never final_suspend() noexcept;
void return_value(int);
};
};
coro2 g() {
co_return 42;
}
// CHECK-LABEL: define void @_Z1gv(
// CHECK: call void @_ZNSt12experimental13coroutines_v113suspend_never12await_resumeEv(%"struct.std::experimental::coroutines_v1::suspend_never"*
// CHECK: call void @_ZN5coro212promise_type12return_valueEi(%"struct.coro2::promise_type"* %__promise, i32 42)