re PR middle-end/49308 (segfault in rest_of_handle_ud_dce () at gcc/gcc/dce.c:518)
authorJakub Jelinek <jakub@redhat.com>
Thu, 9 Jun 2011 07:46:28 +0000 (09:46 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 9 Jun 2011 07:46:28 +0000 (09:46 +0200)
PR middle-end/49308
* dce.c (reset_unmarked_insns_debug_uses): Avoid shadowing insn
variable.  After resetting and rescanning insn continue with previous
statement.

* gfortran.dg/pr49308.f90: New test.

From-SVN: r174839

gcc/ChangeLog
gcc/dce.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr49308.f90 [new file with mode: 0644]

index 4f12db9e3e5c7db95e609bf5ca4352d24cc52807..81aaf76d43d6bf2fa5cafac2a55a3c44d2380e41 100644 (file)
@@ -1,3 +1,10 @@
+2011-06-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/49308
+       * dce.c (reset_unmarked_insns_debug_uses): Avoid shadowing insn
+       variable.  After resetting and rescanning insn continue with previous
+       statement.
+
 2011-06-09  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * configure.ac (gcc_cv_as_hidden): Enable on *-*-darwin*.
index 93464fedeede53e1e786db510bc1494415b5f16a..997432501d30ce73f25681d8b61c03d9f180532e 100644 (file)
--- a/gcc/dce.c
+++ b/gcc/dce.c
@@ -514,11 +514,11 @@ reset_unmarked_insns_debug_uses (void)
              struct df_link *defs;
              for (defs = DF_REF_CHAIN (use); defs; defs = defs->next)
                {
-                 rtx insn;
+                 rtx ref_insn;
                  if (DF_REF_IS_ARTIFICIAL (defs->ref))
                    continue;
-                 insn = DF_REF_INSN (defs->ref);
-                 if (!marked_insn_p (insn))
+                 ref_insn = DF_REF_INSN (defs->ref);
+                 if (!marked_insn_p (ref_insn))
                    break;
                }
              if (!defs)
@@ -527,6 +527,7 @@ reset_unmarked_insns_debug_uses (void)
                 each of the DEFs?  */
              INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC ();
              df_insn_rescan_debug_internal (insn);
+             break;
            }
        }
 }
index 465d22a3d596f6ca2537911efca1b8d6d7edd54a..d2ebaf6ca6dfa8b79ecc46b3eb5d19b50e4c0c8d 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/49308
+       * gfortran.dg/pr49308.f90: New test.
+
 2011-06-08  Jason Merrill  <jason@redhat.com>
 
        * g++.dg/cpp0x/noexcept11.C: New.
diff --git a/gcc/testsuite/gfortran.dg/pr49308.f90 b/gcc/testsuite/gfortran.dg/pr49308.f90
new file mode 100644 (file)
index 0000000..728a5e2
--- /dev/null
@@ -0,0 +1,28 @@
+! PR middle-end/49308
+! { dg-do compile }
+! { dg-options "-O2 -funroll-loops -g" }
+
+subroutine foo(n, b, d, e)
+  type t
+    integer :: f
+  end type t
+  type s
+    type(t), pointer :: g
+  end type s
+  type u
+    type(s), dimension(:), pointer :: h
+  end type
+  integer :: i, k, n
+  type(u), pointer :: a, e
+  character(len=250) :: b, c, d
+  logical :: l
+  do i = 1, n
+    j = i - 1
+    if (j/=0) c = trim(b) // adjustl(d(j))
+  end do
+  a => e
+  do k = 1, size(a%h)
+     l = (a%h(k)%g%f == a%h(1)%g%f)
+     if (.not.(l)) call bar()
+  enddo
+end subroutine foo