]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR debug/27574 (MIssing debug info at -O0 for a local variable in a C++ constructor)
authorDodji Seketeli <dodji@redhat.com>
Wed, 19 Nov 2008 00:15:52 +0000 (00:15 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Wed, 19 Nov 2008 00:15:52 +0000 (01:15 +0100)
gcc/ChangeLog:
2008-11-14  Dodji Seketeli  <dodji@redhat.com>

PR c++/27574
* gcc/cgraph.c (cgraph_remove_node): Do not remove the body of
  abstract functions. It might be useful to emit debugging
  information. This is a patch from Ian Lance Taylor.
* cgraphunit.c (cgraph_optimize): Do not cry when bodies of abstract
  functions are still around. They are useful to output debug info.

gcc/testsuite/ChangeLog
2008-11-14  Dodji Seketeli  <dodji@redhat.com>

PR c++/27574
* testsuite/g++.dg/debug/dwarf2/dwarf2.exp: Backport this here from
gcc-4_3-branch.
* g++.dg/debug/dwarf2/local-var-in-contructor.C: New testcase.

From-SVN: r141984

gcc/ChangeLog
gcc/cgraph.c
gcc/cgraphunit.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/local-var-in-contructor.C [new file with mode: 0644]

index 2d2ed27337813a61bb334bd8132175e2a54d795a..a90b8f4c09a4be6e8d609742d45b10c5f7361f76 100644 (file)
@@ -1,3 +1,12 @@
+2008-11-17  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/27574
+       * gcc/cgraph.c (cgraph_remove_node): Do not remove the body of
+         abstract functions. It might be useful to emit debugging
+         information. This is a patch from Ian Lance Taylor.
+       * cgraphunit.c (cgraph_optimize): Do not cry when bodies of abstract
+         functions are still around. They are useful to output debug info.
+
 2008-11-16  Eric Botcazou  <ebotcazou@adacore.com>
 
        * config/sparc/sparc.c (function_arg_vector_value): Remove 'base_mode'
index b7029d91445b0763e22866e04c7671c408976db9..0031893cc992e86d7df752931546bfd1de2f8bca 100644 (file)
@@ -593,6 +593,14 @@ cgraph_remove_node (struct cgraph_node *node)
              && (TREE_ASM_WRITTEN (n->decl) || DECL_EXTERNAL (n->decl))))
        kill_body = true;
     }
+  /* We don't release the body of abstract functions, because they may
+     be needed when emitting debugging information.  In particular
+     this will happen for C++ constructors/destructors.  FIXME:
+     Ideally we would check to see whether there are any reachable
+     functions whose DECL_ABSTRACT_ORIGIN points to this decl.  */
+  if (DECL_ABSTRACT (node->decl))
+    kill_body = false;
 
   if (kill_body && flag_unit_at_a_time)
     {
index 5e860052630e45b0679514109293ab8bba874eb5..4d88148db8292d2a0abe05139df8b0cd1e934154 100644 (file)
@@ -1609,7 +1609,10 @@ cgraph_optimize (void)
       for (node = cgraph_nodes; node; node = node->next)
        if (node->analyzed
            && (node->global.inlined_to
-               || DECL_SAVED_TREE (node->decl)))
+               || DECL_SAVED_TREE (node->decl))
+            /* Abstract functions are needed to output debug info,
+               so don't complain about them if they are still around.  */
+            && !DECL_ABSTRACT (node->decl))
          {
            error_found = true;
            dump_cgraph_node (stderr, node);
index c849d0a1a5b22388581f0d7c5842d7f42c61a316..8c14705db7b8f9a498449e285ab2cd7b859775d5 100644 (file)
@@ -1,3 +1,10 @@
+2008-11-14  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/27574
+       * testsuite/g++.dg/debug/dwarf2/dwarf2.exp: Backport this here from
+       gcc-4_3-branch.
+       * g++.dg/debug/dwarf2/local-var-in-contructor.C: New testcase.
+
 2008-11-13  Uros Bizjak  <ubizjak@gmail.com>
 
 <<<<<<< .working
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp b/gcc/testsuite/g++.dg/debug/dwarf2/dwarf2.exp
new file mode 100644 (file)
index 0000000..1255d06
--- /dev/null
@@ -0,0 +1,43 @@
+#   Copyright (C) 2007, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# G++ testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib g++-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+    set DEFAULT_CFLAGS " -gdwarf-2"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+set comp_output [g++_target_compile \
+    "$srcdir/$subdir/../trivial.C" "trivial.S" assembly \
+    "additional_flags=-gdwarf-2"]
+if { ! [string match "*: target system does not support the * debug format*" \
+    $comp_output] } {
+    remove-build-file "trivial.S"
+    dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[C\]]] \
+           "" $DEFAULT_CFLAGS
+}
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/local-var-in-contructor.C b/gcc/testsuite/g++.dg/debug/dwarf2/local-var-in-contructor.C
new file mode 100644 (file)
index 0000000..d61d27f
--- /dev/null
@@ -0,0 +1,30 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin PR27574
+// { dg-do compile }
+// { dg-options "-O0 -g" }
+// { dg-final { scan-assembler "problem" } }
+
+void f (int *)
+{
+}
+
+class A
+{
+public:
+ A(int i);
+};
+
+A::A(int i)
+{
+ int *problem = new int(i);
+ f (problem);
+}
+
+int
+main (void)
+{
+  A a (0);
+
+  return 0;
+}
+