public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [gfortran] Patch: First constraint to R1220 and R1224
@ 2004-06-10 14:00 Tobias Schlüter
  2004-06-12 16:47 ` Paul Brook
  0 siblings, 1 reply; 2+ messages in thread
From: Tobias Schlüter @ 2004-06-10 14:00 UTC (permalink / raw)
  To: GCC Fortran mailing list, patch


We missed that the Fortran standard requires that the end statementof a 
contained procedure be of the form:
    END {FUNCTION|SUBROUTINE} [procedure-name]

This patch fixes this. I also had to correct a testcase along the way.

2004-06-10  Tobias Schlueter  <tobias.shclueter@physik.uni-muenchen.de>

	PR fortran/14957
	* decl.c (gfc_match_end): Require END {SUBROUTINE|FUNCTION} for
	contained procedure.

testsuite/
	PR fortran/14957
	* gfortran.fortran-torture/execute/stack_varsize.f90: Correct
	syntax errors in end statements of contained subroutines.

Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/decl.c,v
retrieving revision 1.8
diff -u -p -r1.8 decl.c
--- decl.c      27 May 2004 12:35:11 -0000      1.8
+++ decl.c      10 Jun 2004 12:27:16 -0000
@@ -1876,9 +1876,15 @@ gfc_match_end (gfc_statement * st)
    if (gfc_match_eos () == MATCH_YES)
      {

+      state = gfc_current_state ();
+
        if (*st == ST_ENDIF || *st == ST_ENDDO || *st == ST_END_SELECT
           || *st == ST_END_INTERFACE || *st == ST_END_FORALL
-         || *st == ST_END_WHERE)
+         || *st == ST_END_WHERE
+         || /* A contained procedure requires END FUNCTION/SUBROUTINE.  */
+            ((state == COMP_FUNCTION || state == COMP_SUBROUTINE)
+             && gfc_state_stack->previous != NULL
+             && gfc_state_stack->previous->state == COMP_CONTAINS))
         {

           gfc_error ("%s statement expected at %C",

Index: stack_varsize.f90
===================================================================
RCS file: 
/cvs/gcc/gcc/gcc/testsuite/gfortran.fortran-torture/execute/stack_varsize.f90,v
retrieving revision 1.2
diff -u -p -r1.2 stack_varsize.f90
--- stack_varsize.f90   13 May 2004 06:40:54 -0000      1.2
+++ stack_varsize.f90   10 Jun 2004 12:33:18 -0000
@@ -17,7 +17,7 @@ contains
        k = 30
        if ((a .ne. 10.0).or.(b(1) .ne. 20.0).or.(c(1) .ne. 30.0)) call 
abort
        if ((m .ne. 10).or.(n(256,4) .ne. 20).or.(k(1,1024) .ne. 30)) 
call abort
-   end
+   end subroutine

     ! Local variables defined in recursive subroutine are always put on 
stack.
     recursive subroutine sub2 (n)
@@ -26,5 +26,5 @@ contains
        if (n .ge. 1) call sub2 (n-1)
        if (a(1) .ne. 42) call abort
        a (1) = 0
-   end
+   end subroutine
  end

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [gfortran] Patch: First constraint to R1220 and R1224
  2004-06-10 14:00 [gfortran] Patch: First constraint to R1220 and R1224 Tobias Schlüter
@ 2004-06-12 16:47 ` Paul Brook
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Brook @ 2004-06-12 16:47 UTC (permalink / raw)
  To: fortran; +Cc: Tobias Schlüter, patch

> 2004-06-10  Tobias Schlueter  <tobias.shclueter@physik.uni-muenchen.de>
>
> 	PR fortran/14957
> 	* decl.c (gfc_match_end): Require END {SUBROUTINE|FUNCTION} for
> 	contained procedure.
>
> testsuite/
> 	PR fortran/14957
> 	* gfortran.fortran-torture/execute/stack_varsize.f90: Correct
> 	syntax errors in end statements of contained subroutines.

Ok.

Paul

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-06-12 14:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-10 14:00 [gfortran] Patch: First constraint to R1220 and R1224 Tobias Schlüter
2004-06-12 16:47 ` Paul Brook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).