Debian Codegraph @

clang/test/CodeGenCXX/ubsan-coroutines.cpp

raw
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
4 // UNSUPPORTED: target={{.*}}-zos{{.*}}
5
6 namespace std {
7 template <typename R, typename... T> struct coroutine_traits {
8 using promise_type = typename R::promise_type;
9 };
10
11 template <class Promise = void> struct coroutine_handle;
12 template <> struct coroutine_handle<void> {
13 static coroutine_handle from_address(void *) noexcept;
14 coroutine_handle() = default;
15 template <class PromiseType>
16 coroutine_handle(coroutine_handle<PromiseType>) noexcept;
17 };
18 template <class Promise> struct coroutine_handle : coroutine_handle<void> {
19 coroutine_handle() = default;
20 static coroutine_handle from_address(void *) noexcept;
21 };
22 } // namespace std
23
24 struct suspend_always {
25 bool await_ready() noexcept;
26 void await_suspend(std::coroutine_handle<>) noexcept;
27 void await_resume() noexcept;
28 };
29
30 struct task {
31 struct promise_type {
32 task get_return_object() { return task(); }
33 suspend_always initial_suspend() { return {}; }
34 suspend_always final_suspend() noexcept { return {}; }
35 void return_void() {}
36 void unhandled_exception() {}
37 };
38 };
39
40 struct awaitable {
41 task await() { (void)co_await *this; }
42 bool await_ready() { return false; }
43 bool await_suspend(std::coroutine_handle<> awaiter) { return false; }
44 bool await_resume() { return false; }
45 };
46
47 int main() {
48 awaitable a;
49 a.await();
50 }