Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / ubsan-coroutines.cpp
blob04ab0505f140148e3ce795d12bff39b0889bf8a5
1 // This test merely verifies that emitting the object file does not cause a
2 // crash when the LLVM coroutines passes are run.
3 // RUN: %clang_cc1 -emit-obj -std=c++2a -fsanitize=null %s -o %t.o
5 namespace std {
6 template <typename R, typename... T> struct coroutine_traits {
7 using promise_type = typename R::promise_type;
8 };
10 template <class Promise = void> struct coroutine_handle;
11 template <> struct coroutine_handle<void> {
12 static coroutine_handle from_address(void *) noexcept;
13 coroutine_handle() = default;
14 template <class PromiseType>
15 coroutine_handle(coroutine_handle<PromiseType>) noexcept;
17 template <class Promise> struct coroutine_handle : coroutine_handle<void> {
18 coroutine_handle() = default;
19 static coroutine_handle from_address(void *) noexcept;
21 } // namespace std
23 struct suspend_always {
24 bool await_ready() noexcept;
25 void await_suspend(std::coroutine_handle<>) noexcept;
26 void await_resume() noexcept;
29 struct task {
30 struct promise_type {
31 task get_return_object() { return task(); }
32 suspend_always initial_suspend() { return {}; }
33 suspend_always final_suspend() noexcept { return {}; }
34 void return_void() {}
35 void unhandled_exception() {}
39 struct awaitable {
40 task await() { (void)co_await *this; }
41 bool await_ready() { return false; }
42 bool await_suspend(std::coroutine_handle<> awaiter) { return false; }
43 bool await_resume() { return false; }
46 int main() {
47 awaitable a;
48 a.await();