diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2020-04-27 15:21:25 +0100 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2020-04-30 15:56:44 +0100 |
commit | b16fd5fd8afe6f95c8ae44e759971e605c31f97b (patch) | |
tree | 8abba6dba3e6e635536ea971ca7cb13a06f93a67 /gcc/cp | |
parent | 04e88369a7d95492efccf8f527d27cca74664ea7 (diff) | |
download | gcc-b16fd5fd8afe6f95c8ae44e759971e605c31f97b.zip gcc-b16fd5fd8afe6f95c8ae44e759971e605c31f97b.tar.gz gcc-b16fd5fd8afe6f95c8ae44e759971e605c31f97b.tar.bz2 |
coroutines: Fix cases where proxy variables are used [PR94879]
There are several places where the handling of a variable
declaration depends on whether it corresponds to a compiler
temporary, or to some other entity. We were testing that var
decls were artificial in determining this. However, proxy vars
are also artificial so that this is not sufficient. The solution
is to exclude variables with a DECL_VALUE_EXPR as well, since
the value variable will not be a temporary.
gcc/cp/ChangeLog:
2020-04-30 Iain Sandoe <iain@sandoe.co.uk>
PR c++/94879
* coroutines.cc (build_co_await): Account for variables
with DECL_VALUE_EXPRs.
(captures_temporary): Likewise.
(register_awaits): Likewise.
gcc/testsuite/ChangeLog:
2020-04-30 Iain Sandoe <iain@sandoe.co.uk>
PR c++/94879
* g++.dg/coroutines/pr94879-folly-1.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/cp/coroutines.cc | 9 |
2 files changed, 14 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cbedbab..3172f94 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,11 @@ +2020-04-30 Iain Sandoe <iain@sandoe.co.uk> + + PR c++/94879 + * coroutines.cc (build_co_await): Account for variables + with DECL_VALUE_EXPRs. + (captures_temporary): Likewise. + (register_awaits): Likewise. + 2020-04-29 Patrick Palka <ppalka@redhat.com> PR c++/94830 diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc index 7bb3e98..e2dbeab 100644 --- a/gcc/cp/coroutines.cc +++ b/gcc/cp/coroutines.cc @@ -748,7 +748,8 @@ build_co_await (location_t loc, tree a, suspend_point_kind suspend_kind) if (INDIRECT_REF_P (e_proxy)) e_proxy = TREE_OPERAND (e_proxy, 0); if (TREE_CODE (e_proxy) == PARM_DECL - || (TREE_CODE (e_proxy) == VAR_DECL && !DECL_ARTIFICIAL (e_proxy))) + || (VAR_P (e_proxy) && (!DECL_ARTIFICIAL (e_proxy) + || DECL_HAS_VALUE_EXPR_P (e_proxy)))) e_proxy = o; else { @@ -2659,7 +2660,8 @@ captures_temporary (tree *stmt, int *do_subtree, void *d) } /* This isn't a temporary. */ - if ((TREE_CODE (parm) == VAR_DECL && !DECL_ARTIFICIAL (parm)) + if ((VAR_P (parm) + && (!DECL_ARTIFICIAL (parm) || DECL_HAS_VALUE_EXPR_P (parm))) || TREE_CODE (parm) == PARM_DECL || TREE_CODE (parm) == NON_LVALUE_EXPR) continue; @@ -2742,7 +2744,8 @@ register_awaits (tree *stmt, int *do_subtree ATTRIBUTE_UNUSED, void *d) if (INDIRECT_REF_P (aw)) aw = TREE_OPERAND (aw, 0); if (TREE_CODE (aw) == PARM_DECL - || (TREE_CODE (aw) == VAR_DECL && !DECL_ARTIFICIAL (aw))) + || (VAR_P (aw) && (!DECL_ARTIFICIAL (aw) + || DECL_HAS_VALUE_EXPR_P (aw)))) ; /* Don't make an additional copy. */ else { |