This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch,gfortran] PR 24503: Character functions of non-constant length
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Erik Edelmann <erik dot edelmann at iki dot fi>
- Cc: gfortran <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 25 Oct 2005 10:44:26 -0400
- Subject: Re: [patch,gfortran] PR 24503: Character functions of non-constant length
- References: <20051025143755.GA2914@acclab.helsinki.fi>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Tue, Oct 25, 2005 at 05:37:56PM +0300, Erik Edelmann wrote:
> :ADDPATCH fortran:
>
> Here's a patch to fix PR 24503. The problem is that, for fake
> result character variables of non-connstant length,
> gfc_finish_var_decl will be called. This function, however, is
> apperantly not written with fake result variables in mind. Two
> changes were needed: Add the decl to the current function, rather
> than to the parent, and make an assertion accept fake result
> variables.
Please test the same when using ENTRY without RESULT.
> function s_to_c(chars)
> character, pointer :: chars(:)
> character(len=size(chars)) :: s_to_c
> character(len=size(chars)) :: s_to_c2
> integer :: i
> entry s_to_c2(chars)
>
> do i = 1, size(chars)
> s_to_c2(i:i) = chars(i)
> end do
> end function s_to_c
>
> end module iso
>
> program huj
>
> use iso
> character, pointer :: c(:)
> character(3) :: s
>
> allocate(c(5))
> c = (/"a", "b", "c" /)
> s = s_to_c(c)
>
> end program huj
Jakub