With gfortran 4.3.0 20080109 I get the error message n_interface.f:7.12: END 1 Error: END SUBROUTINE statement expected at (1) with the following program module n contains subroutine n_interface INTERFACE SUBROUTINE NGSXDY(TLS1,TLS2) REAL :: TLS1,TLS2 END END INTERFACE end end module If the n_interface is an external procedure it works fine. A bare END statement is allowed in interface blocks. I'd guess you are misapplying the constraint after R1224 to things inside of interface blocks. But NGSXDY isn't a module subroutine. You'll probably need a similar fix for functions in interface blocks, although I haven't tried that. Dick Hendrickson
Confirm. (Though you missed "subroutine" for "end subroutine n_interface" in your example.) The Fortran 2003 references are: C1243 (R1230) FUNCTION shall appear in the end-function-stmt of an internal or module function. and C1248 (R1234) SUBROUTINE shall appear in the end-subroutine-stmt of an internal or module subroutine. Seemingly, the contained_procedure() check in decl.c, called by gfc_match_end, does not work properly. Thanks for report.
I believe the following patch is correct. Index: gcc/fortran/decl.c =================================================================== --- gcc/fortran/decl.c (revision 131492) +++ gcc/fortran/decl.c (working copy) @@ -4870,12 +4870,11 @@ gfc_match_bind_c (gfc_symbol *sym, bool static int contained_procedure (void) { - gfc_state_data *s; + gfc_state_data *s = gfc_state_stack; - for (s=gfc_state_stack; s; s=s->previous) - if ((s->state == COMP_SUBROUTINE || s->state == COMP_FUNCTION) - && s->previous != NULL && s->previous->state == COMP_CONTAINS) - return 1; + if ((s->state == COMP_SUBROUTINE || s->state == COMP_FUNCTION) + && s->previous != NULL && s->previous->state == COMP_CONTAINS) + return 1; return 0; }
Patch: http://gcc.gnu.org/ml/gcc-patches/2008-01/msg00567.html
Subject: Bug 34763 Author: burnus Date: Sun Jan 13 21:29:49 2008 New Revision: 131512 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131512 Log: 2008-01-13 Tobias Burnus <burnus@net-b.de> PR fortran/34763 * decl.c (contained_procedure): Only check directly preceeding * state. 2008-01-13 Tobias Burnus <burnus@net-b.de> PR fortran/34763 * gfortran.dg/interface_proc_end.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/interface_proc_end.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/testsuite/ChangeLog
Fixed on the trunk (4.3.0). Thanks for the report!