diff options
author | Gor Nishanov <GorNishanov@gmail.com> | 2017-01-10 00:08:31 +0000 |
---|---|---|
committer | Gor Nishanov <GorNishanov@gmail.com> | 2017-01-10 00:08:31 +0000 |
commit | 4c19d05d1671a6b602d59a1dadee0d2ab2399ff8 (patch) | |
tree | 6cec623aa9f574dada37643db99419374ce4f405 | |
parent | b62544540682e5e9418ba65b69c081d6c029cd43 (diff) |
[coroutines] Sema: Allow co_return all by itself.
Reviewers: rsmith, EricWF
Subscribers: mehdi_amini, llvm-commits, EricWF
Differential Revision: https://reviews.llvm.org/D26038
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291513 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.td | 4 | ||||
-rw-r--r-- | lib/Sema/SemaCoroutine.cpp | 11 | ||||
-rw-r--r-- | test/SemaCXX/coroutines.cpp | 3 |
3 files changed, 1 insertions, 17 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 6a8933f23e..3971cf60d5 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -8720,10 +8720,6 @@ def err_coroutine_invalid_func_context : Error< "|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< diff --git a/lib/Sema/SemaCoroutine.cpp b/lib/Sema/SemaCoroutine.cpp index 3109358df4..f6115c1bee 100644 --- a/lib/Sema/SemaCoroutine.cpp +++ b/lib/Sema/SemaCoroutine.cpp @@ -578,17 +578,6 @@ void Sema::CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body) { 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 diff --git a/test/SemaCXX/coroutines.cpp b/test/SemaCXX/coroutines.cpp index a22383cd56..158b1a7c7d 100644 --- a/test/SemaCXX/coroutines.cpp +++ b/test/SemaCXX/coroutines.cpp @@ -154,12 +154,11 @@ void mixed_await() { } 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@+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}} |