[gcc r16-1595] cobol: Correct diagnostic strings for 32-bit builds.
James K. Lowden
jklowden@gcc.gnu.org
Fri Jun 20 21:53:14 GMT 2025
https://gcc.gnu.org/g:007392c0f93cf46b9e87aebdd04e123e3381fc07
commit r16-1595-g007392c0f93cf46b9e87aebdd04e123e3381fc07
Author: James K. Lowden <jklowden@cobolworx.com>
Date: Fri Jun 20 12:43:51 2025 -0400
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:
---
gcc/cobol/genapi.cc | 25 +++++++++++++------------
gcc/cobol/lexio.cc | 6 +++---
gcc/cobol/parse.y | 8 ++++----
gcc/cobol/scan_ante.h | 9 ++++++---
4 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc
index 0ea41f167afa..42f1599a87f6 100644
--- a/gcc/cobol/genapi.cc
+++ b/gcc/cobol/genapi.cc
@@ -957,8 +957,8 @@ parser_compile_ecs( const std::vector<uint64_t>& 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<uint64_t>& 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<uint64_t>& 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<uint64_t>& 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<nusing; i++)
{
@@ -9932,17 +9932,18 @@ inspect_tally(bool backward,
{
SHOW_PARSE_HEADER
char ach[128];
- sprintf(ach, "There are %lu identifier_2", identifier_2.size());
+ sprintf(ach, "There are %lu identifier_2", gb4(identifier_2.size()));
SHOW_PARSE_TEXT(ach);
for(size_t i=0; i<identifier_2.size(); i++)
{
SHOW_PARSE_INDENT
- sprintf(ach, "%lu: bounds: %lu", i, identifier_2[i].nbound());
+ sprintf(ach, "%lu: bounds: %lu", gb4(i), gb4(identifier_2[i].nbound()));
SHOW_PARSE_TEXT(ach);
for(size_t j=0; j<identifier_2[i].nbound(); j++)
{
SHOW_PARSE_INDENT
- sprintf(ach, " %lu: matches: %lu", j, identifier_2[i][j].matches.size());
+ sprintf(ach, " %lu: matches: %lu",
+ gb4(j), gb4(identifier_2[i][j].matches.size()));
SHOW_PARSE_TEXT(ach);
SHOW_PARSE_INDENT
diff --git a/gcc/cobol/lexio.cc b/gcc/cobol/lexio.cc
index 754a948bfc51..5b6000d3c7f4 100644
--- a/gcc/cobol/lexio.cc
+++ b/gcc/cobol/lexio.cc
@@ -1524,11 +1524,11 @@ cdftext::lex_open( const char filename[] ) {
int status;
auto kid = wait(&status);
gcc_assert(pid == kid);
- if( kid == -1 ) cbl_err( "failed waiting for pid %d", pid);
+ if( kid == -1 ) cbl_err( "failed waiting for pid %ld", static_cast<long>(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<long>(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 99295e8db3e3..f0faaa415776 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 037c929aff33..96b688e75128 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<long>(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<long>(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<long>(pid), status);
}
return true;
}
More information about the Gcc-cvs
mailing list