[PATCH] D26038: [coroutines] Sema: Allow co_return all by itself.
Gor Nishanov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 9 15:12:28 PST 2017
GorNishanov updated this revision to Diff 83717.
GorNishanov added a comment.
merged with latest. Preparing to land.
https://reviews.llvm.org/D26038
Files:
include/clang/Basic/DiagnosticSemaKinds.td
lib/Sema/SemaCoroutine.cpp
test/SemaCXX/coroutines.cpp
Index: test/SemaCXX/coroutines.cpp
===================================================================
--- test/SemaCXX/coroutines.cpp
+++ test/SemaCXX/coroutines.cpp
@@ -154,12 +154,11 @@
}
void only_coreturn(void_tag) {
- co_return; // expected-warning {{'co_return' used in a function that uses neither 'co_await' nor 'co_yield'}}
+ co_return; // OK
}
void mixed_coreturn(void_tag, bool b) {
if (b)
- // expected-warning at +1 {{'co_return' used in a function that uses neither}}
co_return; // expected-note {{use of 'co_return'}}
else
return; // expected-error {{not allowed in coroutine}}
Index: lib/Sema/SemaCoroutine.cpp
===================================================================
--- lib/Sema/SemaCoroutine.cpp
+++ lib/Sema/SemaCoroutine.cpp
@@ -578,17 +578,6 @@
isa<CoyieldExpr>(First) ? 1 : 2);
}
- bool AnyCoawaits = false;
- bool AnyCoyields = false;
- for (auto *CoroutineStmt : Fn->CoroutineStmts) {
- AnyCoawaits |= isa<CoawaitExpr>(CoroutineStmt);
- AnyCoyields |= isa<CoyieldExpr>(CoroutineStmt);
- }
-
- if (!AnyCoawaits && !AnyCoyields)
- Diag(Fn->CoroutineStmts.front()->getLocStart(),
- diag::ext_coroutine_without_co_await_co_yield);
-
SourceLocation Loc = FD->getLocation();
// Form a declaration statement for the promise declaration, so that AST
Index: include/clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8720,10 +8720,6 @@
"|a copy assignment operator|a move assignment operator|the 'main' function"
"|a constexpr function|a function with a deduced return type"
"|a varargs function}0">;
-def ext_coroutine_without_co_await_co_yield : ExtWarn<
- "'co_return' used in a function "
- "that uses neither 'co_await' nor 'co_yield'">,
- InGroup<DiagGroup<"coreturn-without-coawait">>;
def err_implied_std_coroutine_traits_not_found : Error<
"you need to include <experimental/coroutine> before defining a coroutine">;
def err_malformed_std_coroutine_traits : Error<
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26038.83717.patch
Type: text/x-patch
Size: 2143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170109/6cf86928/attachment.bin>
More information about the llvm-commits
mailing list