From: James K. Lowden Date: Fri, 20 Jun 2025 16:43:51 +0000 (-0400) Subject: cobol: Correct diagnostic strings for 32-bit builds. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=007392c0f93cf46b9e87aebdd04e123e3381fc07;p=thirdparty%2Fgcc.git cobol: Correct diagnostic strings for 32-bit builds. Avoid %z for printf-family. Cast pid_t to long. Avoid use of YYUNDEF for old Bison versions. PR cobol/120621 gcc/cobol/ChangeLog: * genapi.cc (parser_compile_ecs): Cast argument to unsigned long. (parser_compile_dcls): Same. (parser_division): RAII. (inspect_tally): Cast argument to unsigned long. * lexio.cc (cdftext::lex_open): Cast pid_t to long. * parse.y: hard-code values for old versions of Bison, and message format. * scan_ante.h (wait_for_the_child): Cast pid_t to long. --- diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc index 0ea41f167af..42f1599a87f 100644 --- a/gcc/cobol/genapi.cc +++ b/gcc/cobol/genapi.cc @@ -957,8 +957,8 @@ parser_compile_ecs( const std::vector& ecs ) { SHOW_PARSE_HEADER char ach[64]; - snprintf(ach, sizeof(ach), " Size is %ld; retval is %p", - ecs.size(), as_voidp(retval)); + snprintf(ach, sizeof(ach), " Size is %lu; retval is %p", + gb4(ecs.size()), as_voidp(retval)); SHOW_PARSE_TEXT(ach) SHOW_PARSE_END } @@ -966,8 +966,8 @@ parser_compile_ecs( const std::vector& ecs ) { TRACE1_HEADER char ach[64]; - snprintf(ach, sizeof(ach), " Size is %ld; retval is %p", - ecs.size(), as_voidp(retval)); + snprintf(ach, sizeof(ach), " Size is %lu; retval is %p", + gb4(ecs.size()), as_voidp(retval)); TRACE1_TEXT_ABC("", ach, ""); TRACE1_END } @@ -1006,8 +1006,8 @@ parser_compile_dcls( const std::vector& dcls ) { SHOW_PARSE_HEADER char ach[64]; - snprintf(ach, sizeof(ach), " Size is %ld; retval is %p", - dcls.size(), as_voidp(retval)); + snprintf(ach, sizeof(ach), " Size is %lu; retval is %p", + gb4(dcls.size()), as_voidp(retval)); SHOW_PARSE_TEXT(ach); SHOW_PARSE_END } @@ -1015,8 +1015,8 @@ parser_compile_dcls( const std::vector& dcls ) { TRACE1_HEADER char ach[64]; - snprintf(ach, sizeof(ach), " Size is %ld; retval is %p", - dcls.size(), as_voidp(retval)); + snprintf(ach, sizeof(ach), " Size is %lu; retval is %p", + gb4(dcls.size()), as_voidp(retval)); TRACE1_TEXT_ABC("", ach, ""); TRACE1_END } @@ -6898,7 +6898,7 @@ parser_division(cbl_division_t division, // There are 'nusing' elements in the PROCEDURE DIVISION USING list. - tree parameter; + tree parameter = NULL_TREE; tree rt_i = gg_define_int(); for(size_t i=0; i(pid)); if( WIFSIGNALED(status) ) { - cbl_errx( "%s pid %d terminated by %s", - filter, kid, strsignal(WTERMSIG(status)) ); + cbl_errx( "%s pid %ld terminated by %s", + filter, static_cast(kid), strsignal(WTERMSIG(status)) ); } if( WIFEXITED(status) ) { if( (status = WEXITSTATUS(status)) != 0 ) { diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y index 99295e8db3e..f0faaa41577 100644 --- a/gcc/cobol/parse.y +++ b/gcc/cobol/parse.y @@ -11409,8 +11409,8 @@ keyword_str( int token ) { switch( token ) { case YYEOF: return "YYEOF"; case YYEMPTY: return "YYEMPTY"; - case YYerror: return "YYerror"; - case YYUNDEF: return "invalid token"; + case 256: return "YYerror"; + case 257: return "invalid token"; // YYUNDEF } if( token < 256 ) { @@ -12359,7 +12359,7 @@ numstr2i( const char input[], radix_t radix ) { return output; } if( erc == -1 ) { - yywarn("'%s' was accepted as %wd", input, integer); + yywarn("'%s' was accepted as %zu", input, integer); } return output; } @@ -13141,7 +13141,7 @@ literal_subscripts_valid( YYLTYPE loc, const cbl_refer_t& name ) { // X(0): subscript 1 of for out of range for 02 X OCCURS 4 to 6 error_msg(loc, "%s(%s): subscript %zu out of range " - "for %s %s OCCURS %lu%s", + "for %s %s OCCURS %zu%s", oob->name, subscript_names.c_str(), 1 + isub, oob->level_str(), oob->name, oob->occurs.bounds.lower, upper_phrase ); diff --git a/gcc/cobol/scan_ante.h b/gcc/cobol/scan_ante.h index 037c929aff3..96b688e7512 100644 --- a/gcc/cobol/scan_ante.h +++ b/gcc/cobol/scan_ante.h @@ -824,17 +824,20 @@ wait_for_the_child(void) { } if( WIFSIGNALED(status) ) { - yywarn( "process %d terminated by %s", pid, strsignal(WTERMSIG(status)) ); + yywarn( "process %ld terminated by %s", + static_cast(pid), strsignal(WTERMSIG(status)) ); return false; } if( WIFEXITED(status) ) { if( WEXITSTATUS(status) != 0 ) { - yywarn("process %d exited with status %d", pid, status); + yywarn("process %ld exited with status %d", + static_cast(pid), status); return false; } } if( yy_flex_debug ) { - yywarn("process %d exited with status %d", pid, status); + yywarn("process %ld exited with status %d", + static_cast(pid), status); } return true; }