aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2009-05-18 19:19:52 +0000
committerDodji Seketeli <dodji@gcc.gnu.org>2009-05-18 21:19:52 +0200
commit82725547db6fba598916a16b027e06d16c5e6a57 (patch)
tree91d9fb61dc797d4cd4f4d2aff64f4e3ab110f200
parentf6a1e4301a7a2038e52cae4a2f4d2e2b94dfa5fc (diff)
downloadgcc-82725547db6fba598916a16b027e06d16c5e6a57.zip
gcc-82725547db6fba598916a16b027e06d16c5e6a57.tar.gz
gcc-82725547db6fba598916a16b027e06d16c5e6a57.tar.bz2
re PR debug/40109 (Incorrect debug info nesting for typedef statements within namespaces)
Fix for PR debug/40109 gcc/ChangeLog: PR debug/40109 * dwarf2out.c (gen_type_die_with_usage): Generate the DIE as a child of the containing namespace's DIE. gcc/testsuite/ChangeLog: PR debug/40109 * g++.dg/debug/dwarf2/nested-1.C: New test. From-SVN: r147674
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/dwarf2out.c6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/debug/dwarf2/nested-1.C29
4 files changed, 46 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9735882..6b82ac7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2009-05-18 Dodji Seketeli <dodji@redhat.com>
+
+ PR debug/40109
+ * dwarf2out.c (gen_type_die_with_usage): Generate the DIE as a
+ child of the containing namespace's DIE.
+
2009-05-18 Adam Nemet <anemet@caviumnetworks.com>
* config/mips/mips.md (*zero_extend<GPR:mode>_trunc<SHORT:mode>,
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 157bdaf..cb1b988 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -14642,6 +14642,12 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
/* Prevent broken recursion; we can't hand off to the same type. */
gcc_assert (DECL_ORIGINAL_TYPE (TYPE_NAME (type)) != type);
+ /* Use the DIE of the containing namespace as the parent DIE of
+ the type description DIE we want to generate. */
+ if (DECL_CONTEXT (TYPE_NAME (type))
+ && TREE_CODE (DECL_CONTEXT (TYPE_NAME (type))) == NAMESPACE_DECL)
+ context_die = lookup_decl_die (DECL_CONTEXT (TYPE_NAME (type)));
+
TREE_ASM_WRITTEN (type) = 1;
gen_decl_die (TYPE_NAME (type), NULL, context_die);
return;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1645ea4..1e1c805 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-05-18 Dodji Seketeli <dodji@redhat.com>
+
+ PR debug/40109
+ * g++.dg/debug/dwarf2/nested-1.C: New test.
+
2009-05-18 H.J. Lu <hongjiu.lu@intel.com>
PR testsuite/39907
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/nested-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/nested-1.C
new file mode 100644
index 0000000..336582c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/nested-1.C
@@ -0,0 +1,29 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin PR debug/40109
+// { dg-do compile }
+// { dg-options "-g -dA -O0" }
+
+namespace A
+{
+
+ class B
+ {
+ };
+ typedef A::B AB;
+};
+
+int
+main()
+{
+ A::AB ab;
+ return 0;
+}
+
+// { dg-final { scan-assembler "DW_TAG_typedef" } }
+//
+// What we want to do here is to be sure that the DIE of A::AB is generated
+// as a child of the DIE of the namespace A declaration.
+// So this test won't catch a regression on this fix yet. To write a proper
+// test for this fix, we would need a dwarf reader written in tcl,
+// or something along those lines.
+