https://gcc.gnu.org/g:d9d90129f6dd53d2375c5a13a1563c4365e43a2f
commit r17-4753-gd9d90129f6dd53d2375c5a13a1563c4365e43a2f Author: Robert Dubner <[email protected]> Date: Tue Sep 29 14:26:27 2026 -0400 cobol: Update CALL processing when -fno-static-call is operative. This code works properly when the CALL is the last statement in a COBOL source code module. It also works properly with various combinations of CALL "xyz", with or without ON EXCEPTION and whether or not EXCEPTION processing is enabled. Co-authored-by: James K. Lowden <[email protected]> gcc/cobol/ChangeLog: * genapi.cc (parser_call): Proper handling of the ON EXCEPTION clause. * parse.y: Handle missing target when the CALL is the final statement of the source code module. * parse_ante.h: Likewise. Diff: --- gcc/cobol/genapi.cc | 5 +++-- gcc/cobol/parse.y | 8 +++----- gcc/cobol/parse_ante.h | 1 + 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc index acedc4a72503..c0f2b448964d 100644 --- a/gcc/cobol/genapi.cc +++ b/gcc/cobol/genapi.cc @@ -13443,9 +13443,10 @@ parser_call( cbl_refer_t name, if( except ) { - // Preserve the existing ON EXCEPTION routing and reset placement. - gg_append_statement(except->structs.call_exception->into.go_to); + // Set the exception data, but clear the code, because + // ON EXCEPTION prevents exception process. gg_assign(var_decl_exception_code, integer_zero_node); + gg_append_statement(except->structs.call_exception->into.go_to); } else if( !literal_call && issue_warning ) { diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y index 441c4de259ea..78d7f22d894b 100644 --- a/gcc/cobol/parse.y +++ b/gcc/cobol/parse.y @@ -13105,13 +13105,11 @@ possible_ec() { */ static void statement_epilog( int token ) { - cbl_enabled_exceptions_t& enabled_exceptions( cdf_enabled_exceptions() ); if( possible_ec() && token != CONTINUE ) { - if( enabled_exceptions.size() ) { - current.declaratives_evaluate(); - } + current.declaratives_evaluate(); + } else { + parser_check_fatal_exception(); } - parser_check_fatal_exception(); } static inline void diff --git a/gcc/cobol/parse_ante.h b/gcc/cobol/parse_ante.h index 0f190d042d19..db624c78128b 100644 --- a/gcc/cobol/parse_ante.h +++ b/gcc/cobol/parse_ante.h @@ -2401,6 +2401,7 @@ static class current_t { if( enabled_exceptions.size() ) { declaratives_evaluate(); } + parser_check_fatal_exception(); assert(!programs.empty());
