diff --git a/gcc/cobol/parse_ante.h b/gcc/cobol/parse_ante.h index a799aa0a5e1e6b0d286e1d249a31c0c0785c05ca..29604f3dfa433b295dccc591faf6385a4ba1ee40 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; } }