diff options
| author | Brian Gesiak <modocache@gmail.com> | 2019-11-22 11:25:19 -0500 |
|---|---|---|
| committer | Brian Gesiak <modocache@gmail.com> | 2019-11-22 11:39:13 -0500 |
| commit | 0b3d1d1348da78c8b12e89f138577b0a8ffd4b2f (patch) | |
| tree | 5e15e3f6b9722882c79230d9242a8b78f37019cf /clang | |
| parent | 6f7c8760a5c01edaa8e9c8e48940e1b8a7aa4128 (diff) | |
| download | bcm5719-llvm-0b3d1d1348da78c8b12e89f138577b0a8ffd4b2f.tar.gz bcm5719-llvm-0b3d1d1348da78c8b12e89f138577b0a8ffd4b2f.zip | |
[coroutines] Remove assert on CoroutineParameterMoves in Sema::buildCoroutineParameterMoves
Summary:
The assertion of CoroutineParameterMoves happens when build coroutine function with arguments multiple time while fails to build promise type.
Fix: use return false instead.
Test Plan: check-clang
Reviewers: modocache, GorNishanov, rjmccall
Reviewed By: modocache
Subscribers: rjmccall, EricWF, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69022
Patch by junparser (JunMa)!
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Sema/SemaCoroutine.cpp | 4 | ||||
| -rw-r--r-- | clang/test/SemaCXX/coroutines.cpp | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp index 7c125e999d0..271c4a10f3e 100644 --- a/clang/lib/Sema/SemaCoroutine.cpp +++ b/clang/lib/Sema/SemaCoroutine.cpp @@ -1527,8 +1527,8 @@ bool Sema::buildCoroutineParameterMoves(SourceLocation Loc) { auto *FD = cast<FunctionDecl>(CurContext); auto *ScopeInfo = getCurFunction(); - assert(ScopeInfo->CoroutineParameterMoves.empty() && - "Should not build parameter moves twice"); + if (!ScopeInfo->CoroutineParameterMoves.empty()) + return false; for (auto *PD : FD->parameters()) { if (PD->getType()->isDependentType()) diff --git a/clang/test/SemaCXX/coroutines.cpp b/clang/test/SemaCXX/coroutines.cpp index c8de7b01785..677c6e6ff8d 100644 --- a/clang/test/SemaCXX/coroutines.cpp +++ b/clang/test/SemaCXX/coroutines.cpp @@ -87,6 +87,11 @@ int no_promise_type() { // expected-error {{this function cannot be a coroutine: co_await a; } +int no_promise_type_multiple_awaits(int) { // expected-error {{this function cannot be a coroutine: 'std::experimental::coroutine_traits<int, int>' has no member named 'promise_type'}} + co_await a; + co_await a; +} + template <> struct std::experimental::coroutine_traits<double, double> { typedef int promise_type; }; double bad_promise_type(double) { // expected-error {{this function cannot be a coroutine: 'experimental::coroutine_traits<double, double>::promise_type' (aka 'int') is not a class}} |

