From: Thomas Koenig Date: Mon, 24 Jul 2017 09:50:28 +0000 (+0000) Subject: re PR fortran/66102 (dependency mishandling with reallocation on assignment) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=213c3b7b7cb5f58193cb4ea81cd7313427fcf431;p=gcc.git re PR fortran/66102 (dependency mishandling with reallocation on assignment) 2017-07-24 Thomas Koenig Mikael Morin PR fortran/66102 * fortran/trans-array.c (gfc_conv_resolve_dependencies): Break if dependency has been found. 2017-07-24 Thomas Koenig Mikael Morin PR fortran/66102 * gfortran.dg/realloc_on_assign_28.f90: New test. Co-Authored-By: Mikael Morin From-SVN: r250471 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 048a835d7fc..96b445afb79 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2017-07-24 Thomas Koenig + Mikael Morin + + PR fortran/66102 + * fortran/trans-array.c (gfc_conv_resolve_dependencies): + Break if dependency has been found. + 2017-07-23 Alexander Monakov * interface.c (pair_cmp): Fix gfc_symbol comparison. Adjust comment. diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 47e8c091a9b..9efb531a722 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -4577,7 +4577,10 @@ gfc_conv_resolve_dependencies (gfc_loopinfo * loop, gfc_ss * dest, && gfc_check_dependency (dest_expr, ss_expr, false)) ss_info->data.scalar.needs_temporary = 1; - continue; + if (nDepend) + break; + else + continue; } if (dest_expr->symtree->n.sym != ss_expr->symtree->n.sym) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fa5733ed23a..b1e5730db7e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-07-24 Thomas Koenig + Mikael Morin + + PR fortran/66102 + * gfortran.dg/realloc_on_assign_28.f90: New test. + 2017-07-23 David Edelsohn * gcc.dg/pr56727-2.c: Limit to powerpc-linux. diff --git a/gcc/testsuite/gfortran.dg/realloc_on_assign_28.f90 b/gcc/testsuite/gfortran.dg/realloc_on_assign_28.f90 new file mode 100644 index 00000000000..2e338e470fd --- /dev/null +++ b/gcc/testsuite/gfortran.dg/realloc_on_assign_28.f90 @@ -0,0 +1,40 @@ +! { dg-do run } +! +! PR fortran/66102 +! +! Contributed by Vladimir Fuka +! + type t + integer,allocatable :: i + end type + + type(t) :: e + type(t), allocatable, dimension(:) :: a, b + integer :: chksum = 0 + + do i=1,3 ! Was 100 in original + e%i = i + chksum = chksum + i + if (.not.allocated(a)) then + a = [e] + b = first_arg([e], [e]) + else + call foo + end if + end do + + if (sum ([(a(i)%i, i=1,size(a))]) .ne. chksum) call abort + if (any([(a(i)%i, i=1,size(a))] /= [(i, i=1,size(a))])) call abort + if (size(a) /= size(b)) call abort + if (any([(b(i)%i, i=1,size(b))] /= [(i, i=1,size(b))])) call abort +contains + subroutine foo + b = first_arg([b, e], [a, e]) + a = [a, e] + end subroutine + elemental function first_arg(arg1, arg2) + type(t), intent(in) :: arg1, arg2 + type(t) :: first_arg + first_arg = arg1 + end function first_arg +end