]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cobol: Correct diagnostic strings for 32-bit builds.
authorJames K. Lowden <jklowden@cobolworx.com>
Fri, 20 Jun 2025 16:43:51 +0000 (12:43 -0400)
committerJames K. Lowden <jklowden@cobolworx.com>
Fri, 20 Jun 2025 21:52:40 +0000 (17:52 -0400)
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.

gcc/cobol/genapi.cc
gcc/cobol/lexio.cc
gcc/cobol/parse.y
gcc/cobol/scan_ante.h

index 0ea41f167afa29a5a7b21c653324c50076609c63..42f1599a87f6739df1f4e889459f0ac5739b7a29 100644 (file)
@@ -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
index 754a948bfc5133e10132ad0b59657dd3a9bcaf4a..5b6000d3c7f406a24280266c93b4d83f693d7ab2 100644 (file)
@@ -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 ) {
index 99295e8db3e3cb3aedc8b6e31d01246c7740c67b..f0faaa4157763b51a314646bc433cd14351da5be 100644 (file)
@@ -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 );
index 037c929aff332b98d27158227af8855cac92a7c0..96b688e75128b9e90a8e486a8cfd6616fd10ff3f 100644 (file)
@@ -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;
 }