OSDN Git Service

PR debug/39379
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 5 Mar 2009 12:50:36 +0000 (12:50 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 5 Mar 2009 12:50:36 +0000 (12:50 +0000)
* tree-cfg.c (remove_useless_stmts_bind): Don't remove GIMPLE_BINDs
with blocks containing IMPORTED_DECLs in BLOCK_VARS.

* g++.dg/debug/dwarf2/imported-module-3.C: New test.
* g++.dg/debug/dwarf2/imported-module-4.C: New test.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/imported-module-3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/imported-module-4.C [new file with mode: 0644]
gcc/tree-cfg.c

index d2629d6..a0ff5c8 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/39379
+       * tree-cfg.c (remove_useless_stmts_bind): Don't remove GIMPLE_BINDs
+       with blocks containing IMPORTED_DECLs in BLOCK_VARS.
+
 2009-03-05  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/i386/i386.md (R8_REG, R9_REG): New constants.
index fc15129..f71de1c 100644 (file)
@@ -1,3 +1,9 @@
+2009-03-05  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/39379
+       * g++.dg/debug/dwarf2/imported-module-3.C: New test.
+       * g++.dg/debug/dwarf2/imported-module-4.C: New test.
+
 2009-03-04  Jason Merrill  <jason@redhat.com>
 
        PR c++/13549
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/imported-module-3.C b/gcc/testsuite/g++.dg/debug/dwarf2/imported-module-3.C
new file mode 100644 (file)
index 0000000..d62a506
--- /dev/null
@@ -0,0 +1,17 @@
+// PR debug/39379
+// { dg-do compile }
+// { dg-options "-g -dA" }
+// { dg-final { scan-assembler "DW_TAG_imported" }  }
+
+namespace A
+{
+  int v;
+}
+
+int
+main ()
+{
+  using namespace A;
+  v++;
+  return v - 1;
+}
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/imported-module-4.C b/gcc/testsuite/g++.dg/debug/dwarf2/imported-module-4.C
new file mode 100644 (file)
index 0000000..6e9b52e
--- /dev/null
@@ -0,0 +1,21 @@
+// PR debug/39379
+// { dg-do compile }
+// { dg-options "-g -dA" }
+// { dg-final { scan-assembler "DW_TAG_imported" }  }
+
+namespace A
+{
+  int v;
+}
+
+int
+f ()
+{
+  int i;
+  {
+    using namespace A;
+    v++;
+    i = v - 1;
+  }
+  return i;
+}
index 5632a89..440aa93 100644 (file)
@@ -1796,9 +1796,21 @@ remove_useless_stmts_bind (gimple_stmt_iterator *gsi, struct rus_data *data ATTR
          || (TREE_CODE (BLOCK_ABSTRACT_ORIGIN (block))
              != FUNCTION_DECL)))
     {
-      gsi_insert_seq_before (gsi, body_seq, GSI_SAME_STMT);
-      gsi_remove (gsi, false);
-      data->repeat = true;
+      tree var = NULL_TREE;
+      /* Even if there are no gimple_bind_vars, there might be other
+        decls in BLOCK_VARS rendering the GIMPLE_BIND not useless.  */
+      if (block)
+       for (var = BLOCK_VARS (block); var; var = TREE_CHAIN (var))
+         if (TREE_CODE (var) == IMPORTED_DECL)
+           break;
+      if (var)
+       gsi_next (gsi);
+      else
+       {
+         gsi_insert_seq_before (gsi, body_seq, GSI_SAME_STMT);
+         gsi_remove (gsi, false);
+         data->repeat = true;
+       }
     }
   else
     gsi_next (gsi);