re PR tree-optimization/46583 (-fcompare-debug failure with -O -fno-inline -fipa...
authorAlexandre Oliva <aoliva@redhat.com>
Thu, 20 Jan 2011 16:56:25 +0000 (16:56 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Thu, 20 Jan 2011 16:56:25 +0000 (16:56 +0000)
gcc/ChangeLog:
PR debug/46583
* tree-ssa-live.c (remove_unused_scope_block_p): Keep type decls.
gcc/testsuite/ChangeLog:
PR debug/46583
* g++.dg/debug/pr46583.C: New.

From-SVN: r169058

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/pr46583.C [new file with mode: 0644]
gcc/tree-ssa-live.c

index af3cd28f8377d2f17f3cd984b802dbe849080157..dcc3530650123a8104c945486080c740ccd55764 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-20  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR debug/46583
+       * tree-ssa-live.c (remove_unused_scope_block_p): Keep type decls.
+
 2011-01-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/47283
index cba5291348b68fbf5f877b6b802f7521988c531d..baf5732df073d493716eaba4409655bf22de4166 100644 (file)
@@ -1,3 +1,8 @@
+2011-01-20  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR debug/46583
+       * g++.dg/debug/pr46583.C: New.
+
 2011-01-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/47283
diff --git a/gcc/testsuite/g++.dg/debug/pr46583.C b/gcc/testsuite/g++.dg/debug/pr46583.C
new file mode 100644 (file)
index 0000000..a4e9423
--- /dev/null
@@ -0,0 +1,40 @@
+// PR debug/46583
+// { dg-do compile }
+// { dg-options "-O -fno-inline -fipa-cp -fipa-cp-clone -fcompare-debug" }
+
+template < typename = unsigned long >struct A
+{
+  unsigned long elems[3];
+  unsigned long *begin ()
+  {
+    return 0;
+  }
+};
+
+void
+bar (unsigned long *a1, unsigned long, unsigned long *a3, unsigned const &)
+{
+  *a3 = *a1;
+}
+
+A < >operatorM (A < >a1, unsigned long a2)
+{
+  typedef A < >G;
+  G a3;
+  bar (a1.begin (), a2, a3.begin (), 0);
+  return a3;
+}
+
+struct B
+{
+  B (A < >m):n (operatorM (m, 1))
+  {
+  }
+  A < >n;
+};
+
+void
+foo ()
+{
+  B (A < >());
+}
index 7a6cafa0d28d8e1905732b8a183d559c1e2ba5e8..0fa906b79c7d70bb19d6ec3824c4b94ed1a8e010 100644 (file)
@@ -490,11 +490,16 @@ remove_unused_scope_block_p (tree scope)
         can be considered dead.  We only want to keep around blocks user can
         breakpoint into and ask about value of optimized out variables.
 
-        Similarly we need to keep around types at least until all variables of
-        all nested blocks are gone.  We track no information on whether given
-        type is used or not.  */
-
-      else if (debug_info_level == DINFO_LEVEL_NORMAL
+        Similarly we need to keep around types at least until all
+        variables of all nested blocks are gone.  We track no
+        information on whether given type is used or not, so we have
+        to keep them even when not emitting debug information,
+        otherwise we may end up remapping variables and their (local)
+        types in different orders depending on whether debug
+        information is being generated.  */
+
+      else if (TREE_CODE (*t) == TYPE_DECL
+              || debug_info_level == DINFO_LEVEL_NORMAL
               || debug_info_level == DINFO_LEVEL_VERBOSE)
        ;
       else