This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[Patch, Fortran] PR40176 comment #5
- From: Janus Weil <janus at gcc dot gnu dot org>
- To: gfortran <fortran at gcc dot gnu dot org>, gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 12 Jun 2009 21:25:04 +0200
- Subject: [Patch, Fortran] PR40176 comment #5
Hi all,
here is a simple patch for an outstanding issue of PR40176: In my
orginal patch for this PR (which fixed procedure pointers with array
return values), I introduced a possible infinite loop by calling
resolve_symbol recursively for PROCEDURE interfaces, which was
discovered by Dominique shortly after I committed the patch (comment
#5 in the PR). The attached patch prevents this infinite loop, and
adds an error message for PROCEDURE statements where the procedure is
used as its own interface.
Regtested on x86_64-unknown-linux-gnu. Ok for trunk?
Cheers,
Janus
2009-06-12 Janus Weil <janus@gcc.gnu.org>
PR fortran/40176
* resolve.c (resolve_symbol): Additional error check, preventing an
infinite loop.
2009-06-12 Janus Weil <janus@gcc.gnu.org>
PR fortran/40176
* gfortran.dg/proc_decl_1.f90: Extended.
Index: gcc/testsuite/gfortran.dg/proc_decl_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/proc_decl_1.f90 (revision 148430)
+++ gcc/testsuite/gfortran.dg/proc_decl_1.f90 (working copy)
@@ -57,6 +57,8 @@ program prog
procedure ( ) :: r
procedure ( up ) :: s ! { dg-error "must be explicit" }
+ procedure(t) :: t ! { dg-error "may not be used as its own interface" }
+
call s
contains
Index: gcc/fortran/resolve.c
===================================================================
--- gcc/fortran/resolve.c (revision 148430)
+++ gcc/fortran/resolve.c (working copy)
@@ -9406,10 +9406,19 @@ resolve_symbol (gfc_symbol *sym)
if (sym->attr.procedure && sym->ts.interface
&& sym->attr.if_source != IFSRC_DECL)
{
+ if (sym->ts.interface == sym)
+ {
+ gfc_error ("PROCEDURE '%s' at %L may not be used as its own "
+ "interface", sym->name, &sym->declared_at);
+ return;
+ }
if (sym->ts.interface->attr.procedure)
- gfc_error ("Interface '%s', used by procedure '%s' at %L, is declared "
- "in a later PROCEDURE statement", sym->ts.interface->name,
- sym->name,&sym->declared_at);
+ {
+ gfc_error ("Interface '%s', used by procedure '%s' at %L, is declared"
+ " in a later PROCEDURE statement", sym->ts.interface->name,
+ sym->name,&sym->declared_at);
+ return;
+ }
/* Get the attributes from the interface (now resolved). */
if (sym->ts.interface->attr.if_source