diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc index 1b94e76bc693bc4f402fa635af57dadd3a0e7c0f..9c2ab8ad207a7fb8b1aa174aec23ed646049f201 100644 --- a/gcc/cobol/genapi.cc +++ b/gcc/cobol/genapi.cc @@ -6134,6 +6134,8 @@ parser_allocate(cbl_refer_t size_or_based, void parser_free( size_t n, cbl_refer_t refers[] ) { + if( mode_syntax_only() ) return; // Normally handled by SHOW_PARSE, if present + Analyze(); for( auto p = refers; p < refers + n; p++ ) { diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y index a5b4870bb77bb5ebd4a2b7463b5c3d1ef48808cb..ef027f94ada40ff5c48d256584314fa3e491acb3 100644 --- a/gcc/cobol/parse.y +++ b/gcc/cobol/parse.y @@ -1349,6 +1349,7 @@ cbl_field_t * new_literal( const literal_t& lit, enum cbl_field_attr_t attr ); + static YYLTYPE first_line_of( YYLTYPE loc ); %} %locations @@ -4804,7 +4805,8 @@ statements: statement { $$ = $1; } statement: error { if( current.declarative_section_name() ) { - error_msg(@1, "missing END DECLARATIVES or SECTION name", nparse_error); + error_msg(@1, "missing END DECLARATIVES or SECTION name", + nparse_error); YYABORT; } if( max_errors_exceeded(nparse_error) ) { @@ -6689,7 +6691,7 @@ move_tgt: scalar[tgt] { static const char * error_at; if( error_at != yytext ) { // avoid repeated message error_at = yytext; - error_msg(@1, "invalid receiving operand"); + error_msg(first_line_of(@1), "invalid receiving operand"); } $$ = NULL; } @@ -11053,6 +11055,14 @@ cdf_none: ENTER %% + +static YYLTYPE +first_line_of( YYLTYPE loc ) { + if( loc.first_line < loc.last_line ) loc.last_line = loc.first_line; + if( loc.last_column < loc.first_column ) loc.last_column = loc.first_column; + return loc; +} + void ast_call( const YYLTYPE& loc, cbl_refer_t name, cbl_refer_t returning, size_t narg, cbl_ffi_arg_t args[], cbl_label_t *except,