From: Jakub Jelinek Date: Tue, 14 Feb 2012 23:35:15 +0000 (+0100) Subject: backport: re PR debug/51950 (fdebug-types-section regression for member pointers) X-Git-Tag: releases/gcc-4.6.3~82 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=304d494c6fbc4f8d03d60785141c3c3c3d207532;p=thirdparty%2Fgcc.git backport: re PR debug/51950 (fdebug-types-section regression for member pointers) Backported from mainline 2012-02-14 Jakub Jelinek PR debug/51950 * dwarf2out.c (clone_tree_hash): New function. (copy_decls_walk): Use it instead of clone_tree. From-SVN: r184243 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e458e08ac4eb..b2a34e78e242 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -3,6 +3,10 @@ Backported from mainline 2012-02-14 Jakub Jelinek + PR debug/51950 + * dwarf2out.c (clone_tree_hash): New function. + (copy_decls_walk): Use it instead of clone_tree. + PR c/52181 * c-decl.c (merge_decls): Copy DECL_USER_ALIGN bit from olddecl to newdecl. diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 1860af92f48d..1ed3d5ad5d96 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -10410,6 +10410,32 @@ copy_ancestor_tree (dw_die_ref unit, dw_die_ref die, htab_t decl_table) return copy; } +/* Like clone_tree, but additionally enter all the children into + the hash table decl_table. */ + +static dw_die_ref +clone_tree_hash (dw_die_ref die, htab_t decl_table) +{ + dw_die_ref c; + dw_die_ref clone = clone_die (die); + struct decl_table_entry *entry; + void **slot = htab_find_slot_with_hash (decl_table, die, + htab_hash_pointer (die), INSERT); + /* Assert that DIE isn't in the hash table yet. If it would be there + before, the ancestors would be necessarily there as well, therefore + clone_tree_hash wouldn't be called. */ + gcc_assert (*slot == HTAB_EMPTY_ENTRY); + entry = XCNEW (struct decl_table_entry); + entry->orig = die; + entry->copy = clone; + *slot = entry; + + FOR_EACH_CHILD (die, c, + add_child_die (clone, clone_tree_hash (c, decl_table))); + + return clone; +} + /* Walk the DIE and its children, looking for references to incomplete or trivial types that are unmarked (i.e., that are not in the current type_unit). */ @@ -10446,7 +10472,11 @@ copy_decls_walk (dw_die_ref unit, dw_die_ref die, htab_t decl_table) else { dw_die_ref parent = unit; - dw_die_ref copy = clone_tree (targ); + dw_die_ref copy = clone_die (targ); + + FOR_EACH_CHILD (targ, c, + add_child_die (copy, + clone_tree_hash (c, decl_table))); /* Make sure the cloned tree is marked as part of the type unit. */