GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
gcc/cobol

COBOL diagnostics now report correct 'included from' location

COBOL compiler errors now point to the correct line in `COPY` directives when issues arise in included files.

When an error occurred within a COBOL copybook (an included file), the GCC compiler incorrectly reported the error location. This commit refactors the error reporting mechanism to correctly identify and report the line number of the COPY directive itself, rather than a location within the included file. Additionally, it corrects an issue where paragraph and section relationships were misrecorded, affecting PERFORM statements in specific scenarios.

In Details

This commit addresses two issues in the COBOL front-end. First, it corrects erroneous error reporting for issues within COPY directives by ensuring the location points to the COPY statement itself and not within the included file, using cdftext::open_input and cdftext::output_push_directive. Second, it fixes incorrect symbol table recordings of paragraph/section relationships, particularly when the last section involved a PERFORM.

For Context
COBOL
A high-level programming language primarily used in business applications, known for its English-like syntax.
Copybook
In COBOL, a file containing standard data definitions that can be included in multiple programs using the COPY statement. It promotes code reuse and consistency.
Diagnostic
An error or warning message produced by the compiler to inform the programmer about issues in the source code.
PERFORM statement
A COBOL control flow statement used to execute a sequence of paragraphs or sections, similar to a function call or jump.
Filed Under: cobolcompilerdiagnostics