]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
dwarf2out.c (tree_add_const_value_attribute_for_decl): Don't add DW_AT_const_value...
authorJakub Jelinek <jakub@redhat.com>
Wed, 7 Oct 2009 18:39:52 +0000 (20:39 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 7 Oct 2009 18:39:52 +0000 (20:39 +0200)
* dwarf2out.c (tree_add_const_value_attribute_for_decl): Don't add
DW_AT_const_value if VAR_DIE already has DW_AT_abstract_origin
refering to a DIE with DW_AT_const_value.

* gcc.dg/debug/dwarf2/inline3.c: New test.

From-SVN: r152535

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/debug/dwarf2/inline3.c [new file with mode: 0644]

index cf0d248f258d62e481a7fc19af7a1ebdb1758dd0..b1a88a38d71c89052b8ae304cae039bb05c45557 100644 (file)
@@ -1,3 +1,9 @@
+2009-10-07  Jakub Jelinek  <jakub@redhat.com>
+
+       * dwarf2out.c (tree_add_const_value_attribute_for_decl): Don't add
+       DW_AT_const_value if VAR_DIE already has DW_AT_abstract_origin
+       refering to a DIE with DW_AT_const_value.
+
 2009-10-07  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR middle-end/22072
index f9304e54327870ce0edb7f0b2381d36d1e485013..7e0d466331e15691c188f261cdc77c836b076ee0 100644 (file)
@@ -15701,6 +15701,10 @@ tree_add_const_value_attribute_for_decl (dw_die_ref var_die, tree decl)
     else
       return false;
 
+  /* Don't add DW_AT_const_value if abstract origin already has one.  */
+  if (get_AT (var_die, DW_AT_const_value))
+    return false;
+
   return tree_add_const_value_attribute (var_die, DECL_INITIAL (decl));
 }
 
index 41a7a5e5969febe55cf76257e41a65d0e709794f..ea24c57348fa479837b1ed135ae04323f1dbef06 100644 (file)
@@ -1,3 +1,7 @@
+2009-10-07  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/debug/dwarf2/inline3.c: New test.
+
 2009-10-07  Daniel Kraft  <d@domob.eu>
 
        PR fortran/41615
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline3.c b/gcc/testsuite/gcc.dg/debug/dwarf2/inline3.c
new file mode 100644 (file)
index 0000000..feafb33
--- /dev/null
@@ -0,0 +1,22 @@
+/* Verify that only one DW_AT_const_value is emitted for baz,
+   not for baz abstract DIE and again inside of
+   DW_TAG_inlined_subroutine.  */
+/* { dg-options "-O2 -g -dA" } */
+/* { dg-do compile } */
+/* { dg-final { scan-assembler-times " DW_AT_const_value" 1 } } */
+
+struct A { const long i; const long j; };
+
+static inline long
+foo (void)
+{
+  const struct A baz = { .i = 2, .j = 21 };
+  asm volatile ("" : : : "memory");
+  return baz.i * baz.j;
+}
+
+int
+main ()
+{
+  return foo () - 42;
+}