Simon Sobisch - 2023-09-19
  • labels: PERFORM, GO TO, ibm, rm-cobol
  • status: open --> accepted

Ticket moved from /p/gnucobol/feature-requests/446/

Rechecked MF docs and behavior; the default one is identical like the GC one "uses a stack-based perform handling system", while PERFORM-TYPE(OSVS) [undocumented] and PERFORM-TYPE(RM) are identical to the output shown to be the case on IBM compilers.

MF docs say:

the RM/COBOL system associates a return address with a specific procedure name [...], all end-points to PERFORM statements are always active until they are used

The current help for cobc's -fperform-osvs says:

exit point of any currently executing perform is recognized if reached

Also, depending on -fperform-osvs we provide a compiler constant PERFORM-TYPE (can be checked with $IF) that is set to either MF or OSVS.

Therefore I think we should definitely:

  • add this example in our testsuite (the example found there seems to be correct but is both more simple and also confusing because of the fall-through)
  • fix this (without providing an old result option)
  • enable it for rm/cobol (may do so soon)
  • include parsing of PERFORM-TYPE compiler directive, handling "MF", "OSVS" and "RM"

Just for reference - current single test (that will work after a fix, too):

       IDENTIFICATION   DIVISION.
       PROGRAM-ID.      prog.
       DATA             DIVISION.
       WORKING-STORAGE  SECTION.
       01  MYOCC        PIC 9(8) VALUE 0.
       PROCEDURE        DIVISION.
       ASTART SECTION.
       A01.
           PERFORM BTEST.
           IF MYOCC NOT = 2
              DISPLAY MYOCC.
           STOP RUN.
       BTEST SECTION.
       B01.
           PERFORM B02 VARYING MYOCC FROM 1 BY 1
                   UNTIL MYOCC > 5.
           GO TO B99.
       B02.
           IF MYOCC > 1
              GO TO B99
           END-IF.
       B99.
           EXIT.
      *> expected without -fperform-osvs: fall through here

patches welcome

 

Last edit: Simon Sobisch 2023-09-19