On 3/20/20 10:54 AM, Iain Sandoe wrote:

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index a943ba01de6..bcf3514bbcf 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -1348,6 +1348,7 @@ struct coro_aw_data
    tree actor_fn;   /* Decl for context.  */
    tree coro_fp;    /* Frame pointer var.  */
    tree resume_idx; /* This is the index var in the frame.  */
+  tree iarc_idx;   /* This is the initial await resume called index.  */
 comment misleading it's a flag, not an index, see below.

    tree self_h;     /* This is a handle to the current coro (frame var).  */
    tree cleanup;    /* This is where to go once we complete local destroy.  */
    tree cororet;    /* This is where to go if we suspend.  */
@@ -1445,6 +1446,8 @@ co_await_expander (tree *stmt, int * /*do_subtree*/, void 
*d)
    tree awaiter_calls = TREE_OPERAND (saved_co_await, 3);
tree source = TREE_OPERAND (saved_co_await, 4);
+  bool is_initial =
+    (source && TREE_INT_CST_LOW (source) == (int) INITIAL_SUSPEND_POINT);
    bool is_final = (source
                   && TREE_INT_CST_LOW (source) == (int) FINAL_SUSPEND_POINT);
    bool needs_dtor = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TREE_TYPE (var));
@@ -1586,6 +1589,16 @@ co_await_expander (tree *stmt, int * /*do_subtree*/, 
void *d)
    resume_label = build_stmt (loc, LABEL_EXPR, resume_label);
    append_to_statement_list (resume_label, &stmt_list);
+ if (is_initial)
+    {
+      /* Note that we are about to execute the await_resume() for the initial
+        await expression.  */
+      r = build2_loc (loc, MODIFY_EXPR, boolean_type_node, data->iarc_idx,
+                     boolean_true_node);

It is confusing you're assigning a boolean to a variable refered to as 'idx'. Also, why is it a runtime variable? you're setting it from a compile time constant -- just propagate the constant?

I'm finding this name too confusing to review properly.


nathan

--
Nathan Sidwell

Reply via email to