[gfortran] Patch for pr20363
Erik Edelmann
eedelman@acclab.helsinki.fi
Mon Jul 11 19:47:00 GMT 2005
tobias.schlueter@physik.uni-muenchen.de wrote:
> Erik Edelmann wrote:
> > The attached patch fixes pr20363. The problem was the function
> > find_special in decl.c. When in an INTERFACE, we first checked
> > if the name was the name of the interface, and only then, if it
> > wasn't, we looked in the current name space. With this patch, we
> > do it the other way around.
>
> Can you explain to me why we need find_special()? It looks like it would
> simply not make sense to call it in build_sym(). Or anywhere else, for that
> matter, but maybe I misunderstand. And with your patch it doesn't seem to do
> much special any longer.
Well, I thought it would be needed for cases when you need to
access the interface name from within the interface, e.g.
something like
module test
interface foo
pure real function foo1(r)
real, intent(in) :: r(foo(1))
end function foo1
pure integer function foo2(i)
integer, intent(in) :: i
end function foo2
end interface foo
end module test
Now, however, when thinking through this again, and after some
testing, I must agree with you that find_special() is probably
not needed. Patch to remove find_special(), and use
gfc_get_symbol() instead, attached. Bubblestrapped & reg.tested
(4.0 and mainline) on Linux-x86. Please commit if OK.
> > ! { dg-do compile }
> > module snafu
>
> The testcase should say which PR it tests in a comment.
Ok.
ChangeLog entry for patch:
2005-07-11 Erik Edelmann <erik.edelmann@iki.fi>
PR fortran/20363
* decl.c (find_special) Remove function.
(build_sym, add_init_expr_to_sym, attr_decl1) Replace call to
find_special with call to gfc_get_symbol
ChangeLog entry for testcase:
2005-07-11 Erik Edelmann <erik.edelmann@iki.fi>
PR fortran/20363
* gfortran.dg/named_interface.f90: New test.
Erik
-------------- next part --------------
? gcc/testsuite/gfortran.dg/named_interface.f90
Index: gcc/fortran/decl.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/decl.c,v
retrieving revision 1.37
diff -u -p -r1.37 decl.c
--- gcc/fortran/decl.c 6 Jul 2005 22:12:12 -0000 1.37
+++ gcc/fortran/decl.c 11 Jul 2005 18:57:33 -0000
@@ -530,41 +530,6 @@ syntax:
}
-/* Special subroutine for finding a symbol. If we're compiling a
- function or subroutine and the parent compilation unit is an
- interface, then check to see if the name we've been given is the
- name of the interface (located in another namespace). If so,
- return that symbol. If not, use gfc_get_symbol(). */
-
-static int
-find_special (const char *name, gfc_symbol ** result)
-{
- gfc_state_data *s;
-
- if (gfc_current_state () != COMP_SUBROUTINE
- && gfc_current_state () != COMP_FUNCTION)
- goto normal;
-
- s = gfc_state_stack->previous;
- if (s == NULL)
- goto normal;
-
- if (s->state != COMP_INTERFACE)
- goto normal;
- if (s->sym == NULL)
- goto normal; /* Nameless interface */
-
- if (strcmp (name, s->sym->name) == 0)
- {
- *result = s->sym;
- return 0;
- }
-
-normal:
- return gfc_get_symbol (name, NULL, result);
-}
-
-
/* Special subroutine for getting a symbol node associated with a
procedure name, used in SUBROUTINE and FUNCTION statements. The
symbol is created in the parent using with symtree node in the
@@ -616,7 +581,7 @@ build_sym (const char *name, gfc_charlen
symbol_attribute attr;
gfc_symbol *sym;
- if (find_special (name, &sym))
+ if (gfc_get_symbol (name, NULL, &sym))
return FAILURE;
/* Start updating the symbol table. Add basic type attribute
@@ -683,7 +648,7 @@ add_init_expr_to_sym (const char *name,
gfc_expr *init;
init = *initp;
- if (find_special (name, &sym))
+ if (gfc_get_symbol (name, NULL, &sym))
return FAILURE;
attr = sym->attr;
@@ -2722,7 +2687,7 @@ attr_decl1 (void)
if (m != MATCH_YES)
goto cleanup;
- if (find_special (name, &sym))
+ if (gfc_get_symbol (name, NULL, &sym))
return MATCH_ERROR;
var_locus = gfc_current_locus;
-------------- next part --------------
! { dg-do compile }
! Testcase from PR 20363
module snafu
interface foo
subroutine really_snafu (foo)
integer, intent (inout) :: foo
end subroutine really_snafu
end interface foo
end module snafu
More information about the Gcc-patches
mailing list