GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
cobol

cobol: Print arg loc rather than rule loc

Cobol compiler now shows argument location for BY CONTENT expression errors.

This commit refactors the Cobol compiler’s error reporting for ‘BY CONTENT expression’ issues, ensuring it displays the specific argument’s location rather than the location of the parsing rule. This provides more precise feedback to developers when a BY CONTENT expression is used incorrectly, such as when the ‘-dialect ibm’ option is not enabled.

In Details

In the GCC Cobol front-end, the 'BY CONTENT' clause has specific dialect requirements (e.g., requiring '-dialect ibm'). When this clause is misused, the compiler should pinpoint the exact source location of the problematic 'BY CONTENT expression'. This commit modifies the parsing logic in parse_ante.h to use a temporary symbol location for such errors, ensuring the diagnostic points to the argument itself and not a more general rule location.

For Context
BY CONTENT
A Cobol clause that passes a parameter by value, but with the additional semantics of passing a copy of the data, ensuring that modifications within the called program do not affect the caller's variable. Its availability can be dialect-dependent.
Diagnostic
An error, warning, or informational message generated by the compiler to report issues or provide feedback to the programmer about the source code.
Dialect
A specific variant or mode of the Cobol language that the compiler supports, often corresponding to different COBOL standards or vendor implementations (e.g., IBM, Micro Focus).
Filed Under: cobolcompilerdiagnostics