diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2022-11-30 17:05:56 +0000 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2022-12-04 10:39:36 +0000 |
commit | 58a7b1e354530d8dfe7d8fb859c8b8b5a9140f1f (patch) | |
tree | 1d5aa2a02785dc85b25480d17af01e2af6a0055b /gcc/cp | |
parent | 8c45e67ac673bbddaaf9770a1a6944b382174938 (diff) | |
download | gcc-58a7b1e354530d8dfe7d8fb859c8b8b5a9140f1f.zip gcc-58a7b1e354530d8dfe7d8fb859c8b8b5a9140f1f.tar.gz gcc-58a7b1e354530d8dfe7d8fb859c8b8b5a9140f1f.tar.bz2 |
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.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/coroutines.cc | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 01a3e83..3f23317 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -2685,6 +2685,7 @@ find_interesting_subtree (tree *expr_p, int *dosub, void *d) } } else if (tmp_target_expr_p (expr) + && !TARGET_EXPR_ELIDING_P (expr) && !p->temps_used->contains (expr)) { p->entry = expr_p; |