WEDNESDAY, JULY 8, 2026
cobol
cobol: Add diagnostic for SORT without defined key
Cobol parser now generates a specific error diagnostic for SORT statements missing a defined key, preventing crashes.
The GCC COBOL front-end now provides a specific error diagnostic when a SORT statement is used without a key clause being defined. Previously, this situation could lead to a parser crash. This change (PR cobol/126106) improves error handling by reporting a clear message instead of failing abruptly.
In Details
PR cobol/126105 identified a crash in parse.y when encountering a COBOL SORT statement lacking a KEY clause. This commit adds a specific diagnostic to parse.y to report this condition as an error, rather than allowing the parser to proceed into an invalid state and crash.
For Context
- SORT statement
- A COBOL statement used to sort records in a file or data set based on specified keys.
- key clause
- In a COBOL SORT statement, specifies the data item(s) to be used for sorting the records. Defining a key is typically mandatory for a meaningful sort.
- diagnostic
- An error or warning message generated by the compiler to inform the programmer about issues in the source code.