This one is a heisenbug, which showed up in the testsuite while testing a patch but is also present on trunk: $ cat proc_decl_2.f90 program s implicit none procedure() :: q2 procedure() :: q3 procedure() :: q5 procedure(sub) :: p4 procedure(p4) :: p6 contains subroutine sub end subroutine end program s $ gfortran proc_decl_2.f90 proc_decl_2.f90:7.21: procedure(p4) :: p6 1 Error: Interface 'p4' of procedure 'p6' at (1) must be explicit
As depending which line is commented out or not, the bug disappears or appears, my educated guess would be that one does not properly walk a tree and thus not all leafs are found.
procedure(sub) :: p4 procedure(p4) :: p6 The problem is that first sub needs to be resolved for p4 and then p4 before p6. The problem is that "procedure(p4) :: p6" is checked before "procedure(sub) :: p4" and that thus for "p6" sym->interface->attr.if_source == IFSRC_UNKNOWN instead of IFSRC_DECL. This seems to be a tree-walking problem. The solution is to make sure the interfaces are resolved first such that the following holds true: /* Get the attributes from the interface (now resolved). */
Mine - I have patch.
See also: http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/2eea7b997482aa5e/ The answers decides whether http://gcc.gnu.org/ml/fortran/2007-10/msg00362.html or http://gcc.gnu.org/ml/fortran/2007-10/msg00371.html is the correct approach. Additionally, we probably need to fix gfortran for the second example. (The third question there is related to PR 33162.)
This gets difficult. Using procedure(p4) :: p6 procedure(sub) :: p4 is invalid per "C1212 (R1215) [...] If name is declared by a procedure-declaration-stmt it shall be previously declared." ("name" = interface-name) However, depending how the tree is parsed, it is rejected or not (rather independent of my patch). Using Janus' patch, it is always accepted.
Subject: Bug number PR 33917 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-10/msg01622.html
Subject: Bug 33917 Author: burnus Date: Thu Nov 8 15:28:30 2007 New Revision: 130002 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130002 Log: 2007-11-08 Tobias Burnus <burnus@net-b.de> PR fortran/33917 * interface.c (check_sym_interfaces): Disallow PROCEDURE-declared procedures for MODULE PROCEDURE. * decl.c (match_procedure_in_interface): Do not mark as procedure. 2007-11-08 Tobias Burnus <burnus@net-b.de> PR fortran/33917 * gfortran.dg/proc_decl_5.f90: New. * gfortran.dg/proc_decl_6.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/proc_decl_5.f90 trunk/gcc/testsuite/gfortran.dg/proc_decl_6.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/fortran/interface.c trunk/gcc/testsuite/ChangeLog
Sorry, the check in was for PR 33917.
Subject: Bug number PR33917 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00842.html
Subject: Bug 33917 Author: burnus Date: Thu Nov 15 15:12:03 2007 New Revision: 130202 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130202 Log: 2007-11-15 Tobias Burnus <burnus@net-b.de> PR fortran/33917 * decl.c (match_procedure_decl): Pre-resolve interface. * resolve.c (resolve_symbol): Reject interfaces later declared in procedure statements. 2007-11-15 Tobias Burnus <burnus@net-b.de> PR fortran/33917 * gfortran.dg/proc_decl_11.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/proc_decl_11.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog
FIXED on the trunk (4.3.0) [is not part of any branch].