summaryrefslogtreecommitdiff
path: root/gcc/cp/optimize.c
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2001-05-30 08:44:56 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2001-05-30 08:44:56 +0000
commite352e0a873993daf28c9aee7e55413613510ec5e (patch)
tree8ba2f374e395671acbd26e6ad707d17c8c1f9df2 /gcc/cp/optimize.c
parent1a7076ad6873bb6be99c60cb2f76d157a22ba5ea (diff)
downloadgcc-e352e0a873993daf28c9aee7e55413613510ec5e.tar.gz
cp:
PR g++/2936 * decl.c (finish_anon_union): Copy context. * optimize.c (remap_decl): Remap anonymous aggregate members too. testsuite: * g++.old-deja/g++.other/optimize3.C: New file. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42705 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/optimize.c')
-rw-r--r--gcc/cp/optimize.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index f81d7e38ae3..8676dd80bcc 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -106,8 +106,7 @@ static void update_cloned_parm PARAMS ((tree, tree));
decisions about when a function is too big to inline. */
#define INSNS_PER_STMT (10)
-/* Remap DECL during the copying of the BLOCK tree for the function.
- DATA is really an `inline_data *'. */
+/* Remap DECL during the copying of the BLOCK tree for the function. */
static tree
remap_decl (decl, id)
@@ -149,6 +148,26 @@ remap_decl (decl, id)
copy_body_r, id, NULL);
}
+ if (!DECL_NAME (t) && TREE_TYPE (t)
+ && ANON_AGGR_TYPE_P (TREE_TYPE ((t))))
+ {
+ /* For a VAR_DECL of anonymous type, we must also copy the
+ member VAR_DECLS here and rechain the
+ DECL_ANON_UNION_ELEMS. */
+ tree members = NULL;
+ tree src;
+
+ for (src = DECL_ANON_UNION_ELEMS (t); src;
+ src = TREE_CHAIN (src))
+ {
+ tree member = remap_decl (TREE_VALUE (src), id);
+
+ my_friendly_assert (!TREE_PURPOSE (src), 20010529);
+ members = tree_cons (NULL, member, members);
+ }
+ DECL_ANON_UNION_ELEMS (t) = nreverse (members);
+ }
+
/* Remember it, so that if we encounter this local entity
again we can reuse this copy. */
n = splay_tree_insert (id->decl_map,