r297358 - [coroutines] Fix assertion in DependentCoawaitExpr when the argument is non-dependent.
Eric Fiselier via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 8 21:01:32 PST 2017
Author: ericwf
Date: Wed Mar 8 23:01:31 2017
New Revision: 297358
URL: http://llvm.org/viewvc/llvm-project?rev=297358&view=rev
Log:
[coroutines] Fix assertion in DependentCoawaitExpr when the argument is non-dependent.
Summary:
A `co_await arg` expression has a dependent type whenever the promise type is still dependent, even if the argument to co_await is not. This is because we cannot attempt the `await_transform(<arg>)` until after we know the promise type.
This patch fixes an assertion in the constructor of `DependentCoawaitExpr` that asserted that `arg` must also be dependent.
Reviewers: rsmith, GorNishanov, aaron.ballman
Reviewed By: GorNishanov
Subscribers: mehdi_amini, cfe-commits
Differential Revision: https://reviews.llvm.org/D30772
Modified:
cfe/trunk/include/clang/AST/ExprCXX.h
cfe/trunk/test/SemaCXX/coroutines.cpp
Modified: cfe/trunk/include/clang/AST/ExprCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExprCXX.h?rev=297358&r1=297357&r2=297358&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ExprCXX.h (original)
+++ cfe/trunk/include/clang/AST/ExprCXX.h Wed Mar 8 23:01:31 2017
@@ -4236,7 +4236,9 @@ public:
/*InstantiationDependent*/ true,
Op->containsUnexpandedParameterPack()),
KeywordLoc(KeywordLoc) {
- assert(Op->isTypeDependent() && Ty->isDependentType() &&
+ // NOTE: A co_await expression is dependent on the coroutines promise
+ // type and may be dependent even when the `Op` expression is not.
+ assert(Ty->isDependentType() &&
"wrong constructor for non-dependent co_await/co_yield expression");
SubExprs[0] = Op;
SubExprs[1] = OpCoawait;
Modified: cfe/trunk/test/SemaCXX/coroutines.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/coroutines.cpp?rev=297358&r1=297357&r2=297358&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/coroutines.cpp (original)
+++ cfe/trunk/test/SemaCXX/coroutines.cpp Wed Mar 8 23:01:31 2017
@@ -151,6 +151,12 @@ void coreturn(int n) {
co_return 42;
}
+template <class T>
+void co_await_non_dependent_arg(T) {
+ co_await a;
+}
+template void co_await_non_dependent_arg(int);
+
void mixed_yield() {
co_yield 0; // expected-note {{use of 'co_yield'}}
return; // expected-error {{not allowed in coroutine}}
More information about the cfe-commits
mailing list