| 1 |
!{ dg-do run } |
| 2 |
|
| 3 |
! Check freeing derived typed result's allocatable components is not done twice. |
| 4 |
! Contributed by Damian Rouson <[email protected]> |
| 5 |
|
| 6 |
program pr118747 |
| 7 |
implicit none |
| 8 |
|
| 9 |
type string_t |
| 10 |
character(len=:), allocatable :: string_ |
| 11 |
end type |
| 12 |
|
| 13 |
call check_allocation([foo(), foo()]) |
| 14 |
|
| 15 |
contains |
| 16 |
|
| 17 |
type(string_t) function foo() |
| 18 |
foo%string_ = "foo" |
| 19 |
end function |
| 20 |
|
| 21 |
elemental subroutine check_allocation(string) |
| 22 |
type(string_t), intent(in) :: string |
| 23 |
if (.not. allocated(string%string_)) error stop "unallocated" |
| 24 |
end subroutine |
| 25 |
|
| 26 |
end program |
| 27 |
|