coroutines: Do not promote temporaries that will be elided.
We usually need to 'promote' (i.e. save to the coroutine frame) any temporary
variable that is in a target expression that must persist across an await
expression. However, if the TE is just used as a direct initializer for
another object it will be elided - and we should not promote it since that
would lead to a DTOR call for something that is never constructed.
Since we now have a mechanism to tell if TEs will be elided, use that.
Although the PRs referenced initially appear to be different issues, they all
stem from this.
Co-Authored-By: Adrian Perl <adrian.perl@web.de>
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
PR c++/100611
PR c++/101367
PR c++/101976
PR c++/99576
gcc/cp/ChangeLog:
* coroutines.cc (find_interesting_subtree): Do not promote temporaries
that are only used as direct initializers for some other object.
gcc/testsuite/ChangeLog:
* g++.dg/coroutines/pr100611.C: New test.
* g++.dg/coroutines/pr101367.C: New test.
* g++.dg/coroutines/pr101976.C: New test.
* g++.dg/coroutines/pr99576_1.C: New test.
* g++.dg/coroutines/pr99576_2.C: New test.