coroutines: Fix handling of artificial vars [PR94886]
authorIain Sandoe <iain@sandoe.co.uk>
Thu, 30 Apr 2020 09:42:36 +0000 (10:42 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Thu, 30 Apr 2020 15:00:39 +0000 (16:00 +0100)
commit448c89d590455ed4ab7abc40309b5cf8ec52d13d
tree61c760c016575511ea8afc83832ea9e1fd5fc36d
parentaa94a22f5cb337e173d7119ffd5a92f1e607f544
coroutines: Fix handling of artificial vars [PR94886]

The testcase ICEs because the range-based for generates three
artificial variables that need to be allocated to the coroutine
frame but, when walking the BIND_EXR that contains these, the
DECL_INITIAL for one of them refers to an entry appearing later,
which means that the frame entry hasn't been allocated when that
INITIAL is walked.

The solution is to defer walking the DECL_INITIAL/SIZE etc. until
all the BIND_EXPR vars have been processed.

gcc/cp/ChangeLog:

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

PR c++/94886
* coroutines.cc (transform_local_var_uses): Defer walking
the DECL_INITIALs of BIND_EXPR vars until all the frame
allocations have been made.

gcc/testsuite/ChangeLog:

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

PR c++/94886
* g++.dg/coroutines/pr94886-folly-3.C: New test.
gcc/cp/ChangeLog
gcc/cp/coroutines.cc
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/coroutines/pr94886-folly-3.C [new file with mode: 0644]