forked from wangliu-iscas/gcc-patch
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fortran: Pass pre-calculated class container argument [pr110618]
Pass already evaluated class container argument from gfc_conv_procedure_call down to gfc_add_finalizer_call through gfc_deallocate_scalar_with_status and gfc_deallocate_with_status, to avoid repeatedly evaluating the same data reference expressions in the generated code. PR fortran/110618 gcc/fortran/ChangeLog: * trans.h (gfc_deallocate_with_status): Add class container argument. (gfc_deallocate_scalar_with_status): Ditto. * trans.cc (gfc_deallocate_with_status): Add class container argument and pass it down to gfc_add_finalize_call. (gfc_deallocate_scalar_with_status): Same. * trans-array.cc (structure_alloc_comps): Update caller. * trans-stmt.cc (gfc_trans_deallocate): Ditto. * trans-expr.cc (gfc_conv_procedure_call): Ditto. Pass pre-evaluated class container argument if it's available. gcc/testsuite/ChangeLog: * gfortran.dg/intent_out_22.f90: New test.
- Loading branch information
1 parent
ba74c51
commit e3586ae
Showing
6 changed files
with
55 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
! { dg-do run } | ||
! | ||
! PR fortran/110618 | ||
! Check that if a data reference is passed as actual argument whose dummy | ||
! has INTENT(OUT) attribute, any other argument depending on the | ||
! same data reference is evaluated before the data reference deallocation. | ||
|
||
program p | ||
implicit none | ||
type t | ||
integer :: i | ||
end type t | ||
type u | ||
class(t), allocatable :: ta(:) | ||
end type u | ||
type(u), allocatable :: c(:) | ||
class(t), allocatable :: d(:) | ||
allocate(c, source = [u([t(1), t(3)]), u([t(4), t(9)])]) | ||
allocate(d, source = [t(1), t(5)]) | ||
call bar ( & | ||
allocated(c(d(1)%i)%ta), & | ||
d, & | ||
c(d(1)%i)%ta, & | ||
allocated (c(d(1)%i)%ta) & | ||
) | ||
if (allocated (c(1)%ta)) stop 11 | ||
if (.not. allocated (c(2)%ta)) stop 11 | ||
contains | ||
subroutine bar (alloc, x, y, alloc2) | ||
logical :: alloc, alloc2 | ||
class(t), allocatable, intent(out) :: x(:) | ||
class(t), allocatable, intent(out) :: y(:) | ||
if (allocated (x)) stop 1 | ||
if (.not. alloc) stop 2 | ||
if (.not. alloc2) stop 3 | ||
end subroutine bar | ||
end |