This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch,gfortran] PR 17740
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: Erik Edelmann <eedelman at acclab dot helsinki dot fi>
- Cc: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Mon, 22 Aug 2005 21:08:09 +0200
- Subject: Re: [patch,gfortran] PR 17740
- References: <20050821210518.GA3716@acclab.helsinki.fi>
Erik Edelmann wrote:
> I've been looking at PR 17740, where we get an ICE when calling
> elemental functions via a generic names. The problem seems to be
> the check if the called function is elemental in
> gfc_trans_arrayfunc_assign():
>
> /* Elemental functions don't need a temporary anyway. */
> if (expr2->symtree->n.sym->attr.elemental)
> return NULL;
>
> The problem is that expr2->symtree->n.sym is (appearantly) the
> symbol of the generic name, not the specific function called. I
> wrote a patch (attached) that checks the symbol
> expr2->value.function.esym instead. With the patch, the testcase
> in the PR compiles, and the patch passes reg. testing (Linux/x86,
> 4.0 and mainline).
>
> There is however, one thing that I am still a bit unsure about (I
> hope this question doesn't sound too stupid); I learned (the hard
> way) that expr2->value.function.esym is NULL sometimes (which is
> why the patch checks that first). Can I trust
> expr2->value.function.esym to allways be non-NULL for elemental
> functions? I browsed the gfortran source code, but found no
> definite answer to that question.
It can apparently, see resolve.c:767.
if (sym->attr.generic)
{
s =
gfc_search_interface (sym->generic, 0, &expr->value.function.actual);
if (s != NULL)
{
expr->value.function.name = s->name;
expr->value.function.esym = s;
expr->ts = s->ts;
if (s->as != NULL)
expr->rank = s->as->rank;
return MATCH_YES;
}
/* TODO: Need to search for elemental references in generic interface */
}
I assume what's missing is that array arguments are matched against elemental
function in interfaces, but I'm not sure.
Furthermore, trans-expr.c:1550 says this:
/* expr.value.function.esym is the resolved (specific) function symbol for
most functions. However this isn't set for dummy procedures. */
sym = expr->value.function.esym;
if (!sym)
sym = expr->symtree->n.sym;
gfc_conv_function_call (se, sym, expr->value.function.actual);
It looks like your patch is correct, but I'd rather we understand when esym
should be set, first.
- Tobi