https://gcc.gnu.org/g:f55108a98825c8338b5718004344af02f79353be
commit r17-4818-gf55108a98825c8338b5718004344af02f79353be Author: Xavier Del Campo Romero <[email protected]> Date: Wed Sep 30 22:54:57 2026 +0200 cobol: Honor explicit -ffree-form Previously, an explicit format was only determined as long as command_line_indicator_column did not equal 0. However, OPT_ffree_form assigns it to 0 via cobol_set_indicator_column, and therefore the explicit user setting was being ignored, falling back to the default behaviour, a heuristic where the first {PROGRAM,FUNCTION}-ID is examined to determine whether either fixed or free format should be applied. Since comparing against 0 is not enough to determine whether a given format was explicitly requested, a boolean flag has been added to force a call to source_format_t::indicator_column_set whenever -ffree-form is requested. gcc/cobol/ChangeLog: * lexio.cc (cdftext::lex_open): Add explicit_format condition. (cobol_set_indicator_column): Use cdftext::explicit_format. * lexio.h (class cdftext): Add cdftext::explicit_format. Diff: --- gcc/cobol/lexio.cc | 4 +++- gcc/cobol/lexio.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/cobol/lexio.cc b/gcc/cobol/lexio.cc index 71bc21edefa3..8b7f6e3692ef 100644 --- a/gcc/cobol/lexio.cc +++ b/gcc/cobol/lexio.cc @@ -1509,7 +1509,7 @@ cdftext::lex_open( const char filename[] ) { source_format_stack_t source_format; source_format_t format; // free-form by default - if( command_line_indicator_column ) { + if( command_line_indicator_column || explicit_format ) { format.indicator_column_set(command_line_indicator_column); } source_format.push(format); @@ -1867,10 +1867,12 @@ cdftext::free_form_reference_format( int input, bool cdftext::please_push_filename = false; int cdftext::command_line_indicator_column = 0; +bool cdftext::explicit_format = false; void cobol_set_indicator_column( int column ) { cdftext::command_line_indicator_column = column; + cdftext::explicit_format = true; source_format_t local; local.indicator_column_set(column); dbgmsg("%s: format now %s", __func__, local.description()); diff --git a/gcc/cobol/lexio.h b/gcc/cobol/lexio.h index 76af58d96022..742e28eb18de 100644 --- a/gcc/cobol/lexio.h +++ b/gcc/cobol/lexio.h @@ -353,6 +353,7 @@ typedef std::stack<source_format_t> source_format_stack_t; class cdftext { static bool please_push_filename; static int command_line_indicator_column; + static bool explicit_format; friend void cobol_set_indicator_column( int column );
