https://gcc.gnu.org/g:efc4c77282ece710872cc6521468f17b5a96fc45

commit r16-2717-gefc4c77282ece710872cc6521468f17b5a96fc45
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Sat Aug 2 09:14:14 2025 +0200

    cobol: Use %td in error_msg in 3 spots
    
    On Thu, Jul 31, 2025 at 11:33:07PM +0200, Jakub Jelinek via Gcc wrote:
    > > this was all described in excruciating detail in the patch submission
    > >
    > >     https://gcc.gnu.org/pipermail/gcc-patches/2025-June/687385.html
    > >
    > > and the commit message.
    >
    > Looking at that patch, the dbgmsg change looks correct (dbgmsg is
    > ATTRIBUTE_PRINTF_1), while the last 3 hunks are suboptimal, they should
    > really use %td and keep the ptrdiff_t arguments without casts.
    
    Here it is in patch form.
    I couldn't find other similar casts in calls to ATTRIBUTE_GCOBOL_DIAG
    functions.
    
    2025-08-02  Jakub Jelinek  <ja...@redhat.com>
    
            * parse.y (intrinsic): Use %td format specifier with no cast on
            argument instead of %ld with cast to long.
            * scan_ante.h (numstr_of): Likewise.
            * util.cc (cbl_field_t::report_invalid_initial_value): Likewise.

Diff:
---
 gcc/cobol/parse.y     | 4 ++--
 gcc/cobol/scan_ante.h | 2 +-
 gcc/cobol/util.cc     | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/cobol/parse.y b/gcc/cobol/parse.y
index 59cc64ddeca4..fae96ed5c718 100644
--- a/gcc/cobol/parse.y
+++ b/gcc/cobol/parse.y
@@ -10336,8 +10336,8 @@ intrinsic:      function_udf
                   if( p != NULL ) {
                    auto loc = symbol_field_location(field_index(p->field));
                     error_msg(loc, "FUNCTION %qs has "
-                              "inconsistent parameter type %ld (%qs)",
-                              keyword_str($1), (long)(p - args.data()), 
name_of(p->field) );
+                              "inconsistent parameter type %td (%qs)",
+                              keyword_str($1), p - args.data(), 
name_of(p->field) );
                     YYERROR;
                   }
                   $$ = is_numeric(args[0].field)?
diff --git a/gcc/cobol/scan_ante.h b/gcc/cobol/scan_ante.h
index c00826d652fd..31093a68350f 100644
--- a/gcc/cobol/scan_ante.h
+++ b/gcc/cobol/scan_ante.h
@@ -149,7 +149,7 @@ numstr_of( const char string[], radix_t radix = decimal_e ) 
{
     }
     auto nx = std::count_if(input, p, fisdigit);
     if( 36 < nx ) {
-      error_msg(yylloc, "significand of %s has more than 36 digits (%ld)", 
input, (long)nx);
+      error_msg(yylloc, "significand of %s has more than 36 digits (%td)", 
input, nx);
       return NO_CONDITION;
     }
 
diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc
index 2a7bf2ba86d0..aed9483ff7bb 100644
--- a/gcc/cobol/util.cc
+++ b/gcc/cobol/util.cc
@@ -1049,8 +1049,8 @@ cbl_field_t::report_invalid_initial_value(const YYLTYPE& 
loc) const {
                                                  return TOUPPER(ch) == 'E';
                                                } );
               if( !has_exponent && data.precision() < pend - p ) {
-                error_msg(loc, "%s cannot represent VALUE %qs exactly (max 
%c%ld)",
-                          name, data.initial, '.', (long)(pend - p));
+                error_msg(loc, "%s cannot represent VALUE %qs exactly (max 
%c%td)",
+                          name, data.initial, '.', pend - p);
               }
             }
           }

Reply via email to