From f00c054a1a5a78fa638e859c6de05589b53de13d Mon Sep 17 00:00:00 2001 From: "James K. Lowden" <jklowden@symas.com> Date: Tue, 17 Dec 2024 17:34:30 -0500 Subject: [PATCH] first_statement for each program --- gcc/cobol/parse_ante.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/gcc/cobol/parse_ante.h b/gcc/cobol/parse_ante.h index a799aa0a5e1e..29604f3dfa43 100644 --- a/gcc/cobol/parse_ante.h +++ b/gcc/cobol/parse_ante.h @@ -1733,6 +1733,7 @@ static class current_t { program_stack_t programs; unique_typedefs_t typedefs; std::set<function_descr_t> udfs; + int first_statement; bool in_declaratives; // from command line or early TURN std::list<cbl_exception_files_t> cobol_exceptions; @@ -1765,7 +1766,8 @@ static class current_t { public: current_t() - : in_declaratives(false) + : first_statement(0) + , in_declaratives(false) {} bool option( cbl_options_t::arith_t option ) { @@ -2040,6 +2042,7 @@ static class current_t { } options_paragraph = cbl_options_t(); + first_statement = 0; return fOK; } @@ -2136,7 +2139,13 @@ static class current_t { return symbol_index(symbol_elem_of(section)); } - bool doing_declaratives() const { return in_declaratives; } + bool is_first_statement( int line ) { + if( ! in_declaratives && first_statement == 0 ) { + first_statement = line; + return true; + } + return false; + } cbl_label_t *doing_declaratives( bool begin ) { if( begin ) { @@ -3599,9 +3608,7 @@ static int prior_statement; static size_t statement_begin( const YYLTYPE& loc, int token ); static void ast_first_statement( int first_line ) { - static bool first = true; - if( first && ! current.doing_declaratives() ) { + if( current.is_first_statement( first_line ) ) { parser_first_statement(first_line); - first = false; } } -- GitLab