Locating unreachable code in a file

Highlight lines of code in COBOL files in local projects that are unreachable during execution.

Before you begin

Note: Identify Unreachable Code is a feature of real-time syntax checking that flags portions of source code files that are potential dead code. To disable this function, see Setting options for real-time syntax checking (z Systems® LPEX Editor) and Setting options for real-time syntax checking (COBOL Editor).
Supported Editors:
  • COBOL Editor
  • z Systems LPEX Editor
If you are using the COBOL Editor, you can customize the highlighting of unreachable code:
  1. In the Preferences window, navigate to General > Editors > Text Editors > Annotations.
  2. In the Annotation types list, select Warnings.
  3. Choose the annotation options that you want, and click OK to save the changes.

About this task

The Identify Unreachable Code feature identifies potential dead code based on static analysis of the program source and therefore is not a reflection of the actual execution path. Before you delete any code, verify that the code is correctly identified as unreachable.

Restriction: This feature has several restrictions:
  • Copybooks that are associated with the open file are not included in the program analysis. The analysis works within the boundary of the file.
  • Quick fix is not available.
  • Not available for programs that contain the following statements:
    • EXEC CICS HANDLE
    • EXEC CICS IGNORE
    • EXEC CICS PUSH
    • EXEC CICS POP
    • EXEC SQL WHENEVER
  • CALL statements that do not return to the calling program can result in results that are not correct. Statements after a CALL statement are not marked as unreachable.
  • Unreachable code is reported on a per line basis. If a line contains both code that is reachable and code that is unreachable, the reported results might be incorrect. Use the COBOL formatting tool to enforce the one-verb-per-line rule to prevent reachable and unreachable code in the same line.
  • Unreachable code might be incorrectly detected if there is more than one entry statement.