summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/coroutines.cpp
diff options
context:
space:
mode:
authorGor Nishanov <GorNishanov@gmail.com>2017-03-27 23:36:59 +0000
committerGor Nishanov <GorNishanov@gmail.com>2017-03-27 23:36:59 +0000
commit3aa9eb38a076ab116ad752c5d1177f63461f7bd1 (patch)
tree1a39a2dee987998503e100978f3ab172621ef316 /clang/test/SemaCXX/coroutines.cpp
parentbbd5cc63d7be58d8f63bc4a3cac4c0769efc6337 (diff)
downloadbcm5719-llvm-3aa9eb38a076ab116ad752c5d1177f63461f7bd1.tar.gz
bcm5719-llvm-3aa9eb38a076ab116ad752c5d1177f63461f7bd1.zip
[coroutines] Handle get_return_object_on_allocation_failure
Summary: If promise_type has get_return_object_on_allocation_failure defined, check if an allocation function returns nullptr, and if so, return the result of get_return_object_on_allocation_failure(). Reviewers: rsmith, EricWF Reviewed By: EricWF Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D31399 llvm-svn: 298891
Diffstat (limited to 'clang/test/SemaCXX/coroutines.cpp')
-rw-r--r--clang/test/SemaCXX/coroutines.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/coroutines.cpp b/clang/test/SemaCXX/coroutines.cpp
index 6849f0682c6..a75c2d62f91 100644
--- a/clang/test/SemaCXX/coroutines.cpp
+++ b/clang/test/SemaCXX/coroutines.cpp
@@ -634,3 +634,21 @@ float badly_specialized_coro_handle() { // expected-error {{std::experimental::c
//expected-note@-1 {{call to 'initial_suspend' implicitly required by the initial suspend point}}
co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
}
+
+struct promise_on_alloc_failure_tag {};
+
+template<>
+struct std::experimental::coroutine_traits<int, promise_on_alloc_failure_tag> {
+ struct promise_type {
+ int get_return_object() {}
+ suspend_always initial_suspend() { return {}; }
+ suspend_always final_suspend() { return {}; }
+ void return_void() {}
+ int get_return_object_on_allocation_failure(); // expected-error{{'promise_type': 'get_return_object_on_allocation_failure()' must be a static member function}}
+ void unhandled_exception();
+ };
+};
+
+extern "C" int f(promise_on_alloc_failure_tag) {
+ co_return; //expected-note {{function is a coroutine due to use of 'co_return' here}}
+}
OpenPOWER on IntegriCloud