re PR debug/45088 (pointer type information lost in debuginfo)
authorDodji Seketeli <dodji@redhat.com>
Fri, 17 Dec 2010 10:39:21 +0000 (10:39 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Fri, 17 Dec 2010 10:39:21 +0000 (11:39 +0100)
Fix for PR debug/45088

gcc/

* dwarf2out.c (gen_type_die_with_usage): Do not try to emit debug
info for a redundant typedef that has DECL_ORIGINAL_TYPE set. Use
that underlying type instead.

gcc/testsuite/

* g++.dg/debug/dwarf2/self-ref-1.C: New test.
* g++.dg/debug/dwarf2/self-ref-2.C: Likewise.

From-SVN: r167976

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C [new file with mode: 0644]

index 0e3794355dd198498186dd159ad38c5453ef2b2f..571760f8f814440124061087d50fb292a9559191 100644 (file)
@@ -1,3 +1,9 @@
+2010-12-17  Dodji Seketeli  <dodji@redhat.com>
+
+       * dwarf2out.c (gen_type_die_with_usage): Do not try to emit debug
+       info for a redundant typedef that has DECL_ORIGINAL_TYPE set. Use
+       that underlying type instead.
+
 2010-12-16  Jan Hubicka  <jh@suse.cz>
 
        PR middle-end/44563 
index c9855270d3891ce1f73347c4b5b50896b13211fc..1fa33001a77b21aabda065a1f489a53efcf47150 100644 (file)
@@ -20251,13 +20251,23 @@ gen_tagged_type_die (tree type,
 
 static void
 gen_type_die_with_usage (tree type, dw_die_ref context_die,
-                               enum debug_info_usage usage)
+                        enum debug_info_usage usage)
 {
   struct array_descr_info info;
 
   if (type == NULL_TREE || type == error_mark_node)
     return;
 
+  if (TYPE_NAME (type) != NULL_TREE
+      && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
+      && is_redundant_typedef (TYPE_NAME (type))
+      && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
+    /* The DECL of this type is a typedef we don't want to emit debug
+       info for but we want debug info for its underlying typedef.
+       This can happen for e.g, the injected-class-name of a C++
+       type.  */
+    type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
+
   /* If TYPE is a typedef type variant, let's generate debug info
      for the parent typedef which TYPE is a type of.  */
   if (typedef_variant_p (type))
index df91d0995ad76bf1cdddfa615075b8938a5eb157..8cfa5c0ebfb0b6d0070bb8eec1342e80681e7805 100644 (file)
@@ -1,3 +1,8 @@
+2010-12-17  Dodji Seketeli  <dodji@redhat.com>
+
+       * g++.dg/debug/dwarf2/self-ref-1.C: New test.
+       * g++.dg/debug/dwarf2/self-ref-2.C: Likewise.
+
 2010-12-16  Sebastian Pop  <sebastian.pop@amd.com>
 
        PR tree-optimization/46924
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-1.C
new file mode 100644 (file)
index 0000000..81bcb27
--- /dev/null
@@ -0,0 +1,28 @@
+// Origin: PR debug/45088
+// { dg-do compile }
+// { dg-options "-g -dA" }
+// { dg-final { scan-assembler-times "\[^\n\r\]*\\(DIE\[^\n\r\]*DW_TAG_pointer_type\\)\[\n\r\]{1,2}\[^\n\r\]*DW_AT_byte_size\[\n\r\]{1,2}\[^\n\r\]*DW_AT_type" 4 } }
+
+struct A
+{
+    virtual ~A();
+};
+
+struct B : public A
+{
+    virtual ~B(){}
+};
+
+struct C : public B
+{
+    A* a1;
+};
+
+int
+main()
+{
+    C c;
+    c.a1 = 0;
+    return 0;
+}
+
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C b/gcc/testsuite/g++.dg/debug/dwarf2/self-ref-2.C
new file mode 100644 (file)
index 0000000..b1c5401
--- /dev/null
@@ -0,0 +1,29 @@
+// Origin: PR debug/45088
+// { dg-do compile }
+// { dg-options "-g -dA" }
+// { dg-final { scan-assembler-times "\[^\n\r\]*\\(DIE\[^\n\r\]*DW_TAG_pointer_type\\)\[\n\r\]{1,2}\[^\n\r\]*DW_AT_byte_size\[\n\r\]{1,2}\[^\n\r\]*DW_AT_type" 4 } }
+
+template<class T>
+struct A
+{
+    virtual ~A();
+};
+
+struct B : public A<int>
+{
+    virtual ~B(){}
+};
+
+struct C : public B
+{
+    A<int>* a1;
+};
+
+int
+main()
+{
+    C c;
+    c.a1 = 0;
+    return 0;
+}
+