diff options
author | JunMa <JunMa@linux.alibaba.com> | 2020-02-05 13:46:59 +0800 |
---|---|---|
committer | JunMa <JunMa@linux.alibaba.com> | 2020-03-03 11:18:54 +0800 |
commit | fd9e021c70edf459e5d700af90bfe005dc0afb3b (patch) | |
tree | 7c98f9efe3f20176db35955ec725c2583220691c /gcc/cp | |
parent | 3f33c471bbf745216e0601cb629144b34642c9b9 (diff) | |
download | gcc-fd9e021c70edf459e5d700af90bfe005dc0afb3b.zip gcc-fd9e021c70edf459e5d700af90bfe005dc0afb3b.tar.gz gcc-fd9e021c70edf459e5d700af90bfe005dc0afb3b.tar.bz2 |
Build coroutine expression with unknown_type in processing_template_decl phase.
gcc/cp
* coroutines.cc (finish_co_await_expr): Build co_await_expr
with unknown_type_node.
(finish_co_yield_expr): Ditto.
*pt.c (type_dependent_expression_p): Set co_await/yield_expr
with unknown type as dependent.
gcc/testsuite
* g++.dg/coroutines/torture/co-await-14-template-traits.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/coroutines.cc | 6 | ||||
-rw-r--r-- | gcc/cp/pt.c | 5 |
3 files changed, 16 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bfe8d79..edc088e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2020-03-03 Jun Ma <JunMa@linux.alibaba.com> + + * coroutines.cc (finish_co_await_expr): Build co_await_expr + with unknown_type_node. + (finish_co_yield_expr): Ditto. + *pt.c (type_dependent_expression_p): Set co_await/yield_expr + with unknown type as dependent. + 2020-03-02 Iain Sandoe <iain@sandoe.co.uk> * coroutines.cc (struct local_var_info): Adjust to remove the diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 303e6e8..966ec05 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -847,8 +847,8 @@ finish_co_await_expr (location_t kw, tree expr) /* If we don't know the promise type, we can't proceed. */ tree functype = TREE_TYPE (current_function_decl); if (dependent_type_p (functype) || type_dependent_expression_p (expr)) - return build5_loc (kw, CO_AWAIT_EXPR, TREE_TYPE (expr), expr, NULL_TREE, - NULL_TREE, NULL_TREE, integer_zero_node); + return build5_loc (kw, CO_AWAIT_EXPR, unknown_type_node, expr, + NULL_TREE, NULL_TREE, NULL_TREE, integer_zero_node); } /* We must be able to look up the "await_transform" method in the scope of @@ -925,7 +925,7 @@ finish_co_yield_expr (location_t kw, tree expr) tree functype = TREE_TYPE (current_function_decl); /* If we don't know the promise type, we can't proceed. */ if (dependent_type_p (functype) || type_dependent_expression_p (expr)) - return build2_loc (kw, CO_YIELD_EXPR, TREE_TYPE (expr), expr, + return build2_loc (kw, CO_YIELD_EXPR, unknown_type_node, expr, NULL_TREE); } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 622c70b..230331f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -26701,6 +26701,11 @@ type_dependent_expression_p (tree expression) if (TREE_CODE (expression) == SCOPE_REF) return false; + /* CO_AWAIT/YIELD_EXPR with unknown type is always dependent. */ + if (TREE_CODE (expression) == CO_AWAIT_EXPR + || TREE_CODE (expression) == CO_YIELD_EXPR) + return true; + if (BASELINK_P (expression)) { if (BASELINK_OPTYPE (expression) |