aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Sandoe <iain@sandoe.co.uk>2020-05-05 20:27:27 +0100
committerIain Sandoe <iain@sandoe.co.uk>2020-05-05 20:27:27 +0100
commitf1656ae9234d1a1caee79183786d1f0ac2f8dbf4 (patch)
tree9489d7cf14f0b2c8f799a1ab5a10ded768d1654c
parente5185cc6be3da99435129cdc0c769d4081e82989 (diff)
downloadgcc-f1656ae9234d1a1caee79183786d1f0ac2f8dbf4.zip
gcc-f1656ae9234d1a1caee79183786d1f0ac2f8dbf4.tar.gz
gcc-f1656ae9234d1a1caee79183786d1f0ac2f8dbf4.tar.bz2
coroutines: Replace extra checks for co_yield with asserts.
The lowering of co_yield to a promise method call and a co_await was moved to the initial analysis phase with the intention of avoiding the need to handle the two cases later. Before removing the later checks entirely, this patch replaces them with checking asserts. gcc/cp/Changelog: 2020-05-05 Iain Sandoe <iain@sandoe.co.uk> * coroutines.cc (transform_await_wrapper): Check that we have no unlowered co_yields. (captures_temporary): Likewise. (register_awaits): Likewise.
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/coroutines.cc20
2 files changed, 18 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 3dece83..17e24d2 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,10 @@
+2020-05-05 Iain Sandoe <iain@sandoe.co.uk>
+
+ * coroutines.cc (transform_await_wrapper): Check that we have
+ no unlowered co_yields.
+ (captures_temporary): Likewise.
+ (register_awaits): Likewise.
+
2020-05-05 Nathan Sidwell <nathan@acm.org>
PR c++/94807
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 0c91abc..ed871e1 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -1743,7 +1743,9 @@ transform_await_wrapper (tree *stmt, int *do_subtree, void *d)
&& DECL_CONTEXT (*stmt) != xform->actor_fn)
DECL_CONTEXT (*stmt) = xform->actor_fn;
- if (TREE_CODE (*stmt) != CO_AWAIT_EXPR && TREE_CODE (*stmt) != CO_YIELD_EXPR)
+ /* We should have already lowered co_yields to their co_await. */
+ gcc_checking_assert (TREE_CODE (*stmt) != CO_YIELD_EXPR);
+ if (TREE_CODE (*stmt) != CO_AWAIT_EXPR)
return NULL_TREE;
tree await_expr = *stmt;
@@ -2612,9 +2614,12 @@ struct susp_frame_data
static tree
captures_temporary (tree *stmt, int *do_subtree, void *d)
{
+ /* We should have already lowered co_yields to their co_await. */
+ gcc_checking_assert (TREE_CODE (*stmt) != CO_YIELD_EXPR);
+
/* Stop recursing if we see an await expression, the subtrees
of that will be handled when it is processed. */
- if (TREE_CODE (*stmt) == CO_AWAIT_EXPR || TREE_CODE (*stmt) == CO_YIELD_EXPR)
+ if (TREE_CODE (*stmt) == CO_AWAIT_EXPR)
{
*do_subtree = 0;
return NULL_TREE;
@@ -2732,17 +2737,14 @@ register_awaits (tree *stmt, int *do_subtree ATTRIBUTE_UNUSED, void *d)
{
susp_frame_data *data = (susp_frame_data *) d;
- if (TREE_CODE (*stmt) != CO_AWAIT_EXPR && TREE_CODE (*stmt) != CO_YIELD_EXPR)
+ /* We should have already lowered co_yields to their co_await. */
+ gcc_checking_assert (TREE_CODE (*stmt) != CO_YIELD_EXPR);
+
+ if (TREE_CODE (*stmt) != CO_AWAIT_EXPR)
return NULL_TREE;
tree aw_expr = *stmt;
location_t aw_loc = EXPR_LOCATION (aw_expr); /* location of the co_xxxx. */
- /* co_yield is syntactic sugar, re-write it to co_await. */
- if (TREE_CODE (aw_expr) == CO_YIELD_EXPR)
- {
- aw_expr = TREE_OPERAND (aw_expr, 1);
- *stmt = aw_expr;
- }
/* If the awaitable is a parm or a local variable, then we already have
a frame copy, so don't make a new one. */