This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [gfortran] PR 15327: Fix merge intrinsic for strings
- From: Paul Brook <paul at codesourcery dot com>
- To: fortran at gcc dot gnu dot org
- Cc: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>,patch <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 1 Sep 2004 22:36:14 +0100
- Subject: Re: [gfortran] PR 15327: Fix merge intrinsic for strings
- Organization: CodeSourcery
- References: <4132460D.20900@physik.uni-muenchen.de>
On Sunday 29 August 2004 22:09, Tobias Schlüter wrote:
> MERGE didn't work for strings because we neither dealt with the string
> length arguments in the argument list correctly, nor did we create copies
> of the strings. I fixed this by modifying gfc_conv_intrinsic_merge such
> that it now calls a new library function, gfc_conv_intrinsic_merge, in the
> case of string valued arguments.
<snip>
_gfortran_copy_string can copy with overlapping variables, so you shouldn't
need to create a temporary at all.
merge (a, b, flag) should expand to
_result = flag?a:b; _result_length = len(a)
ie. basically the same as the numeric case, but also setting the string
length.
function foo(a, b, flag)
character*(*) foo, a, b
logical flag
foo = merge(a, b, flag)
end function
Should end up as
void foo (char * result, int _result, char *a, char *b, int *flag,
int _a, it _b)
{
_gfortran_copy_string (_result, result, _a, *z ? a ? b);
}
Merge is an elemental function, so the scalarizer should automagically do the
right thing.
Paul