Skip to content
Permalink
Browse files

[coroutines] Remove assert on CoroutineParameterMoves in Sema::buildC…

…oroutineParameterMoves

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)!
  • Loading branch information
modocache committed Nov 22, 2019
1 parent 6f7c876 commit 0b3d1d1348da78c8b12e89f138577b0a8ffd4b2f
Showing with 7 additions and 2 deletions.
  1. +2 −2 clang/lib/Sema/SemaCoroutine.cpp
  2. +5 −0 clang/test/SemaCXX/coroutines.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())
@@ -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}}

0 comments on commit 0b3d1d1

Please sign in to comment.
You can’t perform that action at this time.