cobol: Honor explicit -ffree-form
GCC COBOL now correctly respects the `-ffree-form` flag, even when the indicator column is set to zero.
GCC’s COBOL compiler now correctly honors the -ffree-form compiler flag. Previously, the compiler might ignore this flag if the command_line_indicator_column was set to 0, causing it to fall back to a heuristic format detection. This commit ensures that an explicit -ffree-form setting is always respected by using a boolean flag and forcing the indicator column to be set.
In Details
The cobol_set_indicator_column function, when called via cdftext::lex_open in gcc/cobol/lexio.cc, previously relied on command_line_indicator_column not being 0 to enforce an explicitly set format. The -ffree-form option, however, sets this value to 0. This commit introduces cdftext::explicit_format boolean flag to gcc/cobol/lexio.h. When -ffree-form is used, this flag is set, and cdftext::lex_open will now unconditionally call source_format_t::indicator_column_set to correctly establish the free-form format, overriding the previous check against 0.
- COBOL
- A compiled programming language designed for business applications. GCC includes a compiler for COBOL.
- -ffree-form
- A GCC compiler flag that instructs the COBOL compiler to treat the source code as using free-form format, allowing more flexible placement of statements.
- indicator column
- In fixed-format COBOL, a specific column used to indicate special characters, such as continuation lines or comment indicators. In free-form COBOL, this concept is less strict but still relevant for certain compiler behaviors.
- heuristic
- A practical approach or rule of thumb used by the compiler to make a decision when an exact solution is complex or impossible. In this case, it's used to guess the source code format (fixed or free).
- lexing
- The process of breaking down source code into a stream of tokens (lexemes), which is the first phase of compilation.