This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran] PR34763 - Allow "END" without "END SUBROUTINE" in INTERFACE


FUNCTION and SUBROUTINE need to end with "END FUNCTION/SUBROUTINE" if
they are module procedures or internal procedures.

Before, all preceding states were tested. The modified check now only
checks for the direct parent.

Build and regtested on x86-64-linux.
OK for the trunk?

Tobias
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.

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(Revision 131501)
+++ gcc/fortran/decl.c	(Arbeitskopie)
@@ -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;
 }
Index: gcc/testsuite/gfortran.dg/interface_proc_end.f90
===================================================================
--- gcc/testsuite/gfortran.dg/interface_proc_end.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/interface_proc_end.f90	(Revision 0)
@@ -0,0 +1,19 @@
+! { dg-do compile}
+!
+! PR fortran/34763
+! Before, gfortran did not allow for the "END" in
+! the interface, which is no module procedure.
+!
+! Test case contributed by Dick Hendrickson
+!
+      module n
+      contains
+      subroutine n_interface
+      INTERFACE
+            SUBROUTINE NGSXDY(TLS1,TLS2)
+            REAL  ::  TLS1,TLS2
+            END ! OK
+      END INTERFACE
+      end ! { dg-error "END SUBROUTINE statement" }
+      end module ! { dg-error "END SUBROUTINE statement" }
+! { dg-excess-errors "Unexpected end of file" }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]