BroadcomMFD / cobol-control-flow

COBOL Control Flow is an extension for Visual Studio Code that provides graphical visualization of program flow for programs written in COBOL.
https://marketplace.visualstudio.com/items?itemName=broadcomMFD.ccf
Other
9 stars 8 forks source link

Unreachable Code is still graphed #50

Closed ekuether closed 1 year ago

ekuether commented 1 year ago

Example Code:

   IDENTIFICATION DIVISION.
   PROGRAM-ID. HLLOWRLD
   DATA DIVISION. 

   WORKING-STORAGE SECTION. 
   01  USRNAME           PIC X(10).

   PROCEDURE DIVISION.
   0000-MAIN SECTION.
       PERFORM 1000-GET-NAME
       PERFORM 2000-TEST
       DISPLAY 'HELLO 'USRNAME
       GOBACK
       .
   1000-GET-NAME SECTION.
       ACCEPT USRNAME.
       PERFORM 1000-EXIT.
       PERFORM 2000-TEST.
   1000-EXIT.
       EXIT.
   2000-TEST SECTION.
       PERFORM 2000-EXIT.
   2000-EXIT.
       EXIT.

Example Graph:

image

Issue:

In 1000-GET-NAME, a perform to 1000-EXIT is done before 2000-TEST. 1000-EXIT does an EXIT, thus 2000-TEST will never be performed. However, the graph still has an arrow from 1000-GET-NAME to 2000-TEST.

sergiuilie commented 1 year ago

Hello!



We are actively looking into the issues you open! Investigating to understand better what you tried to achieve and adding some DISPLAY commands in the code, using our mainframe compiler I see that the flow is correctly generated and 2000-TEST is performed from 0000-MAIN SECTION. Could you please run the following code and reply with the output? Also, please let us know what compiler are you using.

   IDENTIFICATION DIVISION.
   PROGRAM-ID. HLLOWRLD
   DATA DIVISION. 

   WORKING-STORAGE SECTION. 
   01  USRNAME           PIC X(10).

   PROCEDURE DIVISION.
   0000-MAIN SECTION.
       PERFORM 1000-GET-NAME
       PERFORM 2000-TEST
       DISPLAY 'HELLO 'USRNAME
       GOBACK
       .
   1000-GET-NAME SECTION.
       ACCEPT USRNAME.
       PERFORM 1000-EXIT.
       DISPLAY 'FROM 1000-GET_NAME'.
       PERFORM 2000-TEST.
   1000-EXIT.
       EXIT.
   2000-TEST SECTION.
       DISPLAY 'FROM 2000-TEST-SECTION'.
       PERFORM 2000-EXIT.
   2000-EXIT.
       EXIT.
ekuether commented 1 year ago

The output is: FROM 1000-GET_NAME FROM 2000-TEST-SECTION FROM 2000-TEST-SECTION HELLO USRNAME

Note: USRNAME was replaced by the input from the Accept We are using IBM Enterprise COBOL Version 6.1

ekuether commented 1 year ago

Thus, this was a mistake on my part, and the graph above is actually correct. I was under the assumption an exit was supposed to exit from the section.

sergiuilie commented 1 year ago

Thank you for your reply! I will proceed and close this issue, please feel free to reopen another issue if encountered.