[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / coroutine-dealloc.cpp
blob762a14465b297cc3c3d246df6639d094252ccffb
1 // Tests that the behavior will be good if there are multiple operator delete in the promise_type.
2 // RUN: %clang_cc1 %s -std=c++20 %s -fsyntax-only -verify
3 // expected-no-diagnostics
5 #include "Inputs/std-coroutine.h"
7 namespace std {
8 typedef __SIZE_TYPE__ size_t;
9 enum class align_val_t : size_t {};
12 struct task {
13 struct promise_type {
14 auto initial_suspend() { return std::suspend_always{}; }
15 auto final_suspend() noexcept { return std::suspend_always{}; }
16 auto get_return_object() { return task{}; }
17 void unhandled_exception() {}
18 void return_value(int) {}
20 void operator delete(void *ptr, void *meaningless_placeholder);
21 void operator delete(void *ptr);
25 task f() {
26 co_return 43;
29 // From https://github.com/llvm/llvm-project/issues/60545
30 struct generator {
31 struct promise_type {
32 generator get_return_object();
33 std::suspend_always initial_suspend();
34 std::suspend_always final_suspend() noexcept;
35 void return_void();
36 [[noreturn]] void unhandled_exception();
38 static void* operator new(std::size_t size);
39 static void operator delete(void* ptr, const std::size_t size);
43 generator goo() { co_return; }