Debian Codegraph @

gcc/testsuite/gfortran.dg/intent_out_20.f90

raw
1 ! { dg-do run }
2 !
3 ! PR fortran/92178
4 ! Check that if a data reference passed is as actual argument whose dummy
5 ! has INTENT(OUT) attribute, any other argument depending on the
6 ! same data reference is evaluated before the data reference deallocation.
7
8 program p
9 implicit none
10 type t
11 integer :: i
12 end type t
13 type u
14 class(t), allocatable :: ta
15 end type u
16 type(u), allocatable :: c(:)
17 allocate(c, source = [u(t(1)), u(t(4))])
18 call bar ( &
19 allocated (c(c(1)%ta%i)%ta), &
20 c(c(1)%ta%i)%ta, &
21 allocated (c(c(1)%ta%i)%ta) &
22 )
23 if (allocated (c(1)%ta)) stop 11
24 if (.not. allocated (c(2)%ta)) stop 12
25 contains
26 subroutine bar (alloc, x, alloc2)
27 logical :: alloc, alloc2
28 class(t), allocatable, intent(out) :: x(..)
29 if (allocated (x)) stop 1
30 if (.not. alloc) stop 2
31 if (.not. alloc2) stop 3
32 end subroutine bar
33 end