This is the mail archive of the gcc@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]

[RFC] Extension of SIMPLE for Fortran 95


Hello,

This weekend we discussed the Fortran CYCLE (eqv. of C 'continue') and EXIT
(eqv. of 'break') statements on the G95 mailing list. In Fortran 95, you can
have:

OUTER:  DO I=...
           ...
   INNER:  DO J=...
              ...
              IF (something) THEN
                 CYCLE OUTER
              ELSE IF (something else) THEN
                 EXIT OUTER
              ENDIF
              ...
           END DO INNER
           ...
            
        END DO OUTER

We want to lower our parse tree to SIMPLE, but we can't represent this kind
of CYCLE and EXIT statements in SIMPLE.

The back end *does* provide functions for expanding break/continue from
nested loops (http://cobolforgcc.sourceforge.net/cobol_14.html#SEC138), but
it seems that only g77 uses these routines to break from an outer loop, or
to continue a nested loop.

So I would like to propose an extension to the SIMPLE grammar:
How about adding an integer argument to the 'continue' and 'break'
statements, that gives how many loops to break or continue from. 'continue'
without argument would be the "normal" continue statement, 'continue 1'
would contine the second-innermost loop, etc.

I don't think this change would require a lot of changes in the existing
code, and it would make SIMPLE a little more language independent. It would
help G95, too ;-)

Sounds OK?

Greetz
Steven


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