[clang] [C++20][Coroutines] Lambda-coroutine with operator new in promise_type (PR #84193)
Andreas Fertig via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 8 03:06:04 PST 2024
================
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -I%S/Inputs -std=c++20 %s
+
+// expected-no-diagnostics
+
+#include "std-coroutine.h"
+
+using size_t = decltype(sizeof(0));
+
+struct Generator {
+ struct promise_type {
+ int _val{};
+
+ Generator get_return_object() noexcept
+ {
+ return {};
+ }
+
+ std::suspend_never initial_suspend() noexcept
+ {
+ return {};
+ }
+
+ std::suspend_always final_suspend() noexcept
+ {
+ return {};
+ }
+
+ void return_void() noexcept {}
+ void unhandled_exception() noexcept {}
+
+ template<typename This, typename... TheRest>
+ static void*
+ operator new(size_t size,
+ This&,
+ TheRest&&...) noexcept
+ {
+ return nullptr;
+ }
+
+ static void operator delete(void*, size_t)
+ {
+ }
+ };
+};
+
+int main()
+{
+ auto lamb = []() -> Generator {
----------------
andreasfertig wrote:
I added tests that capture the `this` pointer. Please, let me know if you have new questions or if the previous ones are still open.
https://github.com/llvm/llvm-project/pull/84193
More information about the cfe-commits
mailing list