This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR fortran/23516 add IMAG support
On Wed, Sep 21, 2005 at 02:47:30PM -0700, Steve Kargl wrote:
> In intrinsic.c, you find
>
> + /* This provides compatibility with g77. */
> + add_sym_1 ("realpart", 1, 0, BT_REAL, dr, GFC_STD_GNU,
> + gfc_check_fn_c, gfc_simplify_realpart, NULL,
> + a, BT_COMPLEX, dr, REQUIRED);
> +
>
> gfc_check_fn_c is called to check that Z in REALPART(Z) is complex.
> gfc_simplify_realpart is called to do constant folding.
> Until you asked, I thought the NULL was getting mapped to
> gfc_resolve_real via the
>
> make_generic ("real", GFC_ISYM_REAL, GFC_STD_F77);
>
> that collects REAL, SNGL, FLOAT, and REALPART under a generic
> name. But, a -fdump-tree-original on imag_1.f shows
>
> troutmask:sgk[578] more k.f.t02.original
> MAIN__ ()
> {
> real8 y;
> real8 x;
> complex8 z;
>
> z = __complex__ (1.0e+0, 2.0e+0);
> y = IMAGPART_EXPR <z>;
> y = IMAGPART_EXPR <z>;
> x = (real8) (real4) REALPART_EXPR <z>;
> }
>
> Note, the (real4) cast is wrong. I'll need to look at this
> some more.
>
Just to follow-up, if I explicitly add the gfc_resolve_real
/* This provides compatibility with g77. */
add_sym_1 ("realpart", 1, 0, BT_REAL, dr, GFC_STD_GNU,
gfc_check_fn_c, gfc_simplify_realpart, gfc_resolve_real,
a, BT_COMPLEX, dr, REQUIRED);
The -fdump-tree-original output is
troutmask:sgk[580] cat k.f.t02.original
MAIN__ ()
{
real8 y;
real8 x;
complex8 z;
z = __complex__ (1.0e+0, 2.0e+0);
y = IMAGPART_EXPR <z>;
y = IMAGPART_EXPR <z>;
x = REALPART_EXPR <z>;
}
which is what we want.
--
Steve