Skip to content

Commit efc4c77

Browse files
committed
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 <[email protected]> * 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.
1 parent 09a3da8 commit efc4c77

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

gcc/cobol/parse.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10336,8 +10336,8 @@ intrinsic: function_udf
1033610336
if( p != NULL ) {
1033710337
auto loc = symbol_field_location(field_index(p->field));
1033810338
error_msg(loc, "FUNCTION %qs has "
10339-
"inconsistent parameter type %ld (%qs)",
10340-
keyword_str($1), (long)(p - args.data()), name_of(p->field) );
10339+
"inconsistent parameter type %td (%qs)",
10340+
keyword_str($1), p - args.data(), name_of(p->field) );
1034110341
YYERROR;
1034210342
}
1034310343
$$ = is_numeric(args[0].field)?

gcc/cobol/scan_ante.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ numstr_of( const char string[], radix_t radix = decimal_e ) {
149149
}
150150
auto nx = std::count_if(input, p, fisdigit);
151151
if( 36 < nx ) {
152-
error_msg(yylloc, "significand of %s has more than 36 digits (%ld)", input, (long)nx);
152+
error_msg(yylloc, "significand of %s has more than 36 digits (%td)", input, nx);
153153
return NO_CONDITION;
154154
}
155155

gcc/cobol/util.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,8 +1049,8 @@ cbl_field_t::report_invalid_initial_value(const YYLTYPE& loc) const {
10491049
return TOUPPER(ch) == 'E';
10501050
} );
10511051
if( !has_exponent && data.precision() < pend - p ) {
1052-
error_msg(loc, "%s cannot represent VALUE %qs exactly (max %c%ld)",
1053-
name, data.initial, '.', (long)(pend - p));
1052+
error_msg(loc, "%s cannot represent VALUE %qs exactly (max %c%td)",
1053+
name, data.initial, '.', pend - p);
10541054
}
10551055
}
10561056
}

0 commit comments

Comments
 (0)