This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: pr22146 - elemental subroutines
- From: "THOMAS Paul Richard 169137" <paul dot richard dot thomas at cea dot fr>
- To: "Richard E Maine" <Richard dot Maine at nasa dot gov>
- Cc: <fortran at gcc dot gnu dot org>
- Date: Wed, 4 Jan 2006 15:57:32 +0100
- Subject: Re: pr22146 - elemental subroutines
Richard,
I have to thank you for triggering a useful line of investigation, following your pedagogic message. The following program is broken in the second forall block because gfortran turns the interface assignment into a subroutine call, which gfc_trans_forall_1 has no means to deal with. The frontend catches an explicit subroutine call, so I propose to add code to the middle-end to translate a subroutine call. Lahey thinks the code is good.
Cheers
Paul
module type
type itype
integer :: i
end type itype
end module type
module assign
interface assignment (=)
module procedure itype_to_int
end interface
contains
elemental subroutine itype_to_int (i, it)
use type
type(itype), intent(in) :: it
integer, intent(out) :: i
i = it%i
end subroutine itype_to_int
elemental function i_from_itype (it) result (i)
use type
type(itype), intent(in) :: it
integer :: i
i = it
end function i_from_itype
end module assign
program test_assign
use type
use assign
type(itype) :: x(2, 2)
integer :: i(2, 2)
x = reshape ((/(itype (2*j), j = 1,4)/), (/2,2/))
forall (j = 1:2, k = 1:2)
i(j, k) = i_from_itype (x (j, k))
end forall
forall (j = 1:2, k = 1:2)
i(j, k) = x (j, k) ! ICE at trans-stmt.c:2562
end forall
print *, i
end program test_assign