cobol: Improve TYPE reference checking and define YYLOCATION_PRINT
Cobol parser improved to prevent invalid TYPE references and correctly handle user-defined location types for error reporting.
The GCC cobol front-end has been updated to enhance error checking and parser robustness. It now prevents invalid references to TYPEs and provides more informative diagnostic messages. Additionally, it defines the YYLOCATION_PRINT macro to properly handle user-defined cbl_loc_t location types, improving error reporting accuracy.
In Details
The cobol parser (parse.y) had an issue where symbol_typedef could incorrectly refer to the current field being processed, leading to invalid type lookups or crashes (PR126105). This commit fixes that by excluding the current field from type searches within symbol_typedef. It also defines YYLOCATION_PRINT to support custom cbl_loc_t types for better location tracking in Bison-generated parsers.
- TYPE reference
- In COBOL, a reference to a data type definition that specifies the structure and characteristics of data.
- YYLOCATION_PRINT
- A macro used by Bison (a parser generator) to print location information (like line and column numbers) for syntax errors. This commit ensures it works with custom location types.
- Bison
- A parser generator that converts a description of a context-free grammar into a C program that parses those grammar.