diff options
author | Jakub Jelinek <jakub@redhat.com> | 2023-01-24 11:28:00 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2023-01-24 11:28:00 +0100 |
commit | b84e21115700523b4d0ac44275443f7b9c670344 (patch) | |
tree | 224f885eeb0fe0f2a328cf7c77ba8c76d1b0c5bb /gcc/cp | |
parent | 275820c09e5f397040cbff69c90012dc1e220faf (diff) | |
download | gcc-b84e21115700523b4d0ac44275443f7b9c670344.zip gcc-b84e21115700523b4d0ac44275443f7b9c670344.tar.gz gcc-b84e21115700523b4d0ac44275443f7b9c670344.tar.bz2 |
c++: Handle structured bindings like anon unions in initializers [PR108474]
As reported by Andrew Pinski, structured bindings (with the exception
of the ones using std::tuple_{size,element} and get which are really
standalone variables in addition to the binding one) also use
DECL_VALUE_EXPR and needs the same treatment in static initializers.
On Sun, Jan 22, 2023 at 07:19:07PM -0500, Jason Merrill wrote:
> Though, actually, why not instead fix expand_expr_real_1 (and staticp) to
> look through DECL_VALUE_EXPR?
Doing it when emitting the initializers seems to be too late to me,
we in various spots try to put parts of the static var DECL_INITIAL expressions
into the IL, or e.g. for varpool purposes remember which vars are referenced
there.
This patch moves it to record_reference, which is called from varpool_node::analyze
and so about the same time as gimplification of the bodies which also
replaces DECL_VALUE_EXPRs.
2023-01-24 Jakub Jelinek <jakub@redhat.com>
PR c++/108474
* cgraphbuild.cc: Include gimplify.h.
(record_reference): Replace VAR_DECLs with DECL_HAS_VALUE_EXPR_P with
their corresponding DECL_VALUE_EXPR expressions after unsharing.
* cp-gimplify.cc (cp_fold_r): Revert 2023-01-19 changes.
* g++.dg/cpp1z/decomp57.C: New test.
* g++.dg/cpp1z/decomp58.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/cp-gimplify.cc | 10 |
1 files changed, 0 insertions, 10 deletions
diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc index 92cd309..a35cedd 100644 --- a/gcc/cp/cp-gimplify.cc +++ b/gcc/cp/cp-gimplify.cc @@ -1035,16 +1035,6 @@ cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data_) } break; - case VAR_DECL: - /* In initializers replace anon union artificial VAR_DECLs - with their DECL_VALUE_EXPRs, as nothing will do it later. */ - if (DECL_ANON_UNION_VAR_P (stmt) && !data->genericize) - { - *stmt_p = stmt = unshare_expr (DECL_VALUE_EXPR (stmt)); - break; - } - break; - default: break; } |