This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, fortran] Fix another dependency check for reallocation on assignment
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 23 Jul 2017 13:27:20 +0200
- Subject: [patch, fortran] Fix another dependency check for reallocation on assignment
- Authentication-results: sourceware.org; auth=none
Hello world,
in PR 66102, I found a patch by Mikael which has never been applied.
After dusting it off, finding that it looks reasonable and fixes
the test case in question I'd like to apply this.
Regression-tested. OK for trunk?
Regards
Thomas
2017-07-23 Thomas Koenig <tkoenig@gcc.gnu.org>
Mikael Morin <mikael@gcc.gnu.org>
PR fortran/66102
* fortran/trans-array.c (gfc_conv_resolve_dependencies):
Break if dependency has been found.
2017-07-23 Thomas Koenig <tkoenig@gcc.gnu.org>
Mikael Morin <mikael@gcc.gnu.org>
PR fortran/66102
* gfortran.dg/realloc_on_assign_28.f90: New test.
Index: fortran/trans-array.c
===================================================================
--- fortran/trans-array.c (Revision 249936)
+++ fortran/trans-array.c (Arbeitskopie)
@@ -4576,8 +4576,11 @@ gfc_conv_resolve_dependencies (gfc_loopinfo * loop
if (ss_info->type == GFC_SS_REFERENCE
&& 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)
! { dg-do run }
!
! PR fortran/66102
!
! Contributed by Vladimir Fuka <vladimir.fuka@gmail.com>
!
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