[PATCH] D37454: [coroutines] desugar auto type of await_resume before checking whether it is void or bool
Gor Nishanov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 4 17:12:43 PDT 2017
GorNishanov created this revision.
https://reviews.llvm.org/D37454
Files:
lib/Sema/SemaCoroutine.cpp
test/SemaCXX/coroutines.cpp
Index: test/SemaCXX/coroutines.cpp
===================================================================
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -66,6 +66,12 @@
void await_resume() {}
};
+struct auto_await_suspend {
+ bool await_ready();
+ template <typename F> auto await_suspend(F) {}
+ void await_resume();
+};
+
struct DummyVoidTag {};
DummyVoidTag no_specialization() { // expected-error {{this function cannot be a coroutine: 'std::experimental::coroutine_traits<DummyVoidTag>' has no member named 'promise_type'}}
co_await a;
@@ -159,6 +165,10 @@
co_yield yield; // expected-error {{no member named 'await_ready' in 'not_awaitable'}}
}
+void check_auto_await_suspend() {
+ co_await auto_await_suspend{}; // OK
+}
+
void coreturn(int n) {
co_await a;
if (n == 0)
Index: lib/Sema/SemaCoroutine.cpp
===================================================================
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -444,6 +444,9 @@
else {
// non-class prvalues always have cv-unqualified types
QualType AdjRetType = RetType.getUnqualifiedType();
+ if (auto *AT = dyn_cast<AutoType>(AdjRetType))
+ AdjRetType = AT->desugar();
+
if (RetType->isReferenceType() ||
(AdjRetType != S.Context.BoolTy && AdjRetType != S.Context.VoidTy)) {
S.Diag(AwaitSuspend->getCalleeDecl()->getLocation(),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37454.113798.patch
Type: text/x-patch
Size: 1416 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170905/e35f144d/attachment.bin>
More information about the cfe-commits
mailing list