OSDN Git Service

PR debug/39524
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Mar 2009 23:21:38 +0000 (23:21 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 23 Mar 2009 23:21:38 +0000 (23:21 +0000)
* dwarf2out.c (gen_variable_die): Avoid adding duplicate declaration
nodes.

* g++.dg/debug/dwarf2/imported-decl-1.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145018 138bc75d-0d04-0410-961f-82ee72b054a4

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

index c1f7e6f..a75ca23 100644 (file)
@@ -1,3 +1,10 @@
+2009-03-24  Dodji Seketeli  <dodji@redhat.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/39524
+       * dwarf2out.c (gen_variable_die): Avoid adding duplicate declaration
+       nodes.
+
 2009-03-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/39495
index af5c994..9bf0803 100644 (file)
@@ -13978,6 +13978,14 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
       return;
     }
 
+  /* If the compiler emitted a definition for the DECL declaration
+     and if we already emitted a DIE for it, don't emit a second
+     DIE for it again.  */
+  if (old_die
+      && declaration
+      && old_die->die_parent == context_die)
+    return;
+
   var_die = new_die (DW_TAG_variable, context_die, decl);
 
   origin_die = NULL;
index cced718..4f869a0 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-24  Dodji Seketeli  <dodji@redhat.com>
+           Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/39524
+       * g++.dg/debug/dwarf2/imported-decl-1.C: New test.
+
 2009-03-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR c/39495
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/imported-decl-1.C b/gcc/testsuite/g++.dg/debug/dwarf2/imported-decl-1.C
new file mode 100644 (file)
index 0000000..bfdb4f8
--- /dev/null
@@ -0,0 +1,17 @@
+// PR debug/39524
+// { dg-do compile }
+// { dg-options "-gdwarf-2 -dA -O0 -fno-merge-debug-strings" }
+
+namespace A
+{
+  static int var2 = 2;
+}
+
+int
+func ()
+{
+  using A::var2;
+  return var2;
+}
+
+// { dg-final { scan-assembler-times "var2\[^\n\r\]*DW_AT_name" 1 } }