From 8ced31fe6da7fbdc1ec732d7ccbf8f3f401cee0d Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 9 Jun 2011 09:46:28 +0200 Subject: [PATCH] re PR middle-end/49308 (segfault in rest_of_handle_ud_dce () at gcc/gcc/dce.c:518) 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 | 7 +++++++ gcc/dce.c | 7 ++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr49308.f90 | 28 +++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/pr49308.f90 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4f12db9e3e5..81aaf76d43d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-06-09 Jakub Jelinek + + 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 * configure.ac (gcc_cv_as_hidden): Enable on *-*-darwin*. diff --git a/gcc/dce.c b/gcc/dce.c index 93464fedeed..997432501d3 100644 --- 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; } } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 465d22a3d59..d2ebaf6ca6d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-06-09 Jakub Jelinek + + PR middle-end/49308 + * gfortran.dg/pr49308.f90: New test. + 2011-06-08 Jason Merrill * 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 index 00000000000..728a5e21051 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr49308.f90 @@ -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 -- 2.30.2