diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-09-29 21:47:39 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-09-29 21:47:39 +0000 |
commit | a546528d7b929a1494141ebd73da5c081c45b15d (patch) | |
tree | a9da92ab23e4511aa221e5a9d408d6256520e808 /clang/lib/Sema/SemaCoroutine.cpp | |
parent | fa47ff3349b3f68c02c04c624cf7da4cd32e0b51 (diff) | |
download | bcm5719-llvm-a546528d7b929a1494141ebd73da5c081c45b15d.tar.gz bcm5719-llvm-a546528d7b929a1494141ebd73da5c081c45b15d.zip |
[Coroutines] Fix assertion about uncorrected typos in co_await/co_yield/co_return expressions
llvm-svn: 282792
Diffstat (limited to 'clang/lib/Sema/SemaCoroutine.cpp')
-rw-r--r-- | clang/lib/Sema/SemaCoroutine.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp index c8715fff415..51430360886 100644 --- a/clang/lib/Sema/SemaCoroutine.cpp +++ b/clang/lib/Sema/SemaCoroutine.cpp @@ -213,6 +213,11 @@ static ReadySuspendResumeResult buildCoawaitCalls(Sema &S, SourceLocation Loc, } ExprResult Sema::ActOnCoawaitExpr(Scope *S, SourceLocation Loc, Expr *E) { + auto *Coroutine = checkCoroutineContext(*this, Loc, "co_await"); + if (!Coroutine) { + CorrectDelayedTyposInExpr(E); + return ExprError(); + } if (E->getType()->isPlaceholderType()) { ExprResult R = CheckPlaceholderExpr(E); if (R.isInvalid()) return ExprError(); @@ -222,6 +227,7 @@ ExprResult Sema::ActOnCoawaitExpr(Scope *S, SourceLocation Loc, Expr *E) { ExprResult Awaitable = buildOperatorCoawaitCall(*this, S, Loc, E); if (Awaitable.isInvalid()) return ExprError(); + return BuildCoawaitExpr(Loc, Awaitable.get()); } ExprResult Sema::BuildCoawaitExpr(SourceLocation Loc, Expr *E) { @@ -275,8 +281,10 @@ static ExprResult buildPromiseCall(Sema &S, FunctionScopeInfo *Coroutine, ExprResult Sema::ActOnCoyieldExpr(Scope *S, SourceLocation Loc, Expr *E) { auto *Coroutine = checkCoroutineContext(*this, Loc, "co_yield"); - if (!Coroutine) + if (!Coroutine) { + CorrectDelayedTyposInExpr(E); return ExprError(); + } // Build yield_value call. ExprResult Awaitable = @@ -325,6 +333,11 @@ ExprResult Sema::BuildCoyieldExpr(SourceLocation Loc, Expr *E) { } StmtResult Sema::ActOnCoreturnStmt(SourceLocation Loc, Expr *E) { + auto *Coroutine = checkCoroutineContext(*this, Loc, "co_return"); + if (!Coroutine) { + CorrectDelayedTyposInExpr(E); + return StmtError(); + } return BuildCoreturnStmt(Loc, E); } StmtResult Sema::BuildCoreturnStmt(SourceLocation Loc, Expr *E) { |