[go: up one dir, main page]

Menu

#752 Compilation error when using -std=mvs-strict and code contains EXIT PARAGRAPH

invalid
closed
nobody
ibm (10)
9 - lowest
2021-08-24
2021-08-16
Emmad
No

The following program was compiled under WINDOWS 10
Using :
cobc (GnuCOBOL) 3.1.2.0
Command:
cobc.exe C.cbl -free -std=mvs-strict -x -o C.EXE
Compiler Error Message:

C.cbl:16: error: syntax error, unexpected Identifier

Related code:

::cobolfree
       IDENTIFICATION   DIVISION.
       PROGRAM-ID.      BASE1.
       ENVIRONMENT      DIVISION.
       CONFIGURATION    SECTION.
       INPUT-OUTPUT     SECTION.
       FILE-CONTROL.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  WS-X PIC X(10).
       PROCEDURE DIVISION.
           PERFORM P10 THRU P10-E.
           MOVE "X" TO WS-X.
           MOVE ZERO TO RETURN-CODE.    
           STOP RUN.
       P10.
           IF WS-X NOT EQUAL SPACES THEN EXIT PARAGRAPH END-IF  *> line 16 - error
           DISPLAY WS-X.
       P10-E. EXIT.

Discussion

  • Vincent (Bryan) Coen

    Can you try this with a coding change :

    replace P10 1st line with

    IF WS-X not = spaces go to P10-E2.
    

    at end do:

    P10-E2.
          EXIT PARAGRAPH.
    

    see if that works as an EXIT verb should be by itself and NOT in an IF statement.

     

    Last edit: Simon Sobisch 2021-08-24
    • Arnold Trembley

      Arnold Trembley - 2021-08-17

      This is not true for IBM Enterprise COBOL version 6.3:
      https://publibfp.boulder.ibm.com/epubs/pdf/igy6lr30.pdf

      There are six different uses for the EXIT verb (which by itself is equivalent to the CONTINUE verb). This is what the IBM COBOL manual says about EXIT PARAGRAPH:

      "The EXIT PARAGRAPH statement controls the exit from the middle of a paragraph without executing any following statements within the paragraph. The EXIT SECTION statement controls the exit from a section without executing any following statements within the section.
      ...
      "When an EXIT PARAGRAPH statement is executed, control is passed to an implicit CONTINUE statement that immediately follows the last explicit statement of the current paragraph. This return mechanism supersedes any other return mechanisms that are associated with language elements, such as PERFORM, SORT, and USE for that paragraph."

      So it should be perfectly valid to put EXIT PARAGRAPH inside an IF statement, or anywhere in a paragraph.

      And, despite what the COBOL standard may say, IBM has never required EXIT to be the only verb in a paragraph, or the last verb in a paragraph, going back to IBM OS/VS COBOL in the late 1970's.

      So in my opinion this is a true bug, and should be corrected, even though EXIT PARAGRAPH was never supported in IBM Enterprise COBOL for zOS (version 4.2). It takes IBM a while to incorporate 2002 and 2014 standard COBOL features.

       
    • Emmad

      Emmad - 2021-08-18

      Thank you for your suggestion, I posted this code just as a demo of the issue, it is not real code.

       
  • Simon Sobisch

    Simon Sobisch - 2021-08-17

    Does this compile with old MVS? If yes, can you point to some docs?
    Does it compile with -std=ibm?

     
    • Arnold Trembley

      Arnold Trembley - 2021-08-18

      Here are links to IBM COBOL for z/OS manuals:

      Enterprise COBOL for z/OS documentation library
      https://www.ibm.com/support/pages/enterprise-cobol-zos-documentation-library

      IBM Enterprise COBOL for Z/OS 4.2 - Language Reference Manual (August 2009)
      https://publibfp.boulder.ibm.com/epubs/pdf/igy3lr50.pdf

      IBM Enterprise COBOL for Z/OS 5.2 - Language Reference Manual (November 2018)
      https://publibfp.boulder.ibm.com/epubs/pdf/igy5lr20.pdf

      IBM Enterprise COBOL for Z/OS 6.3 - Language Reference Manual (30 July 2021)
      https://publibfp.boulder.ibm.com/epubs/pdf/igy6lr30.pdf

      They're only available in English or Japanese. I have downloaded the indicated IBM Enterprise COBOL for z/OS "Language Reference" manuals. I believe that EXIT PARAGRAPH, EXIT SECTION, and EXIT PERFORM CYCLE were added as part of the 2002 COBOL standard, but the first time they are mentioned in the IBM COBOL Language Reference Manuals is IBM Enterprise COBOL version 5.2 (November 2018).

      So it's a difficult question. Some versions of IBM Enterprise COBOL for z/OS will allow EXIT PARAGRAPH, and older versions will not be able to compile it. I don't think GnuCOBOL ought to support different levels of ibm-strict for IBM compilers that are technically no longer supported by IBM. But there are reasonable arguments for and against.

      Kind regards,

       
      • Emmad

        Emmad - 2021-08-18

        Thank you for the huge effort. You are correct about the possible conflict implementation views. While I personally can live without it, I think that it will be a common feature in the future.
        Thank you always for your support.
        EK

         
  • Simon Sobisch

    Simon Sobisch - 2021-08-24
    • labels: --> ibm
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,16 +1,15 @@
    -The following program was compiled under 
    -WINDOWS 10
    +The following program was compiled under WINDOWS 10
     Using : 
     cobc (GnuCOBOL) 3.1.2.0
     Command:
    - cobc.exe C.cbl -free  -std=mvs-strict  -x -o C.EXE
    +`cobc.exe C.cbl -free  -std=mvs-strict  -x -o C.EXE`
     Compiler Error Message:
    -C.cbl:16: error: syntax error, unexpected Identifier
    +> C.cbl:16: error: syntax error, unexpected Identifier
    
    -Related link:
    +Related code:
     ~~~
    -
    -      IDENTIFICATION   DIVISION.
    +::cobolfree
    +       IDENTIFICATION   DIVISION.
            PROGRAM-ID.      BASE1.
            ENVIRONMENT      DIVISION.
            CONFIGURATION    SECTION.
    @@ -29,5 +28,3 @@
               DISPLAY WS-X.
           P10-E. EXIT.
     ~~~
    -       
    -       
    
    • status: open --> closed
    • Group: unclassified --> invalid
     
  • Simon Sobisch

    Simon Sobisch - 2021-08-24

    -std=mvs-strict is for "MVS/VM COBOL", that is a very old IBM dialect, with a heavy reduced reserved word set. Until shown otherwise by documentation there is no PARAGRAPH reserved word in this old dialect (and by rechecking the MF reserved words I can see that they think the same).

    -std=ibm-strict is for a recent "IBM Enterprise COBOL" and you seem to want to use this one.
    Question: Is there a specific reason for you to target the MVS dialect?

     
    • Emmad

      Emmad - 2021-08-24

      Thank you for clarifying and researching this issue.
      All I need is to write batch COBOL program on Windows, and run it on IBM Enterprise COBOL, and possibly in the future support UNIX.

      I will now use the -stb=ibm-strict

      Thank you much. Stay safe.
      EK

       

Log in to post a comment.