https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87127
--- Comment #4 from paul.richard.thomas at gmail dot com <paul.richard.thomas at gmail dot com> --- Hi Tobias, I have been looking at this one on and off. I think that blocks should be resolved in the same way as contained procedures; I tried adding them to the parent contained list (the night before last) and ended up with segfaults on cleanup. This is easily fixed but I just did not have time. Cheers Paul On Wed, 17 Oct 2018 at 23:43, burnus at gcc dot gnu.org <gcc-bugzi...@gcc.gnu.org> wrote: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87127 > > Tobias Burnus <burnus at gcc dot gnu.org> changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > CC| |burnus at gcc dot gnu.org > > --- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> --- > Variant: > > program test > implicit none > integer :: exfunc, i > call foo() > contains > subroutine foo() > write(*,*) exfunc(i) > end subroutine foo > end program > > > In primary.c's gfc_match_rvalue(), we try to parse a symbol in several ways – > if everything fails: > > /* Give up, assume we have a function. */ > gfc_get_sym_tree (name, NULL, &symtree, false); /* Can't fail */ > sym = symtree->n.sym; > e->expr_type = EXPR_FUNCTION; > if (!sym->attr.function > && !gfc_add_function (&sym->attr, sym->name, NULL)) > > This sets both attr.flavor = FL_PROCEDURE and attr.function = 1. > > If we call "exfunc" in "program test", everything is fine. > > However, if we call "exfunc" in a block (associate) or a contained procedure, > we are in a different namespace. > > In the local namespace, the symbol is FL_PROCEDURE with attr.function. > In the parent namespace, the symbol has will be to FL_VARIABLE. > > In resolve_symbol, one tries to resolve the symbol: > if (sym->attr.flavor == FL_UNKNOWN > || (sym->attr.flavor == FL_PROCEDURE && !sym->attr.intrinsic > && !sym->attr.generic && !sym->attr.external > && sym->attr.if_source == IFSRC_UNKNOWN > && sym->ts.type == BT_UNKNOWN)) > { > > Thus, one ends up with a symbol without attr.function. > > -- > You are receiving this mail because: > You reported the bug.