coroutines, ensure placeholder var is properly declared.
authorIain Sandoe <iain@sandoe.co.uk>
Tue, 7 Apr 2020 14:03:21 +0000 (15:03 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Tue, 7 Apr 2020 15:30:30 +0000 (16:30 +0100)
In cases that we need to extended the lifetime of a temporary captured
by reference, we make a replacement var for the temporary.  This will
be then used to define a coroutine frame entry (so that the var created
is elided by a later phase).  However, we should ensure that the var
is correctly declared anyway.

gcc/cp/ChangeLog:

2020-04-07  Iain Sandoe  <iain@sandoe.co.uk>

* coroutines.cc (maybe_promote_captured_temps): Ensure that
reference capture placeholder vars are properly declared.

gcc/cp/ChangeLog
gcc/cp/coroutines.cc

index 67bee23925378baafadc04d2623c11dca3ec9a97..60d92798112935b9f04a9e49193825bfc02627d8 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-07  Iain Sandoe  <iain@sandoe.co.uk>
+
+       * coroutines.cc (maybe_promote_captured_temps): Ensure that
+       reference capture placeholder vars are properly declared.
+
 2020-04-07  Patrick Palka  <ppalka@redhat.com>
 
        PR c++/90996
index 38a23a91f8bdaa58df5f171c85fac8080627fcdd..983fa650b55e85f64ed301563dcc03b19a89572c 100644 (file)
@@ -2832,7 +2832,9 @@ maybe_promote_captured_temps (tree *stmt, void *d)
            sloc = DECL_SOURCE_LOCATION (orig_temp);
          DECL_SOURCE_LOCATION (newvar) = sloc;
          DECL_CHAIN (newvar) = varlist;
-         varlist = newvar;
+         varlist = newvar; /* Chain it onto the list for the bind expr.  */
+         /* Declare and initialze it in the new bind scope.  */
+         add_decl_expr (newvar);
          tree stmt
            = build2_loc (sloc, INIT_EXPR, var_type, newvar, to_replace);
          stmt = coro_build_cvt_void_expr_stmt (stmt, sloc);