| 1 |
! { dg-do compile } |
| 2 |
! Test the fix for PR113885, where not only was there a gimplifier ICE |
| 3 |
! for a derived type 't' with no components but, with a component, gfortran |
| 4 |
! gave wrong results. |
| 5 |
! Contributed by David Binderman <[email protected]> |
| 6 |
! |
| 7 |
module types |
| 8 |
type t |
| 9 |
contains |
| 10 |
final :: finalize |
| 11 |
end type t |
| 12 |
contains |
| 13 |
pure subroutine finalize(x) |
| 14 |
type(t), intent(inout) :: x |
| 15 |
end subroutine finalize |
| 16 |
end module types |
| 17 |
|
| 18 |
subroutine test1(x) |
| 19 |
use types |
| 20 |
interface |
| 21 |
elemental function elem(x) |
| 22 |
use types |
| 23 |
type(t), intent(in) :: x |
| 24 |
type(t) :: elem |
| 25 |
end function elem |
| 26 |
end interface |
| 27 |
type(t) :: x(:) |
| 28 |
x = elem(x) |
| 29 |
end subroutine test1 |
| 30 |
|
| 31 |
subroutine test2(x) |
| 32 |
use types |
| 33 |
interface |
| 34 |
elemental function elem(x) |
| 35 |
use types |
| 36 |
type(t), intent(in) :: x |
| 37 |
type(t) :: elem |
| 38 |
end function elem |
| 39 |
elemental function elem2(x, y) |
| 40 |
use types |
| 41 |
type(t), intent(in) :: x, y |
| 42 |
type(t) :: elem2 |
| 43 |
end function elem2 |
| 44 |
end interface |
| 45 |
type(t) :: x(:) |
| 46 |
x = elem2(elem(x), elem(x)) |
| 47 |
end subroutine test2 |