aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2012-07-19 16:01:56 -0400
committerJason Merrill <jason@gcc.gnu.org>2012-07-19 16:01:56 -0400
commite1310984b5ea59b3478b7a37d008d1f16c1effde (patch)
treefb904da8c31d229932491fddd79d8a08930b1eed
parent1312c276d64f91c4b44072d37bbef0b817ae2ee2 (diff)
downloadgcc-e1310984b5ea59b3478b7a37d008d1f16c1effde.zip
gcc-e1310984b5ea59b3478b7a37d008d1f16c1effde.tar.gz
gcc-e1310984b5ea59b3478b7a37d008d1f16c1effde.tar.bz2
re PR debug/53235 (20120504 broke -fdebug-types-section)
PR debug/53235 * dwarf2out.c (generate_type_signature): Handle the case of DIE being nested, rather than its declaration.. From-SVN: r189676
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/dwarf2out.c27
-rw-r--r--gcc/testsuite/g++.dg/debug/dwarf2/nested-4.C14
3 files changed, 43 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 817a222..c87c3cc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2012-07-19 Jason Merrill <jason@redhat.com>
+
+ PR debug/53235
+ * dwarf2out.c (get_die_parent): New.
+ (generate_type_signature): Use it.
+
2012-07-19 Richard Henderson <rth@redhat.com>
* config/ia64/vect.md (smulv4hi3_highpart): New.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index dd48d1d..e36a15d 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -4011,6 +4011,23 @@ get_AT (dw_die_ref die, enum dwarf_attribute attr_kind)
return NULL;
}
+/* Returns the parent of the declaration of DIE. */
+
+static dw_die_ref
+get_die_parent (dw_die_ref die)
+{
+ dw_die_ref t;
+
+ if (!die)
+ return NULL;
+
+ if ((t = get_AT_ref (die, DW_AT_abstract_origin))
+ || (t = get_AT_ref (die, DW_AT_specification)))
+ die = t;
+
+ return die->die_parent;
+}
+
/* Return the "low pc" attribute value, typically associated with a subprogram
DIE. Return null if the "low pc" attribute is either not present, or if it
cannot be represented as an assembler label identifier. */
@@ -5630,9 +5647,11 @@ generate_type_signature (dw_die_ref die, comdat_type_node *type_node)
unsigned char checksum[16];
struct md5_ctx ctx;
dw_die_ref decl;
+ dw_die_ref parent;
name = get_AT_string (die, DW_AT_name);
decl = get_AT_ref (die, DW_AT_specification);
+ parent = get_die_parent (die);
/* First, compute a signature for just the type name (and its surrounding
context, if any. This is stored in the type unit DIE for link-time
@@ -5643,8 +5662,8 @@ generate_type_signature (dw_die_ref die, comdat_type_node *type_node)
md5_init_ctx (&ctx);
/* Checksum the names of surrounding namespaces and structures. */
- if (decl != NULL && decl->die_parent != NULL)
- checksum_die_context (decl->die_parent, &ctx);
+ if (parent != NULL)
+ checksum_die_context (parent, &ctx);
md5_process_bytes (&die->die_tag, sizeof (die->die_tag), &ctx);
md5_process_bytes (name, strlen (name) + 1, &ctx);
@@ -5660,8 +5679,8 @@ generate_type_signature (dw_die_ref die, comdat_type_node *type_node)
die->die_mark = mark;
/* Checksum the names of surrounding namespaces and structures. */
- if (decl != NULL && decl->die_parent != NULL)
- checksum_die_context (decl->die_parent, &ctx);
+ if (parent != NULL)
+ checksum_die_context (parent, &ctx);
/* Checksum the DIE and its children. */
die_checksum_ordered (die, &ctx, &mark);
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/nested-4.C b/gcc/testsuite/g++.dg/debug/dwarf2/nested-4.C
new file mode 100644
index 0000000..8ab75e1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/nested-4.C
@@ -0,0 +1,14 @@
+// PR debug/53235
+// { dg-options "-gdwarf-4 -fdebug-types-section" }
+// { dg-final { scan-assembler-times "debug_types" 2 } }
+
+namespace E {
+ class O {};
+ void f (O o) {}
+}
+namespace F {
+ class O {};
+ void f (O fo) {}
+}
+E::O eo;
+int main () {}