On Sun, Apr 06, 2025 at 03:39:27PM +0200, Jakub Jelinek wrote:
> Right now it is not possible to even build cross-compilers from 32-bit
> architectures to e.g. x86_64-linux or aarch64-linux, even from little-endian
> ones.
>
> The following patch attempts to fix that.
>
> There were various issues seen e.g. trying to build i686-linux ->
> x86_64-linux cross-compiler (so still 64-bit libgcobol, but the compiler
> is 32-bit).
> 1) warning about >> 32 shift of size_t, on 32-bit arches size_t is 32-bit
> and so the shift is UB; fixed by doing (new_size>>16)>>16 so that
> it ors in >> 32 when new_size is 64-bit and 0 when it is 32-bit
> 2) enum cbl_field_attr_t was using size_t as underlying type, but has
> various bitmasks which require full 64-bit type; changed this to uint64_t
> underlying type and using unsigned long long in the structure; various
> routines which operate with those attributes had to be changed also to
> work with uint64_t instead of size_t
> 3) on i686-linux, config.h can #define _FILE_OFFSET_BITS 64 or similar
> macros; as documented, those macros have to be defined before including
> first C library header, but some sources included cobol-system.h which
> includes config.h only after various other headers; this resulted in
> link failures, as ino_t was sometimes unsigned long and sometines
> unsigned long long, depending on whether config.h was included first or
> not, and e.g. cobol_filename uses ino_t argument
> 4) lots of places used %ld or %lx *printf format specifers with size_t
> arguments; that works only if size_t is unsigned long, but not when it
> is unsigned int or unsigned long long or some other type; now while
> ISO C99 has %zd or %zx to print size_t and C++14 includes C99 (or C11?),
> while for the C++ headers the C++ compilers typically have full control
> over it and so support everything in C++14 (e.g. libstdc++ in GCC 5.1+
> or libc++ if not too old), for C library we are dependent on the system
> C library (note, on the host for the compiler side). And not all hosts
> support C99 in their C libraries; so instead of just changing it to
> %zd or %zx, I'm changing it to what we use elsewhere in GCC,
> HOST_SIZE_T_PRINT_{DEC,UNSIGNED,HEX_PURE} or GCC_PRISZ macros in the
> *printf family format string and casts of the size_t arguments to
> fmt_size_t. Note, if not using the C library *printf family (e.g. in
> dbgmsg, sprintf, snprintf, fprintf, etc.) but the GCC diagnostic code
> (e.g. err_msg, error, warning, yywarn, ...), then %zd/%zu is supported
> and on the other side HOST_SIZE_T_PRINT_{DEC,UNSIGNED,HEX_PURE} etc.
> macros shouldn't be used (for two reasons, because it is unnecessary
> when %zd/%zu is guaranteed to be supported there because GCC has
> control over that and more importantly because it breaks translations,
> both extraction of the to be translated strings and we don't want to
> have different messages, once with %lld, once with %ld, once with just %d
> or %I64d depending on host, translators couldn't translate it all).
> 5) see above, there were already tons of %zd/%zu or %3zu etc. format
> specifers in *printf format strings, this patch changes those too
> 6) I've noticed dbgmsg wasn't declared with printf attribute, which resulted
> in bugs where format specifiers didn't match actually passed types of
> arguments
Here is an updated patch against latest trunk.
Maintaining the patch is a nightmare, got several dozens of rejects
that I had to deal with.
Bootstrapped/regtested on x86_64-linux and tested with i686-linux ->
x86_64-linux cross, ok for trunk?
2025-05-02 Jakub Jelinek <[email protected]>
PR cobol/119364
libgcobol/
* valconv.cc (__gg__realloc_if_necessary): Use (new_size>>16)>>16;
instead of new_size>>32; to avoid warnings on 32-bit hosts.
* common-defs.h (enum cbl_field_attr_t): Use uint64_t
as underlying type rather than size_t.
* gcobolio.h (cblc_field_t): Change attr member type from size_t
to unsigned long long.
gcc/cobol/
* util.cc (is_numeric_edited): Use HOST_SIZE_T_PRINT_UNSIGNED
instead of "%zu" and cast corresponding argument to fmt_size_t.
(normalize_picture): Use GCC_PRISZ instead of "z" and pass address
of fmt_size_t var to sscanf and copy afterwards.
(cbl_refer_t::str): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" and cast corresponding argument
to fmt_size_t.
(struct move_corresponding_field): Likewise.
(valid_move): Likewise.
(ambiguous_reference): Likewise.
(parent_names): Likewise.
(find_corresponding::find_corresponding): Likewise.
(corresponding_fields): Likewise.
(unique_stack::push): Likewise.
(cobol_filename): Likewise.
* lexio.cc: Include config.h first.
(recognize_replacements): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" and cast corresponding argument
to fmt_size_t.
(check_source_format_directive): Likewise.
(parse_replacing_pair): Use size_t(0) instead of 0UL in span_t
construction.
(parse_replace_pairs): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(parse_copy_directive): Likewise.
(parse_replace_last_off): Likewise.
(parse_replace_text): Likewise.
(bytespan_t::append): Likewise.
(cdftext::map_file): Likewise.
(cdftext::process_file): Likewise.
* symfind.cc (dump_symbol_map2): Likewise.
(dump_symbol_map_value): Likewise.
(build_symbol_map): Likewise.
(is_name::dump_key): Likewise.
(symbol_match2): Likewise.
(symbol_find): Likewise.
(symbol_find_of): Likewise.
* cdf.y: Likewise.
* symbols.cc: Include config.h first.
(cbl_field_t::set_attr): Return uint64_t rather than size_t
and replace size_t(attr) with uint64_t(attr).
(cbl_field_t::clear_attr): Likewise.
(symbol_field_capacity): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(symbol_find_odo_debug): Likewise.
(symbols_dump): Likewise.
(calculate_capacity): Likewise.
(field_str): Likewise.
(symbols_update): Likewise.
(symbol_field_forward): Likewise.
(numeric_group_attrs): Return uint64_t rather than size_t and
change inherit variable to from size_t to uint64_t.
(new_literal_add): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(temporaries_t::dump): Likewise.
(cbl_label_t::str): Likewise.
(symbol_label_add): Likewise.
(symbol_program_add): Likewise.
(symbol_forward_names): Likewise.
(symbol_forward_to): Likewise.
(cbl_file_key_t::deforward): Likewise.
(cbl_file_key_t::str): Likewise.
* gengen.cc (show_type): Use PRId64 instead of "ld".
(gg_unique_in_function): Use HOST_SIZE_T_PRINT_DEC instead of
%ld and cast corresponding argument to fmt_size_t.
* scan.l: Add %top section with #include "config.h".
* genmath.cc (parser_add): Use HOST_SIZE_T_PRINT_DEC instead of
%ld and cast corresponding argument to fmt_size_t.
(parser_subtract): Likewise.
* parse.y: Include "config.h" before <fstream>. Use
HOST_SIZE_T_PRINT_UNSIGNED instead of "%zu" and cast corresponding
argument to fmt_size_t. Change type of sign_attrs, group_sign and
type_implies from size_t to uint64_t.
(perform_t::ec_labels_t::new_label): Use HOST_SIZE_T_PRINT_UNSIGNED
instead of "%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC
instead of "%zd" and cast corresponding argument to fmt_size_t.
(stringify_src_t::dump): Likewise.
(lang_check_failed): Likewise.
(numstr2i): Use GCC_PRISZ instead of "z" and pass address of temporary
with fmt_size_t type to sscanf and then copy it over.
(initialize_statement): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(dump_inspect_oper): Likewise.
(new_literal): Likewise.
(literal_subscripts_valid): Likewise.
(eval_subject_t::label): Likewise.
* genapi.cc (level_88_helper): Likewise.
(parser_call_targets_dump): Likewise.
(combined_name): Use HOST_SIZE_T_PRINT_DEC instead of "%ld"
and cast corresponding argument to fmt_size_t.
(section_label): Likewise.
(paragraph_label): Likewise.
(leave_procedure): Likewise.
(parser_perform): Likewise.
(parser_perform_times): Likewise.
(internal_perform_through): Likewise.
(internal_perform_through_times): Likewise.
(parser_enter_program): Likewise.
(parser_init_list_size): Likewise.
(parser_init_list): Likewise.
(psa_FldLiteralN): Likewise.
(psa_FldBlob): Likewise.
(parser_assign): Likewise.
(parser_free): Pass p->field->name to dbgmsg.
(parser_division): Use HOST_SIZE_T_PRINT_DEC instead of "%ld"
and cast corresponding argument to fmt_size_t.
(perform_outofline_before_until): Likewise.
(perform_outofline_after_until): Likewise.
(perform_outofline_testafter_varying): Likewise.
(perform_outofline_before_varying): Likewise.
(perform_inline_testbefore_varying): Likewise.
(parser_inspect): Change n_operations parameter type from
unsigned long to size_t.
(parser_intrinsic_callv): Use HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(parser_bitop): Use HOST_SIZE_T_PRINT_HEX_PURE instead of
"%lx" and cast corresponding argument to fmt_size_t.
(parser_bitwise_op): Likewise.
(parser_program_hierarchy): Use HOST_SIZE_T_PRINT_DEC instead of "%ld"
and cast corresponding argument to fmt_size_t.
(parser_set_handled): Use HOST_SIZE_T_PRINT_HEX_PURE instead of
"%lx" and cast corresponding argument to fmt_size_t.
(parser_set_numeric): Use HOST_SIZE_T_PRINT_DEC instead of "%ld"
and cast corresponding argument to fmt_size_t.
(psa_new_var_decl): Use HOST_SIZE_T_PRINT_DEC instead of "%ld"
and cast corresponding argument to fmt_size_t.
(parser_symbol_add): Use HOST_SIZE_T_PRINT_DEC instead of "%zd"
or HOST_SIZE_T_PRINT_HEX_PURE instead of "%lx" and cast corresponding
argument to fmt_size_t.
* cdf-copy.cc: Include "config.h" first.
* scan_ante.h (trim_location): Use HOST_SIZE_T_PRINT_UNSIGNED instead
of "%zu" or "%d" and cast corresponding argument to fmt_size_t.
* structs.cc (create_cblc_field_t): Use ULONGLONG instead of SIZE
for "attr".
* cbldiag.h (dbgmsg): Add ATTRIBUTE_PRINTF_1.
* gcobolspec.cc (lang_specific_driver): Use HOST_SIZE_T_PRINT_DEC
instead of "%ld" and cast corresponding argument to fmt_size_t.
* parse_ante.h (literal_of): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(evaluate_elem_t::dump): Likewise.
(arith_t::another_pair): Likewise.
(current_t::end_program): Likewise.
(file_add): Likewise.
(implicit_paragraph): Likewise.
(implicit_section): Likewise.
(data_division_ready): Use HOST_SIZE_T_PRINT_DEC instead of "%d"
and cast corresponding argument to fmt_size_t.
* symbols.h (struct cbl_field_t): Change attr member type from size_t
to uint64_t.
(cbl_field_t::set_attr): Change return type from size_t to uint64_t.
(cbl_field_t::clear_attr): Likewise.
(function_descr_t::init): Use HOST_SIZE_T_PRINT_UNSIGNED instead of
"%zu" or GCC_PRISZ instead of "z" or HOST_SIZE_T_PRINT_DEC instead
of "%zd" and cast corresponding argument to fmt_size_t.
(cbl_perform_tgt_t::dump): Likewise.
(numeric_group_attrs): Change return type from size_t to uint64_t.
--- libgcobol/valconv.cc.jj 2025-04-14 07:26:46.744879521 +0200
+++ libgcobol/valconv.cc 2025-05-02 12:16:43.200929871 +0200
@@ -67,7 +67,7 @@ __gg__realloc_if_necessary(char **dest,
new_size |= new_size>>4;
new_size |= new_size>>8;
new_size |= new_size>>16;
- new_size |= new_size>>32;
+ new_size |= (new_size>>16)>>16;
*dest_size = new_size + 1;
*dest = (char *)realloc(*dest, *dest_size);
}
--- libgcobol/common-defs.h.jj 2025-04-10 10:02:38.979131558 +0200
+++ libgcobol/common-defs.h 2025-05-02 12:16:43.205929804 +0200
@@ -147,7 +147,7 @@ enum cbl_field_type_t {
* A field is padded (in the unjustified direction) either with 0 or SPC.
* (But maybe the fill character should just be an explicit character.)
*/
-enum cbl_field_attr_t : size_t {
+enum cbl_field_attr_t : uint64_t {
none_e = 0x0000000000,
figconst_1_e = 0x0000000001, // This needs to be 1 - don't change the
position
figconst_2_e = 0x0000000002, // This needs to be 2
--- libgcobol/gcobolio.h.jj 2025-04-08 14:10:01.736300649 +0200
+++ libgcobol/gcobolio.h 2025-05-02 12:16:43.224929551 +0200
@@ -55,7 +55,7 @@ typedef struct cblc_field_t
struct cblc_field_t *parent;// This field's immediate parent field
size_t occurs_lower; // non-zero for a table
size_t occurs_upper; // non-zero for a table
- size_t attr; // See cbl_field_attr_t
+ unsigned long long attr; // See cbl_field_attr_t
signed char type; // A one-byte copy of cbl_field_type_t
signed char level; // This variable's level in the naming
heirarchy
signed char digits; // Digits specified in PIC string; e.g. 5 for
99v999
--- gcc/cobol/util.cc.jj 2025-04-14 07:26:46.294886066 +0200
+++ gcc/cobol/util.cc 2025-05-02 12:51:42.858972956 +0200
@@ -324,8 +324,9 @@ is_numeric_edited( const char picture[]
break;
default:
numed_message = xasprintf("invalid PICTURE character "
- "'%c' at offset %zu in '%s'",
- *p, p - picture, picture);
+ "'%c' at offset " HOST_SIZE_T_PRINT_UNSIGNED
+ " in '%s'",
+ *p, (fmt_size_t)(p - picture), picture);
break;
}
@@ -370,10 +371,12 @@ normalize_picture( char picture[] )
assert(pmatch[2].rm_so == pmatch[1].rm_eo + 1); // character paren
number
p = picture + pmatch[2].rm_so;
len = 0;
- if( 1 != sscanf(p, "%zu", &len) ) {
+ fmt_size_t lenf = 0;
+ if( 1 != sscanf(p, "%" GCC_PRISZ "u", &lenf) ) {
dbgmsg("%s:%d: no number found in '%s'", __func__, __LINE__, p);
goto irregular;
}
+ len = lenf;
if( len == 0 ) {
dbgmsg("%s:%d: ZERO length found in '%s'", __func__, __LINE__, p);
goto irregular;
@@ -985,7 +988,8 @@ cbl_refer_t::subscripts_set( const std::
const char *
cbl_refer_t::str() const {
static char subscripts[64];
- sprintf(subscripts, "(%u of %zu dimensions)", nsubscript, dimensions(field));
+ sprintf(subscripts, "(%u of " HOST_SIZE_T_PRINT_UNSIGNED " dimensions)",
+ nsubscript, (fmt_size_t)dimensions(field));
char *output = xasprintf("%s %s %s",
field? field_str(field) : "(none)",
0 < dimensions(field)? subscripts : "",
@@ -1031,10 +1035,10 @@ struct move_corresponding_field {
tgt.field = cbl_field_of(symbol_at(elem.second));
if( yydebug ) {
- dbgmsg("move_corresponding:%d: SRC: %3zu %s", __LINE__,
- elem.first, src.str());
- dbgmsg("move_corresponding:%d: to %3zu %s", __LINE__,
- elem.second, tgt.str());
+ dbgmsg("move_corresponding:%d: SRC: %3" GCC_PRISZ "u %s", __LINE__,
+ (fmt_size_t)elem.first, src.str());
+ dbgmsg("move_corresponding:%d: to %3" GCC_PRISZ "u %s", __LINE__,
+ (fmt_size_t)elem.second, tgt.str());
}
parser_move(tgt, src);
@@ -1138,8 +1142,9 @@ valid_move( const struct cbl_field_t *tg
if( yydebug && ! retval ) {
auto bad = std::find_if( p, pend,
[]( char ch ) { return ! ISDIGIT(ch); } );
- dbgmsg("%s:%d: offending character '%c' at position %zu",
- __func__, __LINE__, *bad, bad - p);
+ dbgmsg("%s:%d: offending character '%c' at position "
+ HOST_SIZE_T_PRINT_UNSIGNED,
+ __func__, __LINE__, *bad, (fmt_size_t)(bad - p));
}
}
break;
@@ -1498,9 +1503,10 @@ ambiguous_reference( size_t program ) {
is_unique(program, proc.first) );
if( proc.second.end() != ambiguous ) {
if( yydebug ) {
- dbgmsg("%s: %s of '%s' has %zu potential matches", __func__,
+ dbgmsg("%s: %s of '%s' has " HOST_SIZE_T_PRINT_UNSIGNED
+ "potential matches", __func__,
ambiguous->paragraph(), ambiguous->section(),
- procedures.count(*ambiguous));
+ (fmt_size_t)procedures.count(*ambiguous));
}
return new procref_t(*ambiguous);
}
@@ -1543,9 +1549,9 @@ parent_names( const symbol_elem_t *elem,
if( is_filler(cbl_field_of(elem)) ) return;
- // dbgmsg("%s: asked about %s of %s (%zu away)", __func__,
+ // dbgmsg("%s: asked about %s of %s (" HOST_SIZE_T_PRINT_UNSIGNED " away)",
__func__,
// cbl_field_of(elem)->name,
- // cbl_field_of(group)->name, elem - group);
+ // cbl_field_of(group)->name, (fmt_size_t)(elem - group));
for( const symbol_elem_t *e=elem; e && group < e; e = symbol_parent(e) ) {
names.push_front( cbl_field_of(e)->name );
@@ -1564,9 +1570,11 @@ public:
symbol_elem_t *rgroup, type_t type )
: lgroup(lgroup), rgroup(rgroup), type(type)
{
- dbgmsg( "%s:%d: for #%zu %s and #%zu %s on line %d", __func__, __LINE__,
- symbol_index(lgroup), cbl_field_of(lgroup)->name,
- symbol_index(rgroup), cbl_field_of(rgroup)->name, yylineno );
+ dbgmsg( "%s:%d: for #" HOST_SIZE_T_PRINT_UNSIGNED
+ " %s and #" HOST_SIZE_T_PRINT_UNSIGNED " %s on line %d",
+ __func__, __LINE__,
+ (fmt_size_t)symbol_index(lgroup), cbl_field_of(lgroup)->name,
+ (fmt_size_t)symbol_index(rgroup), cbl_field_of(rgroup)->name,
yylineno );
}
static bool
@@ -1643,8 +1651,9 @@ corresponding_fields( cbl_field_t *lhs,
lhsg.a = symbols_begin(field_index(lhs));
lhsg.z = std::find_if( lhsg.a, symbols_end(), next_group(lhsg.a) );
- dbgmsg("%s:%d: examining %zu symbols after %s", __func__, __LINE__,
- lhsg.z - lhsg.a, lhs->name);
+ dbgmsg("%s:%d: examining " HOST_SIZE_T_PRINT_UNSIGNED " symbols after %s",
+ __func__, __LINE__,
+ (fmt_size_t)(lhsg.z - lhsg.a), lhs->name);
find_corresponding finder( symbol_at(field_index(lhs)),
symbol_at(field_index(rhs)), type );
@@ -1652,8 +1661,9 @@ corresponding_fields( cbl_field_t *lhs,
output.erase(0);
- dbgmsg( "%s:%d: %s and %s have %zu corresponding fields",
- __func__, __LINE__, lhs->name, rhs->name, output.size() );
+ dbgmsg( "%s:%d: %s and %s have " HOST_SIZE_T_PRINT_UNSIGNED
+ " corresponding fields",
+ __func__, __LINE__, lhs->name, rhs->name, (fmt_size_t)output.size()
);
return output;
}
@@ -1772,7 +1782,8 @@ class unique_stack : public std::stack<i
"----- ---- --------"
"----------------------------------------");
for( const auto& v : c ) {
- dbgmsg( " %4zu %4d %s", c.size() - --n, v.lineno, no_wd(wd, v.name)
);
+ dbgmsg( " %4" GCC_PRISZ "u %4d %s",
+ (fmt_size_t)(c.size() - --n), v.lineno, no_wd(wd, v.name) );
}
} else {
dbgmsg("unable to get current working directory: %m");
@@ -1810,7 +1821,8 @@ bool cobol_filename( const char *name, i
auto p = old_filenames.find(name);
if( p == old_filenames.end() ) {
for( auto& elem : old_filenames ) {
- dbgmsg("%6zu %-30s", elem.second, elem.first.c_str());
+ dbgmsg("%6" GCC_PRISZ "u %-30s",
+ (fmt_size_t)elem.second, elem.first.c_str());
}
cbl_errx( "logic error: missing inode for %s", name);
}
--- gcc/cobol/lexio.cc.jj 2025-04-12 13:10:31.631523149 +0200
+++ gcc/cobol/lexio.cc 2025-05-02 12:16:43.255929137 +0200
@@ -28,6 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "config.h"
#include <ext/stdio_filebuf.h>
#include "cobol-system.h"
#include "cbldiag.h"
@@ -260,9 +261,10 @@ recognize_replacements( filespan_t mfile
found = span_t( cm[1].first, cm[1].second );
if( yy_flex_debug ) {
size_t n = count_newlines(mfile.data, found.p);
- dbgmsg("%s:%d first '%.*s' is on line %zu (offset %zu)", __func__,
__LINE__,
+ dbgmsg("%s:%d first '%.*s' is on line " HOST_SIZE_T_PRINT_UNSIGNED
+ " (offset " HOST_SIZE_T_PRINT_UNSIGNED ")", __func__,
__LINE__,
directive.before.size(), directive.before.p,
- ++n, found.p - mfile.data);
+ (fmt_size_t)++n, (fmt_size_t)(found.p - mfile.data));
}
} else {
dbgmsg("%s:%d not found: '%s' in \n'%.*s'", __func__, __LINE__,
@@ -290,8 +292,10 @@ recognize_replacements( filespan_t mfile
if( yy_flex_debug ) {
size_t n = std::count((const char *)mfile.data, recognized.before.p,
'\n');
- dbgmsg( "%s:%d: line %zu @ %zu: '%s'\n/%.*s/%.*s/", __func__, __LINE__,
- ++n, next.found.p - mfile.data,
+ dbgmsg( "%s:%d: line " HOST_SIZE_T_PRINT_UNSIGNED
+ " @ " HOST_SIZE_T_PRINT_UNSIGNED ": '%s'\n/%.*s/%.*s/",
+ __func__, __LINE__,
+ (fmt_size_t)++n, (fmt_size_t)(next.found.p - mfile.data),
next.directive.before.p,
int(recognized.before.size()), recognized.before.p,
int(recognized.after.size()), recognized.after.p );
@@ -308,9 +312,10 @@ recognize_replacements( filespan_t mfile
next.found = span_t( cm[1].first, cm[1].second );
size_t n = std::count((const char *)mfile.data, next.found.p, '\n');
if( false )
- dbgmsg("%s:%d next '%.*s' will be on line %zu (offset %zu)", __func__,
__LINE__,
+ dbgmsg("%s:%d next '%.*s' will be on line " HOST_SIZE_T_PRINT_UNSIGNED
+ " (offset " HOST_SIZE_T_PRINT_UNSIGNED ")", __func__, __LINE__,
next.directive.before.size(), next.directive.before.p,
- ++n, next.found.p - mfile.data);
+ (fmt_size_t)++n, (fmt_size_t)(next.found.p - mfile.data));
}
pnext = std::min_element(futures.begin(), futures.end());
}
@@ -344,8 +349,10 @@ check_source_format_directive( filespan_
break;
}
mfile.cur = const_cast<char*>(cm[0].second);
- dbgmsg( "%s:%d: %s format set, on line %zu", __func__, __LINE__,
- indicator.column == 7? "FIXED" : "FREE", mfile.lineno() );
+ dbgmsg( "%s:%d: %s format set, on line " HOST_SIZE_T_PRINT_UNSIGNED,
+ __func__, __LINE__,
+ indicator.column == 7? "FIXED" : "FREE",
+ (fmt_size_t)mfile.lineno() );
erase_line(const_cast<char*>(cm[0].first),
const_cast<char*>(cm[0].second));
}
@@ -724,7 +731,7 @@ parse_replacing_pair( const char *stmt,
// This eliminated a compiler warning about "format-overflow"
yywarn("CDF syntax error");
}
- pair.stmt = span_t(0UL, stmt);
+ pair.stmt = span_t(size_t(0), stmt);
pair.replace = replace_t();
}
return pair;
@@ -764,9 +771,9 @@ parse_replace_pairs( const char *stmt, c
// Report findings.
if( false && yy_flex_debug ) {
for( size_t i=0; i < cm.size(); i++ ) {
- dbgmsg("%s: %s %zu: '%.*s'", __func__,
+ dbgmsg("%s: %s " HOST_SIZE_T_PRINT_UNSIGNED ": '%.*s'", __func__,
cm[i].matched? "Pair" : "pair",
- i,
+ (fmt_size_t)i,
cm[i].matched? int(cm[i].length()) : 0,
cm[i].matched? cm[i].first : "");
}
@@ -825,9 +832,10 @@ parse_replace_pairs( const char *stmt, c
}
if( yy_flex_debug ) {
- dbgmsg( "%s:%d: %s: %zu pairs parsed from '%.*s'", __func__, __LINE__,
- parsed.done()? "done" : "not done",
- pairs.size(), parsed.stmt.size(), parsed.stmt.p );
+ dbgmsg( "%s:%d: %s: " HOST_SIZE_T_PRINT_UNSIGNED " pairs parsed from
'%.*s'",
+ __func__, __LINE__,
+ parsed.done() ? "done" : "not done",
+ (fmt_size_t)pairs.size(), parsed.stmt.size(), parsed.stmt.p );
int i = 0;
for( const auto& replace : pairs ) {
dbgmsg("%s:%d:%4d: '%s' => '%s'", __func__, __LINE__,
@@ -909,9 +917,10 @@ parse_copy_directive( filespan_t& mfile
if( yy_flex_debug ) {
size_t nnl = 1 + count_newlines(mfile.data, copy_stmt.p);
size_t nst = 1 + count_newlines(copy_stmt.p, copy_stmt.pend);
- dbgmsg("%s:%d: line %zu: COPY directive is %zu lines '%.*s'",
+ dbgmsg("%s:%d: line " HOST_SIZE_T_PRINT_UNSIGNED
+ ": COPY directive is " HOST_SIZE_T_PRINT_UNSIGNED " lines
'%.*s'",
__func__, __LINE__,
- nnl, nst, copy_stmt.size(), copy_stmt.p);
+ (fmt_size_t)nnl, (fmt_size_t)nst, copy_stmt.size(),
copy_stmt.p);
}
}
}
@@ -924,7 +933,8 @@ parse_copy_directive( filespan_t& mfile
outcome.partial_line = span_t(mfile.cur, copy_stmt.p);
if( yy_flex_debug ) {
- dbgmsg("%zu expressions", std::count(pattern, pattern + sizeof(pattern),
'('));
+ dbgmsg(HOST_SIZE_T_PRINT_UNSIGNED " expressions",
+ (fmt_size_t)std::count(pattern, pattern + sizeof(pattern), '('));
int i = 0;
for( const auto& m : cm ) {
if( m.matched )
@@ -1008,8 +1018,9 @@ parse_replace_last_off( filespan_t& mfil
}
}
- dbgmsg( "%s:%d: line %zu: parsed '%.*s', ", __func__, __LINE__,
- mfile.lineno(), int(cm[0].length()), cm[0].first );
+ dbgmsg( "%s:%d: line " HOST_SIZE_T_PRINT_UNSIGNED ": parsed '%.*s', ",
+ __func__, __LINE__,
+ (fmt_size_t)mfile.lineno(), int(cm[0].length()), cm[0].first );
// Remove statement from input
erase_line(const_cast<char*>(cm[0].first),
@@ -1041,20 +1052,23 @@ parse_replace_text( filespan_t& mfile )
gcc_assert(mfile.line_length() > 2);
if( pend[-1] == '\n' ) pend -= 2;
auto len = int(pend - mfile.cur);
- dbgmsg("%s:%d: line %zu: parsing '%.*s", __func__, __LINE__,
- current_lineno, len, mfile.cur);
+ dbgmsg("%s:%d: line " HOST_SIZE_T_PRINT_UNSIGNED ": parsing '%.*s",
+ __func__, __LINE__,
+ (fmt_size_t)current_lineno, len, mfile.cur);
}
if( ! regex_search(mfile.ccur(), (const char *)mfile.eodata, cm, re) ) {
- dbgmsg( "%s:%d: line %zu: not a REPLACE statement:\n'%.*s'",
- __func__, __LINE__, current_lineno,
+ dbgmsg( "%s:%d: line " HOST_SIZE_T_PRINT_UNSIGNED
+ ": not a REPLACE statement:\n'%.*s'",
+ __func__, __LINE__, (fmt_size_t)current_lineno,
int(mfile.line_length()), mfile.cur );
return span_t();
}
// Report findings.
if( yy_flex_debug ) {
- dbgmsg("%zu expressions", std::count(pattern, pattern + sizeof(pattern),
'('));
+ dbgmsg(HOST_SIZE_T_PRINT_UNSIGNED " expressions",
+ (fmt_size_t)std::count(pattern, pattern + sizeof(pattern), '('));
int i = 0;
for( const auto& m : cm ) {
if( m.matched )
@@ -1083,8 +1097,10 @@ parse_replace_text( filespan_t& mfile )
replace_directives.push( replacements );
if( yy_flex_debug ) {
- dbgmsg( "%s:%d: line %zu: %zu pairs parsed from '%.*s'", __func__,
__LINE__,
- current_lineno, replacements.size(), int(replace_stmt.size()),
replace_stmt.p );
+ dbgmsg( "%s:%d: line " HOST_SIZE_T_PRINT_UNSIGNED ": "
HOST_SIZE_T_PRINT_UNSIGNED
+ " pairs parsed from '%.*s'", __func__, __LINE__,
+ (fmt_size_t)current_lineno, (fmt_size_t)replacements.size(),
+ int(replace_stmt.size()), replace_stmt.p );
for( const auto& replace : replacements ) {
int i = 0;
dbgmsg("%s:%d:%4d: '%s' => '%s'", __func__, __LINE__,
@@ -1164,8 +1180,9 @@ bytespan_t::append( const char *input, c
#if LEXIO
auto nq = std::count_if(data, eodata, isquote);
dbgmsg("%s:%3d: input ------ '%.*s'", __func__, __LINE__, int(eoinput -
input), input);
- dbgmsg("%s:%3d: precondition '%.*s' (%zu: %s)", __func__, __LINE__,
- int(size()), data, nq, in_string()? "in string" : "not in string");
+ dbgmsg("%s:%3d: precondition '%.*s' (" HOST_SIZE_T_PRINT_UNSIGNED ": %s)",
+ __func__, __LINE__,
+ int(size()), data, (fmt_size_t)nq, in_string()? "in string" : "not in
string");
#endif
if( !in_string() ) { // Remove trailing space unless it's part of a literal.
while(data < eodata && ISSPACE(eodata[-1])) eodata--;
@@ -1563,8 +1580,8 @@ cdftext::map_file( int fd ) {
cbl_err( "%s: could not prepare map file from FIFO %d",
__func__, input);
}
- if( false ) dbgmsg("%s: copied %ld bytes from FIFO",
- __func__, nout);
+ if( false ) dbgmsg("%s: copied " HOST_SIZE_T_PRINT_DEC " bytes from
FIFO",
+ __func__, (fmt_size_t)nout);
}
}
} while( S_ISFIFO(sb.st_mode) );
@@ -1774,8 +1791,8 @@ cdftext::process_file( filespan_t mfile,
std::copy_if(copied.erased_lines.p, copied.erased_lines.pend, ofs,
[]( char ch ) { return ch == '\n'; } );
struct { int in, out; filespan_t mfile; } copy;
- dbgmsg("%s:%d: line %zu, opening %s on fd %d", __func__, __LINE__,
- mfile.lineno(),
+ dbgmsg("%s:%d: line " HOST_SIZE_T_PRINT_UNSIGNED ", opening %s on fd %d",
+ __func__, __LINE__,mfile.lineno(),
copybook.source(), copybook.current()->fd);
copy.in = copybook.current()->fd;
copy.mfile = free_form_reference_format( copy.in );
--- gcc/cobol/symfind.cc.jj 2025-04-12 13:10:31.705522127 +0200
+++ gcc/cobol/symfind.cc 2025-05-02 12:51:05.248464874 +0200
@@ -147,13 +147,14 @@ dump_symbol_map2( const field_key_t& key
for( auto candidate : candidates ) {
char *tmp = fields;
- fields = xasprintf("%s%s %3zu", tmp? tmp : "", sep, candidate);
+ fields = xasprintf("%s%s %3" GCC_PRISZ "u",
+ tmp? tmp : "", sep, (fmt_size_t)candidate);
sep[0] = ',';
free(tmp);
}
- dbgmsg( "%s:%d: %3zu %s {%s}", __func__, __LINE__,
- key.program, key.name, fields );
+ dbgmsg( "%s:%d: %3" GCC_PRISZ "u %s {%s}", __func__, __LINE__,
+ (fmt_size_t)key.program, key.name, fields );
free(fields);
}
@@ -179,7 +180,8 @@ dump_symbol_map_value( const char name[]
for( ; p != value.second.end(); p++ ) {
char *tmp = ancestry;
- ancestry = xasprintf("%s%s %3zu", tmp? tmp : "", sep, *p);
+ ancestry = xasprintf("%s%s %3" GCC_PRISZ "u",
+ tmp? tmp : "", sep, (fmt_size_t)*p);
sep[0] = ',';
free(tmp);
}
@@ -256,8 +258,11 @@ build_symbol_map() {
symbol_map.erase(sym_name_t(""));
if( yydebug ) {
- dbgmsg( "%s:%d: %zu of %zu symbols inserted into %zu in symbol_map",
- __func__, __LINE__, nsym, end, symbol_map.size() );
+ dbgmsg( "%s:%d: " HOST_SIZE_T_PRINT_UNSIGNED " of "
+ HOST_SIZE_T_PRINT_UNSIGNED " symbols inserted into "
+ HOST_SIZE_T_PRINT_UNSIGNED " in symbol_map",
+ __func__, __LINE__, (fmt_size_t)nsym, (fmt_size_t)end,
+ (fmt_size_t)symbol_map.size() );
}
}
@@ -277,8 +282,8 @@ public:
}
protected:
void dump_key( const char tag[], const symbol_map_t::key_type& key ) const
{
- dbgmsg( "symbol_map key: %s { %3zu %3zu %s }",
- tag, key.program, key.parent, key.name );
+ dbgmsg( "symbol_map key: %s { %3" GCC_PRISZ "u %3" GCC_PRISZ "u %s }",
+ tag, (fmt_size_t)key.program, (fmt_size_t)key.parent, key.name );
}
};
@@ -459,14 +464,16 @@ symbol_match2( size_t program,
sep = "";
for( auto field : fields ) {
char *partial = fieldstr;
- int asret = asprintf(&fieldstr, "%s%s%zu", partial? partial : "", sep,
field);
+ int asret = asprintf(&fieldstr, "%s%s" HOST_SIZE_T_PRINT_UNSIGNED,
+ partial? partial : "", sep, (fmt_size_t)field);
assert(asret);
sep = ", ";
assert(fieldstr);
free(partial);
}
- dbgmsg("%s: '%s' matches %zu fields: {%s}", __func__, ancestry,
fields.size(), fieldstr);
+ dbgmsg("%s: '%s' matches " HOST_SIZE_T_PRINT_UNSIGNED " fields: {%s}",
+ __func__, ancestry, (fmt_size_t)fields.size(), fieldstr);
free(fieldstr);
}
free(ancestry);
@@ -537,8 +544,8 @@ symbol_find( size_t program, std::list<c
return std::pair<symbol_elem_t *, bool>(NULL, false);
}
if( yydebug ) {
- dbgmsg( "%s:%d: '%s' has %zu possible matches",
- __func__, __LINE__, names.back(), items.size() );
+ dbgmsg( "%s:%d: '%s' has " HOST_SIZE_T_PRINT_UNSIGNED " possible
matches",
+ __func__, __LINE__, names.back(), (fmt_size_t)items.size() );
std::for_each( items.begin(), items.end(), dump_symbol_map_value1 );
}
}
@@ -577,8 +584,8 @@ symbol_find_of( size_t program, std::lis
}
if( yydebug ) {
- dbgmsg( "%s:%d: '%s' has %zu possible matches",
- __func__, __LINE__, names.back(), input.size() );
+ dbgmsg( "%s:%d: '%s' has " HOST_SIZE_T_PRINT_UNSIGNED " possible matches",
+ __func__, __LINE__, names.back(), (fmt_size_t)input.size() );
std::for_each( input.begin(), input.end(), dump_symbol_map_value1 );
}
--- gcc/cobol/cdf.y.jj 2025-04-12 13:10:31.591523702 +0200
+++ gcc/cobol/cdf.y 2025-05-02 12:16:43.268928963 +0200
@@ -245,8 +245,8 @@ apply_cdf_turn( exception_turns_t& turns
%printer { fprintf(yyo, "%s '%s'",
keyword_str($$.token),
$$.string? $$.string : "<nil>" ); } <cdfarg>
-%printer { fprintf(yyo, "%ld '%s'",
- $$.number, $$.string? $$.string : "" ); } <cdfval>
+%printer { fprintf(yyo, HOST_SIZE_T_PRINT_DEC " '%s'",
+ (fmt_size_t)$$.number, $$.string? $$.string : "" ); }
<cdfval>
%type <string> NAME NUMSTR LITERAL PSEUDOTEXT
%type <string> LSUB RSUB SUBSCRIPT
@@ -828,7 +828,8 @@ defined_cmd( const char arg[] )
if( yydebug ) {
if( cdf_name->second.is_numeric() ) {
- dbgmsg("%s: added -D %s = %ld", __func__, name,
cdf_name->second.as_number());
+ dbgmsg("%s: added -D %s = " HOST_SIZE_T_PRINT_DEC,
+ __func__, name, (fmt_size_t)cdf_name->second.as_number());
} else {
dbgmsg("%s: added -D %s = \"%s\"", __func__, name,
cdf_name->second.string);
}
--- gcc/cobol/symbols.cc.jj 2025-04-12 13:10:31.705522127 +0200
+++ gcc/cobol/symbols.cc 2025-05-02 12:16:43.285928736 +0200
@@ -28,6 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "config.h"
#include <fstream> // Before cobol-system because it uses poisoned functions
#include "cobol-system.h"
@@ -814,24 +815,24 @@ cbl_field_t::size() const {
return field_size(this);
}
-size_t
+uint64_t
cbl_field_t::set_attr( cbl_field_attr_t attr ) {
if( attr == signable_e ) {
if( ! has_attr(attr) && this->var_decl_node != NULL ) {
parser_field_attr_set(this, attr);
}
}
- return this->attr |= size_t(attr);
+ return this->attr |= uint64_t(attr);
}
-size_t
+uint64_t
cbl_field_t::clear_attr( cbl_field_attr_t attr ) {
if( attr == signable_e ) {
if( this->var_decl_node != nullptr && has_attr(attr) ) {
parser_field_attr_set(this, attr, false);
}
}
- return this->attr &= ~size_t(attr);
+ return this->attr &= ~uint64_t(attr);
}
static uint32_t
@@ -1001,8 +1002,8 @@ symbol_field_capacity( const cbl_field_t
size_t size = std::accumulate( symbol_at(bog), symbol_at_impl(eog),
0, sym_field_size::capacity );
- if(true) dbgmsg("%s: %02u %s.data.capacity was computed as %zu", __func__,
- field->level, field->name, size);
+ if(true) dbgmsg("%s: %02u %s.data.capacity was computed as "
HOST_SIZE_T_PRINT_UNSIGNED,
+ __func__, field->level, field->name, (fmt_size_t)size);
return size;
}
@@ -1016,14 +1017,15 @@ has_odo( const symbol_elem_t& e ) {
struct cbl_field_t *
symbol_find_odo_debug( cbl_field_t * field ) {
size_t bog = field_index(field), eog = end_of_group(bog);
- dbgmsg("%s: %s is #%zu - #%zu of %zu, ends at %s", __func__,
- field->name, bog, eog, symbols.nelem,
+ dbgmsg("%s: %s is #" HOST_SIZE_T_PRINT_UNSIGNED " - #"
HOST_SIZE_T_PRINT_UNSIGNED
+ " of " HOST_SIZE_T_PRINT_UNSIGNED ", ends at %s", __func__,
+ field->name, (fmt_size_t)bog, (fmt_size_t)eog,
(fmt_size_t)symbols.nelem,
eog == symbols.nelem? "[end]" : cbl_field_of(symbol_at(eog))->name );
auto e = std::find_if( symbol_at(bog), symbol_at_impl(eog, true), has_odo );
if( e != symbol_at_impl(eog, true) ) {
- dbgmsg("%s: %s has ODO at #%zu (return '%s')", __func__,
- field->name, symbol_index(e),
+ dbgmsg("%s: %s has ODO at #" HOST_SIZE_T_PRINT_UNSIGNED " (return '%s')",
__func__,
+ field->name, (fmt_size_t)symbol_index(e),
cbl_field_of(e)->name );
}
return e == symbol_at_impl(eog, true)? NULL : cbl_field_of(e);
@@ -1047,8 +1049,8 @@ symbols_dump( size_t first, bool header
if( !yydebug ) return 0;
if( header ) {
- fprintf(stderr, "Symbol Table has %zu elements\n",
- symbols_end() - symbols_begin());
+ fprintf(stderr, "Symbol Table has " HOST_SIZE_T_PRINT_UNSIGNED "
elements\n",
+ (fmt_size_t)(symbols_end() - symbols_begin()));
}
for( struct symbol_elem_t *e = symbols_begin(first); e < symbols_end(); e++
) {
@@ -1056,25 +1058,26 @@ symbols_dump( size_t first, bool header
switch(e->type) {
case SymFilename:
- s = xasprintf("%4zu %-18s %s", e->program,
+ s = xasprintf("%4" GCC_PRISZ "u %-18s %s", (fmt_size_t)e->program,
"Filename", e->elem.filename);
break;
case SymDataSection:
- s = xasprintf("%4zu %-18s line %d", e->program,
+ s = xasprintf("%4" GCC_PRISZ "u %-18s line %d", (fmt_size_t)e->program,
cbl_section_of(e)->name(), cbl_section_of(e)->line);
break;
case SymFunction:
- s = xasprintf("%4zu %-15s %s", e->program,
+ s = xasprintf("%4" GCC_PRISZ "u %-15s %s", (fmt_size_t)e->program,
"Function", e->elem.function.name);
break;
case SymField: {
auto field = cbl_field_of(e);
char *odo_str = NULL;
if( field->occurs.depending_on != 0 ) {
- odo_str = xasprintf("odo %zu", field->occurs.depending_on );
+ odo_str = xasprintf("odo " HOST_SIZE_T_PRINT_UNSIGNED,
+ (fmt_size_t)field->occurs.depending_on );
}
ninvalid += cbl_field_of(e)->type == FldInvalid? 1 : 0;
- s = xasprintf("%4zu %-18s %s (%s)", e->program,
+ s = xasprintf("%4" GCC_PRISZ "u %-18s %s (%s)", (fmt_size_t)e->program,
cbl_field_type_str(cbl_field_of(e)->type) + 3,
field_str(cbl_field_of(e)),
odo_str? odo_str :
@@ -1082,7 +1085,7 @@ symbols_dump( size_t first, bool header
}
break;
case SymLabel:
- s = xasprintf("%4zu %-18s %s", e->program,
+ s = xasprintf("%4" GCC_PRISZ "u %-18s %s", (fmt_size_t)e->program,
"Labe1l", e->elem.label.str());
if( LblProgram == cbl_label_of(e)->type ) {
const auto& L = *cbl_label_of(e);
@@ -1094,31 +1097,35 @@ symbols_dump( size_t first, bool header
}
break;
case SymSpecial:
- s = xasprintf("%4zu %-18s id=%2d, %s", e->program,
+ s = xasprintf("%4" GCC_PRISZ "u %-18s id=%2d, %s",
(fmt_size_t)e->program,
"Special", e->elem.special.id, e->elem.special.name);
break;
case SymAlphabet:
- s = xasprintf("%4zu %-18s encoding=%2d, '%s'", e->program, "Alphabet",
+ s = xasprintf("%4" GCC_PRISZ "u %-18s encoding=%2d, '%s'",
+ (fmt_size_t)e->program, "Alphabet",
int(e->elem.alphabet.encoding), e->elem.alphabet.name);
break;
case SymFile:
- s = xasprintf("%4zu %-18s %-20s", e->program,
+ s = xasprintf("%4" GCC_PRISZ "u %-18s %-20s", (fmt_size_t)e->program,
"File", e->elem.file.name);
{
char same_as[26] = "";
if( cbl_file_of(e)->same_record_as > 0 ) {
- sprintf(same_as, "s%3zu", cbl_file_of(e)->same_record_as);
+ sprintf(same_as, "s%3" GCC_PRISZ "u",
+ (fmt_size_t)cbl_file_of(e)->same_record_as);
}
const char *type = file_org_str(e->elem.file.org);
char *part = s;
- s = xasprintf("%s %-4s %s %s %s{%zu-%zu} status=#%zu",
+ s = xasprintf("%s %-4s %s %s %s{" HOST_SIZE_T_PRINT_UNSIGNED "-"
+ HOST_SIZE_T_PRINT_UNSIGNED "} status=#"
+ HOST_SIZE_T_PRINT_UNSIGNED,
part, same_as, type,
e->elem.file.keys_str(),
cbl_file_of(e)->varies()? "varies " : "",
- cbl_file_of(e)->varying_size.min,
- cbl_file_of(e)->varying_size.max,
- cbl_file_of(e)->user_status);
+ (fmt_size_t)cbl_file_of(e)->varying_size.min,
+ (fmt_size_t)cbl_file_of(e)->varying_size.max,
+ (fmt_size_t)cbl_file_of(e)->user_status);
free(part);
}
break;
@@ -1126,7 +1133,8 @@ symbols_dump( size_t first, bool header
dbgmsg("%s: cannot dump symbol type %d", __func__, e->type);
continue;
}
- fprintf(stderr, "%4zu: %s\n", e - symbols_begin(), s);
+ fprintf(stderr, "%4" GCC_PRISZ "u: %s\n",
+ (fmt_size_t)(e - symbols_begin()), s);
free(s);
}
return ninvalid;
@@ -1238,7 +1246,8 @@ static struct symbol_elem_t *
}
if(yydebug && group->type != FldGroup) {
- dbgmsg("Field #%zu '%s' is not a group", symbol_index(e), group->name);
+ dbgmsg("Field #" HOST_SIZE_T_PRINT_UNSIGNED " '%s' is not a group",
+ (fmt_size_t)symbol_index(e), group->name);
symbols_dump(symbols.first_program, true);
}
if( group->type == FldInvalid ) return e;
@@ -1493,8 +1502,8 @@ field_str( const cbl_field_t *field ) {
for( size_t i=0; i < field->occurs.nkey; i++ ) {
updown[i] = field->occurs.keys[i].ascending? 'A' : 'D';
}
- snprintf(name, sizeof(name), "%s[%zu]%s",
- field->name, field->occurs.ntimes(), updown.data());
+ snprintf(name, sizeof(name), "%s[" HOST_SIZE_T_PRINT_UNSIGNED "]%s",
+ field->name, (fmt_size_t)field->occurs.ntimes(), updown.data());
}
}
@@ -1503,7 +1512,7 @@ field_str( const cbl_field_t *field ) {
char offset[32] = "";
if( field->level > 1 ) {
- sprintf( offset, "off%3zu", field->offset );
+ sprintf( offset, "off%3" GCC_PRISZ "u", (fmt_size_t)field->offset );
}
char parredef =
@@ -1570,8 +1579,8 @@ field_str( const cbl_field_t *field ) {
};
pend += snprintf(pend, string + sizeof(string) - pend,
- "%c%3zu %-6s %c%c%c %2u{%3u,%u,%d = %s} (%s), line %d",
- parredef, field->parent, offset,
+ "%c%3" GCC_PRISZ "u %-6s %c%c%c %2u{%3u,%u,%d = %s} (%s),
line %d",
+ parredef, (fmt_size_t)field->parent, offset,
(field->attr & global_e)? 'G' : 0x20,
(field->attr & external_e)? 'E' : 0x20,
storage_type,
@@ -1796,18 +1805,19 @@ symbols_update( size_t first, bool parse
field->line, field->level_str(), field->name);
} else {
- dbgmsg("%s: error: data item %s #%zu '%s' capacity %u rejected",
+ dbgmsg("%s: error: data item %s #" HOST_SIZE_T_PRINT_UNSIGNED
+ " '%s' capacity %u rejected",
__func__,
3 + cbl_field_type_str(field->type),
- isym, field->name, field->data.capacity);
+ (fmt_size_t)isym, field->name, field->data.capacity);
}
}
return 0;
}
if(! (field->data.memsize == 0 || field_size(field) <=
field->data.memsize) ) {
- dbgmsg( "%s:%d: #%zu: invalid: %s", __func__, __LINE__,
- symbol_index(p), field_str(cbl_field_of(p)) );
+ dbgmsg( "%s:%d: #" HOST_SIZE_T_PRINT_UNSIGNED ": invalid: %s", __func__,
__LINE__,
+ (fmt_size_t)symbol_index(p), field_str(cbl_field_of(p)) );
}
assert(field->data.memsize == 0 || field_size(field) <=
field_memsize(field));
assert( !(field->data.memsize > 0 && symbol_explicitly_redefines(field)) );
@@ -1925,7 +1935,8 @@ symbol_field_forward( size_t index ) {
assert( index < symbols.nelem );
symbol_elem_t *e = symbol_at(index);
if( (e->type != SymField) ) {
- dbgmsg("%s: logic error: #%zu is %s", __func__, index,
symbol_type_str(e->type));
+ dbgmsg("%s: logic error: #" HOST_SIZE_T_PRINT_UNSIGNED " is %s",
+ __func__, (fmt_size_t)index, symbol_type_str(e->type));
}
assert(e->type == SymField);
@@ -2433,9 +2444,9 @@ symbol_alphabet_add( size_t program, str
return symbol_add(&sym);
}
-size_t
+uint64_t
numeric_group_attrs( const cbl_field_t *field ) {
- static const size_t inherit = signable_e | leading_e | separate_e |
big_endian_e;
+ static const uint64_t inherit = signable_e | leading_e | separate_e |
big_endian_e;
static_assert(sizeof(cbl_field_t::type) < sizeof(inherit), "need bigger
type");
assert(field);
if( field->type == FldNumericDisplay || field->type == FldGroup ) {
@@ -3258,10 +3269,10 @@ new_literal_add( const char initial[], u
static size_t literal_count = 1;
sprintf(field->name,
- "%s%c_%zd",
+ "%s%c_" HOST_SIZE_T_PRINT_DEC,
"_literal",
field->type == FldLiteralA ? 'a' : 'n',
- literal_count++);
+ (fmt_size_t)literal_count++);
return parser_symbol_add2(field);
}
@@ -3290,14 +3301,15 @@ new_literal( uint32_t len, const char in
void
temporaries_t::dump() const {
extern int yylineno;
- char *output = xasprintf("%4d: %zu Literals", yylineno, literals.size());
+ char *output = xasprintf("%4d: " HOST_SIZE_T_PRINT_UNSIGNED " Literals",
+ yylineno, (fmt_size_t)literals.size());
for( const auto& elem : used ) {
if( ! elem.second.empty() ) {
char *so_far = output;
- output = xasprintf("%s, %zu %s",
+ output = xasprintf("%s, " HOST_SIZE_T_PRINT_UNSIGNED " %s",
so_far,
- elem.second.size(),
+ (fmt_size_t)elem.second.size(),
3 + cbl_field_type_str(elem.first));
free(so_far);
}
@@ -3580,8 +3592,8 @@ cbl_label_t::str() const {
buf = xasprintf("%-12s %s top level [%s], line %d",
type_str() + 3, name, mangled_name, line);
} else {
- buf = xasprintf("%-12s %s OF #%zu '%s' [%s], line %d",
- type_str() + 3, name, parent,
+ buf = xasprintf("%-12s %s OF #" HOST_SIZE_T_PRINT_UNSIGNED " '%s' [%s],
line %d",
+ type_str() + 3, name, (fmt_size_t)parent,
cbl_label_of(symbol_at(parent))->name,
mangled_name, line);
}
@@ -3695,7 +3707,8 @@ symbol_label_add( size_t program, cbl_la
// Set the program's mangled name, dehyphenated and uniqified by parent
index.
if( input->type == LblProgram ) {
char *psz = cobol_name_mangler(input->name);
- input->mangled_name = xasprintf("%s.%zu", psz, input->parent);
+ input->mangled_name = xasprintf("%s." HOST_SIZE_T_PRINT_UNSIGNED,
+ psz, (fmt_size_t)input->parent);
free(psz);
}
@@ -3764,7 +3777,8 @@ symbol_program_add( size_t program, cbl_
// Set the program's mangled name, dehyphenated and uniqified by parent
index.
char *psz = cobol_name_mangler(input->name);
- elem.elem.label.mangled_name = xasprintf("%s.%zu", psz, input->parent);
+ elem.elem.label.mangled_name = xasprintf("%s." HOST_SIZE_T_PRINT_UNSIGNED,
+ psz, (fmt_size_t)input->parent);
free(psz);
e = std::find_if( symbols_begin(program), symbols_end(),
@@ -4445,8 +4459,8 @@ symbol_forward_names( size_t ifield ) {
for( auto sym = symbols_begin(ifield); sym && sym->type == SymField; ) {
const cbl_field_t *field = cbl_field_of(sym);
if( !(field->type == FldForward) ) {
- dbgmsg("%s:%d: logic error, not FldForward: #%zu %s",
- __func__, __LINE__, symbol_index(sym), field_str(field));
+ dbgmsg("%s:%d: logic error, not FldForward: #"
HOST_SIZE_T_PRINT_UNSIGNED " %s",
+ __func__, __LINE__, (fmt_size_t)symbol_index(sym),
field_str(field));
}
assert(field->type == FldForward);
@@ -4469,8 +4483,9 @@ symbol_forward_to( size_t fwd ) {
if( !elem.second ) {
const auto& field = *cbl_field_of(symbols_begin(fwd));
if( yydebug )
- dbgmsg("%s:%d: no symbol found for #%zu %s %s", __func__, __LINE__,
- fwd, cbl_field_type_str(field.type), field.name);
+ dbgmsg("%s:%d: no symbol found for #" HOST_SIZE_T_PRINT_UNSIGNED " %s
%s",
+ __func__, __LINE__,
+ (fmt_size_t)fwd, cbl_field_type_str(field.type), field.name);
return fwd;
}
@@ -4491,8 +4506,9 @@ cbl_file_key_t::deforward( size_t ifile
const auto field = cbl_field_of(symbol_at(ifield));
if( is_forward(field) && yydebug ) {
- dbgmsg("%s:%d: key %d: #%zu %s of %s is %s",
"deforward", __LINE__,
- keys[ifile]++, ifield, field->name, file->name,
+ dbgmsg("%s:%d: key %d: #" HOST_SIZE_T_PRINT_UNSIGNED "
%s of %s is %s",
+ "deforward", __LINE__,
+ keys[ifile]++, (fmt_size_t)ifield, field->name,
file->name,
cbl_field_type_str(field->type) + 3);
}
@@ -4546,7 +4562,7 @@ cbl_file_key_t::str() const {
*p++ = '[';
for( auto f = fields; f < fields + nfield; f++) {
- auto n = sprintf(p, "%s%zu", sep, *f);
+ auto n = sprintf(p, "%s" HOST_SIZE_T_PRINT_UNSIGNED, sep, (fmt_size_t)*f);
p += n;
sep = ", ";
}
--- gcc/cobol/gengen.cc.jj 2025-04-08 15:51:11.954929158 +0200
+++ gcc/cobol/gengen.cc 2025-05-02 12:16:43.304928483 +0200
@@ -393,13 +393,13 @@ show_type(tree type)
case REAL_TYPE:
sprintf(ach,
- "%3ld-bit REAL",
+ "%3" PRId64 "-bit REAL",
TREE_INT_CST_LOW(TYPE_SIZE(type)));
break;
case INTEGER_TYPE:
sprintf(ach,
- "%3ld-bit %s INT",
+ "%3" PRId64 "-bit %s INT",
TREE_INT_CST_LOW(TYPE_SIZE(type)),
(TYPE_UNSIGNED(type) ? "unsigned" : " signed"));
break;
@@ -892,7 +892,8 @@ gg_unique_in_function(const char *var_na
char *retval = (char *)xmalloc(strlen(var_name)+32);
if( (vs_scope == vs_stack || vs_scope == vs_static) )
{
- sprintf(retval, "%s.%ld", var_name, current_function->program_id_number);
+ sprintf(retval, "%s." HOST_SIZE_T_PRINT_DEC, var_name,
+ (fmt_size_t)current_function->program_id_number);
}
else
{
--- gcc/cobol/scan.l.jj 2025-04-14 07:26:46.273886371 +0200
+++ gcc/cobol/scan.l 2025-05-02 12:16:43.316928322 +0200
@@ -27,6 +27,9 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+%top{
+#include "config.h"
+}
%{
#include <fstream> // Before cobol-system because it uses poisoned functions
#include "cobol-system.h"
--- gcc/cobol/genmath.cc.jj 2025-04-08 14:08:48.651318060 +0200
+++ gcc/cobol/genmath.cc 2025-05-02 12:16:43.333928096 +0200
@@ -725,7 +725,7 @@ parser_add( size_t nC, cbl_num_result_t
SHOW_PARSE
{
SHOW_PARSE_HEADER
- fprintf(stderr, " A[%ld]:", nA);
+ fprintf(stderr, " A[" HOST_SIZE_T_PRINT_DEC "]:", (fmt_size_t)nA);
for(size_t i=0; i<nA; i++)
{
if(i > 0)
@@ -737,7 +737,7 @@ parser_add( size_t nC, cbl_num_result_t
fprintf(stderr, "%s", format==giving_e? " GIVING" : "");
- fprintf(stderr, " C[%ld]:", nC);
+ fprintf(stderr, " C[" HOST_SIZE_T_PRINT_DEC "]:", (fmt_size_t)nC);
for(size_t i=0; i<nC; i++)
{
if(i > 0)
@@ -1412,7 +1412,7 @@ parser_subtract(size_t nC, cbl_num_resul
SHOW_PARSE
{
SHOW_PARSE_HEADER
- fprintf(stderr, " A[%ld]:", nA);
+ fprintf(stderr, " A[" HOST_SIZE_T_PRINT_DEC "]:", (fmt_size_t)nA);
for(size_t i=0; i<nA; i++)
{
if(i > 0)
@@ -1422,7 +1422,7 @@ parser_subtract(size_t nC, cbl_num_resul
fprintf(stderr, "%s", A[i].field->name);
}
- fprintf(stderr, " B[%ld]:", nB);
+ fprintf(stderr, " B[" HOST_SIZE_T_PRINT_DEC "]:", (fmt_size_t)nB);
for(size_t i=0; i<nB; i++)
{
if(i > 0)
@@ -1432,7 +1432,7 @@ parser_subtract(size_t nC, cbl_num_resul
fprintf(stderr, "%s", B[i].field->name);
}
- fprintf(stderr, " C[%ld]:", nC);
+ fprintf(stderr, " C[" HOST_SIZE_T_PRINT_DEC "]:", (fmt_size_t)nC);
for(size_t i=0; i<nC; i++)
{
if(i > 0)
--- gcc/cobol/parse.y.jj 2025-04-14 07:26:46.260886560 +0200
+++ gcc/cobol/parse.y 2025-05-02 12:16:43.367927642 +0200
@@ -28,6 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
%code requires {
+ #include "config.h"
#include <fstream> // Before cobol-system because it uses poisoned functions
#include "cobol-system.h"
#include "coretypes.h"
@@ -279,6 +280,7 @@
}
%{
+#include "config.h"
#include <fstream> // Before cobol-system because it uses poisoned functions
#include "cobol-system.h"
#include "coretypes.h"
@@ -945,18 +947,20 @@
%printer { fprintf(yyo, "%s (token %d)", keyword_str($$), $$ ); } relop
%printer { fprintf(yyo, "'%s'", $$? $$ : "" ); } NAME <string>
-%printer { fprintf(yyo, "%s'%.*s'{%zu} %s", $$.prefix, int($$.len), $$.data,
$$.len,
+%printer { fprintf(yyo, "%s'%.*s'{" HOST_SIZE_T_PRINT_UNSIGNED "} %s",
+ $$.prefix, int($$.len), $$.data, (fmt_size_t)$$.len,
$$.symbol_name()); } <literal>
-%printer { fprintf(yyo, "%s (1st of %zu)",
+%printer { fprintf(yyo, "%s (1st of " HOST_SIZE_T_PRINT_UNSIGNED ")",
$$->targets.empty()? "" :
$$->targets.front().refer.field->name,
- $$->targets.size() ); } <targets>
-%printer { fprintf(yyo, "#%zu: %s",
- is_temporary($$)? 0 : field_index($$),
+ (fmt_size_t)$$->targets.size() ); } <targets>
+%printer { fprintf(yyo, "#" HOST_SIZE_T_PRINT_UNSIGNED ": %s",
+ is_temporary($$)? 0 : (fmt_size_t)field_index($$),
$$? name_of($$) : "<nil>" ); } name
-%printer { fprintf(yyo, "{%zu-%zu}", $$.min, $$.max ); } <min_max>
+%printer { fprintf(yyo, "{" HOST_SIZE_T_PRINT_UNSIGNED "-"
HOST_SIZE_T_PRINT_UNSIGNED "}",
+ (fmt_size_t)$$.min, (fmt_size_t)$$.max ); } <min_max>
%printer { fprintf(yyo, "{%s}", $$? "+/-" : "" ); } signed
-%printer { fprintf(yyo, "{%s of %zu}",
- teed_up_names().front(), teed_up_names().size() ); }
qname
+%printer { fprintf(yyo, "{%s of " HOST_SIZE_T_PRINT_UNSIGNED "}",
+ teed_up_names().front(), (fmt_size_t)
teed_up_names().size() ); } qname
%printer { fprintf(yyo, "{%d}", $$ ); } <number>
%printer { fprintf(yyo, "'%s'", $$.string ); } <numstr>
%printer { const char *s = string_of($$);
@@ -968,9 +972,9 @@
$$.low? (const char*) $$.low : "",
$$.high? (const char*) $$.high : "",
$$.also? "+" : "" ); } <colseq>
-%printer { fprintf(yyo, "{%s, %zu parameters}",
+%printer { fprintf(yyo, "{%s, " HOST_SIZE_T_PRINT_UNSIGNED " parameters}",
name_of($$.ffi_name->field), !$$.using_params? 0 :
- $$.using_params->elems.size()); } call_body
+ (fmt_size_t)$$.using_params->elems.size()); } call_body
%printer { fprintf(yyo, "%s <- %s", data_category_str($$.category),
name_of($$.replacement->field)); } init_by
@@ -3616,12 +3620,12 @@ data_descr1: level_name
// SIGN clause valid only with "S" in picture
if( $field->type == FldNumericDisplay &&
!is_signable($field) ) {
- static const size_t sign_attrs = leading_e | separate_e;
+ static const uint64_t sign_attrs = leading_e | separate_e;
static_assert(sizeof(sign_attrs) == sizeof($field->attr),
"size matters");
// remove inapplicable inherited sign attributes
- size_t group_sign = group_attr($field) & sign_attrs;
+ uint64_t group_sign = group_attr($field) & sign_attrs;
$field->attr &= ~group_sign;
if( $field->attr & sign_attrs ) {
@@ -3777,7 +3781,7 @@ data_clauses: data_clause
// If any implied TYPE bits are on in addition to
// type_clause_e, they're in conflict.
- static const size_t type_implies =
+ static const uint64_t type_implies =
// ALIGNED clause not implemented
blank_zero_clause_e | justified_clause_e | picture_clause_e
| sign_clause_e | synched_clause_e | usage_clause_e;
@@ -4278,8 +4282,9 @@ usage_clause1: usage COMPUTATIONAL[comp
is_numeric(redefined->type) && redefined->size() == 4) {
// For now, we allow POINTER to expand a 32-bit item to 64
bits.
field->data.capacity = int_size_in_bytes(ptr_type_node);
- dbgmsg("%s: expanding #%zu %s capacity %u => %u", __func__,
- field_index(redefined), redefined->name,
+ dbgmsg("%s: expanding #" HOST_SIZE_T_PRINT_UNSIGNED
+ " %s capacity %u => %u", __func__,
+ (fmt_size_t)field_index(redefined), redefined->name,
redefined->data.capacity, field->data.capacity);
redefined->embiggen();
@@ -4533,7 +4538,7 @@ sign_clause: sign_is sign_leading sig
if( $sign_leading ) {
field->attr |= leading_e;
} else {
- field->attr &= ~size_t(leading_e); // turn off in case
inherited
+ field->attr &= ~uint64_t(leading_e); // turn off in case
inherited
field->attr |= signable_e;
}
if( $sign_separate ) field->attr |= separate_e;
@@ -11399,7 +11404,7 @@ perform_t::ec_labels_t::new_label( cbl_l
{
size_t n = 1 + symbols_end() - symbols_begin();
cbl_name_t name;
- sprintf(name, "_perf_%s_%zu", role, n);
+ sprintf(name, "_perf_%s_" HOST_SIZE_T_PRINT_UNSIGNED, role, (fmt_size_t)n);
return label_add( type, name, yylineno );
}
@@ -11714,8 +11719,8 @@ struct stringify_src_t : public cbl_stri
}
static void dump( const cbl_string_src_t& src ) {
- dbgmsg( "%s:%d:, %zu inputs delimited by %s:", __func__, __LINE__,
- src.ninput,
+ dbgmsg( "%s:%d:, " HOST_SIZE_T_PRINT_UNSIGNED " inputs delimited by %s:",
+ __func__, __LINE__, (fmt_size_t)src.ninput,
src.delimited_by.field? field_str(src.delimited_by.field) : "SIZE"
);
std::for_each(src.inputs, src.inputs + src.ninput, dump_input);
}
@@ -11864,8 +11869,8 @@ lang_check_failed (const char* file, int
void ast_inspect( cbl_refer_t& input, bool backward, ast_inspect_list_t&
inspects ) {
if( yydebug ) {
- dbgmsg("%s:%d: INSPECT %zu operations on %s, line %d", __func__, __LINE__,
- inspects.size(), input.field->name, yylineno);
+ dbgmsg("%s:%d: INSPECT " HOST_SIZE_T_PRINT_UNSIGNED " operations on %s,
line %d",
+ __func__, __LINE__, (fmt_size_t)inspects.size(), input.field->name,
yylineno);
}
std::for_each(inspects.begin(), inspects.end(), dump_inspect);
auto array = inspects.as_array();
@@ -12006,6 +12011,7 @@ static REAL_VALUE_TYPE
numstr2i( const char input[], radix_t radix ) {
REAL_VALUE_TYPE output;
size_t integer = 0;
+ fmt_size_t integerf = 0;
int erc=0;
switch( radix ) {
@@ -12017,7 +12023,8 @@ numstr2i( const char input[], radix_t ra
}
break;
case hexadecimal_e:
- erc = sscanf(input, "%zx", &integer);
+ erc = sscanf(input, "%" GCC_PRISZ "x", &integerf);
+ integer = integer;
real_from_integer (&output, VOIDmode, integer, UNSIGNED);
break;
case boolean_e:
@@ -12445,9 +12452,11 @@ initialize_statement( std::list<cbl_num_
static void
dump_inspect_oper( const cbl_inspect_oper_t& op ) {
- dbgmsg("\t%s: %zu \"matches\", %zu \"replaces\"",
+ dbgmsg("\t%s: " HOST_SIZE_T_PRINT_UNSIGNED
+ " \"matches\", " HOST_SIZE_T_PRINT_UNSIGNED " \"replaces\"",
bound_str(op.bound),
- op.matches? op.n_identifier_3 : 0, op.replaces? op.n_identifier_3 : 0);
+ op.matches? (fmt_size_t)op.n_identifier_3 : 0,
+ op.replaces? (fmt_size_t)op.n_identifier_3 : 0);
if( op.matches )
std::for_each(op.matches, op.matches + op.n_identifier_3,
dump_inspect_match);
if( op.replaces )
@@ -12535,10 +12544,11 @@ cbl_field_t *
new_literal( const literal_t& lit, enum cbl_field_attr_t attr ) {
bool zstring = lit.prefix[0] == 'Z';
if( !zstring && lit.data[lit.len] != '\0' ) {
- dbgmsg("%s:%d: line %d, no NUL terminator '%-*.*s'{%zu/%zu}",
+ dbgmsg("%s:%d: line %d, no NUL terminator '%-*.*s'{"
+ HOST_SIZE_T_PRINT_UNSIGNED "/" HOST_SIZE_T_PRINT_UNSIGNED "}",
__func__, __LINE__, yylineno,
int(lit.len), int(lit.len),
- lit.data, strlen(lit.data), lit.len);
+ lit.data, (fmt_size_t)strlen(lit.data), (fmt_size_t)lit.len);
}
assert(zstring || lit.data[lit.len] == '\0');
@@ -12781,7 +12791,8 @@ literal_subscripts_valid( YYLTYPE loc, c
const char *upper_phrase = "";
if( ! oob->occurs.bounds.fixed_size() ) {
static char ub[32] = "boo";
- sprintf(ub, " to %lu", oob->occurs.bounds.upper);
+ sprintf(ub, " to " HOST_SIZE_T_PRINT_UNSIGNED,
+ (fmt_size_t)oob->occurs.bounds.upper);
upper_phrase = ub;
}
@@ -12851,7 +12862,8 @@ eval_subject_t::label( const char skel[]
cbl_label_t label = protolabel;
label.line = yylineno;
size_t n = 1 + symbols_end() - symbols_begin();
- snprintf(label.name, sizeof(label.name), "_eval_%s_%zu", skel, n);
+ snprintf(label.name, sizeof(label.name),
+ "_eval_%s_" HOST_SIZE_T_PRINT_UNSIGNED, skel, (fmt_size_t)n);
auto output = symbol_label_add( PROGRAM, &label );
return output;
}
--- gcc/cobol/genapi.cc.jj 2025-04-24 23:44:00.111196021 +0200
+++ gcc/cobol/genapi.cc 2025-05-02 12:28:18.249651309 +0200
@@ -427,7 +427,8 @@ level_88_helper(size_t parent_capacity,
nbuild += first_name_length;
}
}
- returned_size = sprintf(retval, "%zdA", nbuild);
+ returned_size = sprintf(retval, HOST_SIZE_T_PRINT_DEC "A",
+ (fmt_size_t)nbuild);
memcpy(retval + returned_size, builder, nbuild);
returned_size += nbuild;
free(first_name);
@@ -735,12 +736,14 @@ parser_call_target_convention( tree func
void
parser_call_targets_dump()
{
- dbgmsg( "call targets for #%zu", current_program_index() );
+ dbgmsg( "call targets for #" HOST_SIZE_T_PRINT_UNSIGNED,
+ (fmt_size_t)current_program_index() );
for( const auto& elem : call_targets ) {
const auto& k = elem.first;
const auto& v = elem.second;
- fprintf(stderr, "\t#%-3zu %s calls %s ",
- k.caller, cbl_label_of(symbol_at(k.caller))->name, k.called);
+ fprintf(stderr, "\t#%-3" GCC_PRISZ "u %s calls %s ",
+ (fmt_size_t)k.caller, cbl_label_of(symbol_at(k.caller))->name,
+ k.called);
char ch = '[';
for( auto func : v ) {
fprintf( stderr, "%c %s", ch, IDENTIFIER_POINTER(DECL_NAME(func.node))
);
@@ -2343,9 +2346,11 @@ combined_name(cbl_label_t *label)
{
strcat(retval, mangled_program_name);
}
- sprintf(ach, ".%ld", current_function->program_id_number);
+ sprintf(ach, "." HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)current_function->program_id_number);
strcat(retval, ach);
- sprintf(ach, ".%ld", symbol_label_id(label));
+ sprintf(ach, "." HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)symbol_label_id(label));
strcat(retval, ach);
free(mangled_program_name);
free(section);
@@ -2391,11 +2396,11 @@ section_label(struct cbl_proc_t *procedu
cbl_label_t *label = procedure->label;
// The _initialize_program section isn't relevant.
- char *psz = xasprintf("%s SECTION %s in %s (%ld)",
+ char *psz = xasprintf("%s SECTION %s in %s (" HOST_SIZE_T_PRINT_DEC ")",
ASM_COMMENT_START,
label->name,
current_function->our_unmangled_name,
- deconflictor);
+ (fmt_size_t)deconflictor);
gg_insert_into_assembler(psz);
free(psz);
@@ -2443,12 +2448,12 @@ paragraph_label(struct cbl_proc_t *proce
char *psz1 =
xasprintf(
- "%s PARAGRAPH %s of %s in %s (%ld)",
+ "%s PARAGRAPH %s of %s in %s (" HOST_SIZE_T_PRINT_DEC ")",
ASM_COMMENT_START,
para_name ? para_name: "" ,
section_name ? section_name: "(null)" ,
current_function->our_unmangled_name ?
current_function->our_unmangled_name: "" ,
- deconflictor );
+ (fmt_size_t)deconflictor );
gg_insert_into_assembler(psz1);
@@ -2560,8 +2565,8 @@ leave_procedure(struct cbl_proc_t *proce
gg_append_statement(procedure->exit.label);
char *psz;
- psz = xasprintf("_procret.%ld:",
- symbol_label_id(procedure->label));
+ psz = xasprintf("_procret." HOST_SIZE_T_PRINT_DEC ":",
+ (fmt_size_t)symbol_label_id(procedure->label));
gg_insert_into_assembler(psz);
free(psz);
pseudo_return_pop(procedure);
@@ -3042,12 +3047,12 @@ parser_perform(cbl_label_t *label, bool
para_name = label->name;
sect_name = section_label->name;
sprintf(ach,
- "%s PERFORM %s of %s of %s (%ld)",
+ "%s PERFORM %s of %s of %s (" HOST_SIZE_T_PRINT_DEC ")",
ASM_COMMENT_START,
para_name,
sect_name,
program_name,
- deconflictor);
+ (fmt_size_t)deconflictor);
gg_insert_into_assembler(ach);
}
@@ -3055,19 +3060,19 @@ parser_perform(cbl_label_t *label, bool
{
sect_name = label->name;
sprintf(ach,
- "%s PERFORM %s of %s (%ld)",
+ "%s PERFORM %s of %s (" HOST_SIZE_T_PRINT_DEC ")",
ASM_COMMENT_START,
sect_name,
program_name,
- deconflictor);
+ (fmt_size_t)deconflictor);
gg_insert_into_assembler(ach);
}
if( !suppress_nexting )
{
sprintf(ach,
- "_proccall.%ld.%d:",
- symbol_label_id(label),
+ "_proccall." HOST_SIZE_T_PRINT_DEC ".%d:",
+ (fmt_size_t)symbol_label_id(label),
call_counter++);
gg_insert_into_assembler( ach );
}
@@ -3115,8 +3120,8 @@ parser_perform_times( cbl_label_t *proc_
char ach[256];
size_t our_pseudo_label = pseudo_label++;
sprintf(ach,
- "_proccallb.%ld:",
- our_pseudo_label);
+ "_proccallb." HOST_SIZE_T_PRINT_DEC ":",
+ (fmt_size_t)our_pseudo_label);
gg_insert_into_assembler( ach );
tree counter = gg_define_variable(LONG);
@@ -3137,8 +3142,8 @@ parser_perform_times( cbl_label_t *proc_
WEND
sprintf(ach,
- "_procretb.%ld:",
- our_pseudo_label);
+ "_procretb." HOST_SIZE_T_PRINT_DEC ":",
+ (fmt_size_t)our_pseudo_label);
gg_insert_into_assembler(ach);
}
@@ -3215,8 +3220,8 @@ internal_perform_through( cbl_label_t *p
{
char ach[256];
sprintf(ach,
- "_proccall.%ld.%d:",
- symbol_label_id(proc_2),
+ "_proccall." HOST_SIZE_T_PRINT_DEC ".%d:",
+ (fmt_size_t)symbol_label_id(proc_2),
call_counter++);
gg_insert_into_assembler(ach);
}
@@ -3265,8 +3270,8 @@ internal_perform_through_times( cbl_la
char ach[256];
sprintf(ach,
- "_proccallb.%ld:",
- our_pseudo_label);
+ "_proccallb." HOST_SIZE_T_PRINT_DEC ":",
+ (fmt_size_t)our_pseudo_label);
gg_insert_into_assembler( ach );
tree counter = gg_define_variable(LONG);
@@ -3282,8 +3287,8 @@ internal_perform_through_times( cbl_la
WEND
sprintf(ach,
- "_procretb.%ld:",
- our_pseudo_label);
+ "_procretb." HOST_SIZE_T_PRINT_DEC ":",
+ (fmt_size_t)our_pseudo_label);
gg_insert_into_assembler( ach );
}
@@ -3594,7 +3599,8 @@ parser_enter_program( const char *funcna
if( parent_index )
{
// This is a nested function. Tack on the parent_index to the end of it.
- sprintf(funcname, "%s.%ld", mangled_name, parent_index);
+ sprintf(funcname, "%s." HOST_SIZE_T_PRINT_DEC, mangled_name,
+ (fmt_size_t)parent_index);
}
else
{
@@ -3760,8 +3766,8 @@ parser_init_list_size(int count_of_varia
vti_list_size = count_of_variables;
char ach[48];
sprintf(ach,
- "..variables_to_init_%ld",
- current_function->our_symbol_table_index);
+ "..variables_to_init_" HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)current_function->our_symbol_table_index);
tree array_of_variables_type = build_array_type_nelts(VOID_P,
count_of_variables+1);
vti_array = gg_define_variable( array_of_variables_type,
@@ -3799,8 +3805,8 @@ parser_init_list()
char ach[48];
sprintf(ach,
- "..variables_to_init_%ld",
- current_function->our_symbol_table_index);
+ "..variables_to_init_" HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)current_function->our_symbol_table_index);
tree array = gg_trans_unit_var_decl(ach);
gg_call(VOID,
"__gg__variables_to_init",
@@ -3981,7 +3987,7 @@ psa_FldLiteralN(struct cbl_field_t *fiel
static size_t our_index = 0;
- sprintf(id_string, ".%ld", ++our_index);
+ sprintf(id_string, "." HOST_SIZE_T_PRINT_DEC, (fmt_size_t)++our_index);
strcpy(base_name, field->name);
strcat(base_name, id_string);
@@ -4018,7 +4024,7 @@ psa_FldBlob(struct cbl_field_t *var )
static size_t our_index = 0;
- sprintf(id_string, ".%ld", ++our_index);
+ sprintf(id_string, "." HOST_SIZE_T_PRINT_DEC, (fmt_size_t)++our_index);
strcpy(base_name, var->name);
strcat(base_name, id_string);
@@ -5089,7 +5095,8 @@ parser_assign( size_t nC, cbl_num_result
{
TRACE1_HEADER
char ach[32];
- sprintf(ach, "%ld target%s", nC, nC==1 ? "" : "s");
+ sprintf(ach, HOST_SIZE_T_PRINT_DEC " target%s",
+ (fmt_size_t)nC, nC==1 ? "" : "s");
TRACE1_TEXT(ach);
if( on_error )
{
@@ -5108,7 +5115,8 @@ parser_assign( size_t nC, cbl_num_result
TRACE1
{
char ach[48];
- sprintf(ach, "Processing target number %ld", i);
+ sprintf(ach, "Processing target number " HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)i);
TRACE1_INDENT
TRACE1_TEXT(ach);
}
@@ -6162,7 +6170,8 @@ parser_free( size_t n, cbl_refer_t refer
gcc_assert( ! p->is_refmod_reference() );
if( !(p->field->type == FldPointer || p->addr_of || (p->field->attr &
based_e)) )
{
- dbgmsg("Deallocating %s means it has to be FldPointer or addr_of or
based_e");
+ dbgmsg("Deallocating %s means it has to be FldPointer or addr_of or
based_e",
+ p->field->name);
}
gcc_assert( p->field->type == FldPointer || p->addr_of || (p->field->attr
& based_e) );
@@ -6436,8 +6445,8 @@ parser_division(cbl_division_t division,
// We need a pointer to the array of program names
char ach[2*sizeof(cbl_name_t)];
sprintf(ach,
- "..accessible_program_list_%ld",
- current_function->our_symbol_table_index);
+ "..accessible_program_list_" HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)current_function->our_symbol_table_index);
tree prog_list = gg_define_variable(build_pointer_type(CHAR_P),
ach, vs_file_static);
@@ -6449,8 +6458,8 @@ parser_division(cbl_division_t division,
tree pointer_type = build_pointer_type(function_type);
tree constructed_array_type = build_array_type_nelts(pointer_type, 1);
sprintf(ach,
- "..accessible_program_pointers_%ld",
- current_function->our_symbol_table_index);
+ "..accessible_program_pointers_" HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)current_function->our_symbol_table_index);
tree prog_pointers = gg_define_variable(
build_pointer_type(constructed_array_type),
ach,
@@ -7753,8 +7762,8 @@ perform_outofline_before_until(struct cb
char ach[256];
size_t our_pseudo_label = pseudo_label++;
sprintf(ach,
- "_proccallb.%ld:",
- our_pseudo_label);
+ "_proccallb." HOST_SIZE_T_PRINT_DEC ":",
+ (fmt_size_t)our_pseudo_label);
gg_insert_into_assembler( ach );
parser_if(varys[0].until);
@@ -7776,8 +7785,8 @@ perform_outofline_before_until(struct cb
// Label the bottom of the PERFORM
gg_append_statement( tgt->addresses.exit.label );
sprintf(ach,
- "_procretb.%ld:",
- our_pseudo_label);
+ "_procretb." HOST_SIZE_T_PRINT_DEC ":",
+ (fmt_size_t)our_pseudo_label);
gg_insert_into_assembler( ach );
}
@@ -7808,8 +7817,8 @@ perform_outofline_after_until(struct cbl
char ach[256];
size_t our_pseudo_label = pseudo_label++;
sprintf(ach,
- "_proccallb.%ld:",
- our_pseudo_label);
+ "_proccallb." HOST_SIZE_T_PRINT_DEC ":",
+ (fmt_size_t)our_pseudo_label);
gg_insert_into_assembler( ach );
create_iline_address_pairs(tgt);
@@ -7839,8 +7848,8 @@ perform_outofline_after_until(struct cbl
// Label the bottom of the PERFORM
gg_append_statement( tgt->addresses.exit.label );
sprintf(ach,
- "_procretb.%ld:",
- our_pseudo_label);
+ "_procretb." HOST_SIZE_T_PRINT_DEC ":",
+ (fmt_size_t)our_pseudo_label);
gg_insert_into_assembler( ach );
}
@@ -7904,8 +7913,8 @@ perform_outofline_testafter_varying(stru
char ach[256];
size_t our_pseudo_label = pseudo_label++;
sprintf(ach,
- "_proccallb.%ld:",
- our_pseudo_label);
+ "_proccallb." HOST_SIZE_T_PRINT_DEC ":",
+ (fmt_size_t)our_pseudo_label);
gg_insert_into_assembler( ach );
create_iline_address_pairs(tgt);
@@ -7959,8 +7968,8 @@ perform_outofline_testafter_varying(stru
// Arriving here means that we all of the conditions were
// true. So, we're done.
sprintf(ach,
- "_procretb.%ld:",
- our_pseudo_label);
+ "_procretb." HOST_SIZE_T_PRINT_DEC ":",
+ (fmt_size_t)our_pseudo_label);
gg_insert_into_assembler( ach );
}
@@ -8021,8 +8030,8 @@ perform_outofline_before_varying( stru
char ach[256];
size_t our_pseudo_label = pseudo_label++;
sprintf(ach,
- "_proccallb.%ld:",
- our_pseudo_label);
+ "_proccallb." HOST_SIZE_T_PRINT_DEC ":",
+ (fmt_size_t)our_pseudo_label);
gg_insert_into_assembler( ach );
// Initialize all varying:
@@ -8102,8 +8111,8 @@ perform_outofline_before_varying( stru
// We have, you see, reached the egress:
gg_append_statement( tgt->addresses.exit.label );
sprintf(ach,
- "_procretb.%ld:",
- our_pseudo_label);
+ "_procretb." HOST_SIZE_T_PRINT_DEC ":",
+ (fmt_size_t)our_pseudo_label);
gg_insert_into_assembler( ach );
}
@@ -8310,7 +8319,7 @@ perform_inline_testbefore_varying( stru
{
SHOW_PARSE_INDENT
char ach[32];
- sprintf(ach, "LABEL [%ld]:", i);
+ sprintf(ach, "LABEL [" HOST_SIZE_T_PRINT_DEC "]:", (fmt_size_t)i);
SHOW_PARSE_TEXT(ach)
SHOW_PARSE_END
}
@@ -8321,7 +8330,8 @@ perform_inline_testbefore_varying( stru
{
SHOW_PARSE_INDENT
char ach[32];
- sprintf(ach, "LABEL CONDINTO[%ld]:", i);
+ sprintf(ach, "LABEL CONDINTO[" HOST_SIZE_T_PRINT_DEC "]:",
+ (fmt_size_t)i);
SHOW_PARSE_TEXT(ach)
SHOW_PARSE_END
}
@@ -8332,7 +8342,8 @@ perform_inline_testbefore_varying( stru
{
SHOW_PARSE_INDENT
char ach[32];
- sprintf(ach, "LABEL CONDBACK[%ld]:", i);
+ sprintf(ach, "LABEL CONDBACK[" HOST_SIZE_T_PRINT_DEC "]:",
+ (fmt_size_t)i);
SHOW_PARSE_TEXT(ach)
SHOW_PARSE_END
}
@@ -8367,7 +8378,8 @@ perform_inline_testbefore_varying( stru
{
SHOW_PARSE_INDENT
char ach[32];
- sprintf(ach, "GOTO [%ld]:", i-1);
+ sprintf(ach, "GOTO [" HOST_SIZE_T_PRINT_DEC "]:",
+ (fmt_size_t)(i-1));
SHOW_PARSE_TEXT(ach)
SHOW_PARSE_END
}
@@ -8401,7 +8413,8 @@ perform_inline_testbefore_varying( stru
{
SHOW_PARSE_INDENT
char ach[32];
- sprintf(ach, "GOTO [%ld]:", N-1);
+ sprintf(ach, "GOTO [" HOST_SIZE_T_PRINT_DEC "]:",
+ (fmt_size_t)(N-1));
SHOW_PARSE_TEXT(ach)
SHOW_PARSE_END
}
@@ -8418,7 +8431,8 @@ perform_inline_testbefore_varying( stru
{
SHOW_PARSE_INDENT
char ach[32];
- sprintf(ach, "GOTO [%ld]:", i-1);
+ sprintf(ach, "GOTO [" HOST_SIZE_T_PRINT_DEC "]:",
+ (fmt_size_t)(i-1));
SHOW_PARSE_TEXT(ach)
SHOW_PARSE_END
}
@@ -9997,7 +10011,7 @@ inspect_replacing(int backward,
void
parser_inspect(cbl_refer_t identifier_1,
bool backward,
- unsigned long n_operations,
+ size_t n_operations,
cbx_inspect_t<cbl_refer_t>* operations)
{
Analyze();
@@ -10218,7 +10232,8 @@ parser_intrinsic_callv( cbl_field_t *tgt
SHOW_PARSE_HEADER
SHOW_PARSE_TEXT(" of ")
SHOW_PARSE_TEXT(function_name)
- fprintf(stderr, " with %zd parameters", nrefs);
+ fprintf(stderr, " with " HOST_SIZE_T_PRINT_DEC " parameters",
+ (fmt_size_t)nrefs);
SHOW_PARSE_END
}
@@ -12700,7 +12715,7 @@ parser_bitop( struct cbl_field_t *tgt,
{
SHOW_PARSE_HEADER
SHOW_PARSE_FIELD( " switch: ", a)
- fprintf(stderr, " mask: %lx", bitmask);
+ fprintf(stderr, " mask: " HOST_SIZE_T_PRINT_HEX_PURE, (fmt_size_t)bitmask);
fprintf(stderr, " op: %s", ops[op]);
SHOW_PARSE_FIELD( " target ", tgt)
SHOW_PARSE_END
@@ -12784,7 +12799,7 @@ parser_bitwise_op(struct cbl_field_t *tg
{
SHOW_PARSE_HEADER
SHOW_PARSE_FIELD( " switch: ", a)
- fprintf(stderr, " mask: %lx", bitmask);
+ fprintf(stderr, " mask: " HOST_SIZE_T_PRINT_HEX_PURE, (fmt_size_t)bitmask);
fprintf(stderr, " op: %s", ops[op]);
SHOW_PARSE_FIELD( " target ", tgt)
SHOW_PARSE_END
@@ -12988,11 +13003,11 @@ parser_program_hierarchy( const struct c
}
char ach[128];
sprintf(ach,
- "%ld %s%s parent:%ld",
- hier.labels[i].ordinal,
+ HOST_SIZE_T_PRINT_DEC " %s%s parent:" HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)hier.labels[i].ordinal,
hier.labels[i].label.name,
hier.labels[i].label.common ? " COMMON" : "",
- hier.labels[i].label.parent);
+ (fmt_size_t)hier.labels[i].label.parent);
SHOW_PARSE_TEXT(ach);
}
}
@@ -13121,12 +13136,14 @@ parser_program_hierarchy( const struct c
char ach[2*sizeof(cbl_name_t)];
tree names_table_type = build_array_type_nelts(CHAR_P,
mol->second.size()+1);
- sprintf(ach, "..our_accessible_functions_%ld", caller);
+ sprintf(ach, "..our_accessible_functions_" HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)caller);
tree the_names_table = gg_define_variable(names_table_type, ach,
vs_file_static);
// Here is where we build a table out of constructors:
tree constructed_array_type = build_array_type_nelts(pointer_type,
mol->second.size());
- sprintf(ach, "..our_constructed_table_%ld", caller);
+ sprintf(ach, "..our_constructed_table_" HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)caller);
tree the_constructed_table =
gg_define_variable(constructed_array_type, ach, vs_file_static);
tree constr_names = make_node(CONSTRUCTOR);
@@ -13144,7 +13161,8 @@ parser_program_hierarchy( const struct c
callee != mol->second.end();
callee++ )
{
- sprintf(ach, "%s.%ld", (*callee)->name,
(*callee)->parent_node->our_index);
+ sprintf(ach, "%s." HOST_SIZE_T_PRINT_DEC, (*callee)->name,
+ (fmt_size_t)(*callee)->parent_node->our_index);
CONSTRUCTOR_APPEND_ELT( CONSTRUCTOR_ELTS(constr_names),
build_int_cst_type(SIZE_T, i),
@@ -13170,11 +13188,13 @@ parser_program_hierarchy( const struct c
// And put a pointer to that table into the file-static variable set
aside
// for it:
- sprintf(ach, "..accessible_program_list_%ld", caller);
+ sprintf(ach, "..accessible_program_list_" HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)caller);
tree accessible_list_var_decl = gg_trans_unit_var_decl(ach);
gg_assign( accessible_list_var_decl,
gg_get_address_of(the_names_table) );
- sprintf(ach, "..accessible_program_pointers_%ld", caller);
+ sprintf(ach, "..accessible_program_pointers_" HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)caller);
tree accessible_programs_decl = gg_trans_unit_var_decl(ach);
gg_assign( accessible_programs_decl,
gg_get_address_of(the_constructed_table) );
}
@@ -13192,7 +13212,8 @@ parser_set_handled(ec_type_t ec_handled)
{
SHOW_PARSE_HEADER
char ach[64];
- sprintf(ach, "ec_type_t: 0x%lx", size_t(ec_handled));
+ sprintf(ach, "ec_type_t: 0x" HOST_SIZE_T_PRINT_HEX_PURE,
+ (fmt_size_t)ec_handled);
SHOW_PARSE_TEXT(ach);
SHOW_PARSE_END
}
@@ -13261,7 +13282,7 @@ parser_set_numeric(struct cbl_field_t *t
SHOW_PARSE_TEXT(tgt->name)
SHOW_PARSE_TEXT(" to ")
char ach[32];
- sprintf(ach, "%ld", value);
+ sprintf(ach, HOST_SIZE_T_PRINT_DEC, (fmt_size_t)value);
SHOW_PARSE_TEXT(ach);
SHOW_PARSE_END
}
@@ -15983,12 +16004,14 @@ psa_new_var_decl(cbl_field_t *new_var, c
&& symbol_at(new_var->parent)->type == SymField )
{
// We have a parent that is a field
- sprintf(id_string, ".%ld_%ld", our_index, new_var->parent);
+ sprintf(id_string, "." HOST_SIZE_T_PRINT_DEC "_" HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)our_index, (fmt_size_t)new_var->parent);
}
else
{
// The parent is zero, so it'll be implied:
- sprintf(id_string, ".%ld", our_index);
+ sprintf(id_string, "." HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)our_index);
}
if(strcasecmp(new_var->name, "filler") == 0)
@@ -16229,29 +16252,30 @@ parser_symbol_add(struct cbl_field_t *ne
}
while(0);
- fprintf(stderr, " %2.2d %s<%s> off:%zd "
- "msiz:%d cap:%d dig:%d rdig:%d attr:0x%lx loc:%p",
+ fprintf(stderr, " %2.2d %s<%s> off:" HOST_SIZE_T_PRINT_DEC " "
+ "msiz:%d cap:%d dig:%d rdig:%d attr:0x"
HOST_SIZE_T_PRINT_HEX_PURE " loc:%p",
new_var->level,
new_var->name,
cbl_field_type_str(new_var->type),
- new_var->offset,
+ (fmt_size_t)new_var->offset,
new_var->data.memsize,
new_var->data.capacity,
new_var->data.digits,
new_var->data.rdigits,
- new_var->attr,
+ (fmt_size_t)new_var->attr,
(void*)new_var);
if( is_table(new_var) )
{
- fprintf(stderr," OCCURS:%zd", new_var->occurs.ntimes());
+ fprintf(stderr," OCCURS:" HOST_SIZE_T_PRINT_DEC,
+ (fmt_size_t)new_var->occurs.ntimes());
}
cbl_field_t *parent = parent_of(new_var);
if( parent )
{
fprintf(stderr,
- " parent:(%zd)%s",
- new_var->parent,
+ " parent:(" HOST_SIZE_T_PRINT_DEC ")%s",
+ (fmt_size_t)new_var->parent,
parent->name);
}
else
@@ -16264,8 +16288,8 @@ parser_symbol_add(struct cbl_field_t *ne
if( e->type == SymFile )
{
fprintf(stderr,
- " parent_file:(%zd)%s",
- new_var->parent,
+ " parent_file:(" HOST_SIZE_T_PRINT_DEC ")%s",
+ (fmt_size_t)new_var->parent,
e->elem.file.name);
if( e->elem.file.attr & external_e )
{
@@ -16711,9 +16735,10 @@ parser_symbol_add(struct cbl_field_t *ne
if( !bytes_to_allocate )
{
fprintf(stderr,
- "bytes_to_allocate is zero for %s (symbol number %ld)\n",
+ "bytes_to_allocate is zero for %s (symbol number "
+ HOST_SIZE_T_PRINT_DEC ")\n",
new_var->name,
- new_var->our_index);
+ (fmt_size_t)new_var->our_index);
gcc_assert(bytes_to_allocate);
}
@@ -16747,16 +16772,16 @@ parser_symbol_add(struct cbl_field_t *ne
{
// Avoid doubling up on leading underscore
sprintf(achDataName,
- "%s_data_%lu",
+ "%s_data_" HOST_SIZE_T_PRINT_UNSIGNED,
new_var->name,
- sv_data_name_counter++);
+ (fmt_size_t)sv_data_name_counter++);
}
else
{
sprintf(achDataName,
- "_%s_data_%lu",
+ "_%s_data_" HOST_SIZE_T_PRINT_UNSIGNED,
new_var->name,
- sv_data_name_counter++);
+ (fmt_size_t)sv_data_name_counter++);
}
if( new_var->attr & external_e )
--- gcc/cobol/cdf-copy.cc.jj 2025-04-08 14:08:48.536319661 +0200
+++ gcc/cobol/cdf-copy.cc 2025-05-02 12:16:43.448926560 +0200
@@ -34,6 +34,7 @@
//
// We regret any confusion engendered.
+#include "config.h"
#include <glob.h>
#include "cobol-system.h"
--- gcc/cobol/scan_ante.h.jj 2025-04-12 13:10:31.679522486 +0200
+++ gcc/cobol/scan_ante.h 2025-05-02 12:16:43.448926560 +0200
@@ -438,11 +438,12 @@ trim_location( int nkeep) {
} rescan = { yytext + nkeep, yytext + yyleng };
auto nline = std::count(rescan.p, rescan.pend, '\n');
- dbgmsg("%s:%d: yyless(%d), rescan '%.*s' (%zu lines, %d bytes)",
+ dbgmsg("%s:%d: yyless(%d), rescan '%.*s' (" HOST_SIZE_T_PRINT_UNSIGNED
+ " lines, " HOST_SIZE_T_PRINT_UNSIGNED " bytes)",
__func__, __LINE__,
nkeep,
int(rescan.size()), rescan.p,
- nline, rescan.size());
+ (fmt_size_t)nline, (fmt_size_t)rescan.size());
if( nline ) {
gcc_assert( yylloc.first_line + nline <= yylloc.last_line );
yylloc.last_line =- int(nline);
--- gcc/cobol/structs.cc.jj 2025-04-08 14:08:48.725317030 +0200
+++ gcc/cobol/structs.cc 2025-05-02 12:16:43.455926467 +0200
@@ -176,7 +176,7 @@ create_cblc_field_t()
struct cblc_field_t *parent;// This field's immediate parent field
size_t occurs_lower; // non-zero for a table
size_t occurs_upper; // non-zero for a table
- size_t attr; // See cbl_field_attr_t
+ uint64_t attr; // See cbl_field_attr_t
signed char type; // A one-byte copy of cbl_field_type_t
signed char level; // This variable's level in the naming
heirarchy
signed char digits; // Digits specified in PIC string; e.g. 5
for 99v999
@@ -196,7 +196,7 @@ create_cblc_field_t()
CHAR_P, "parent",
SIZE_T, "occurs_lower",
SIZE_T, "occurs_upper",
- SIZE_T, "attr",
+ ULONGLONG, "attr",
SCHAR, "type",
SCHAR, "level",
SCHAR, "digits",
--- gcc/cobol/cbldiag.h.jj 2025-04-12 13:10:31.565524062 +0200
+++ gcc/cobol/cbldiag.h 2025-05-02 12:16:43.480926133 +0200
@@ -97,7 +97,7 @@ void cbl_unimplemented_at( const YYLTYP
* be localized and fwrite directly to standard out. dbgmsg is activated by
* -fflex-debug or -fyacc-debug.
*/
-void dbgmsg( const char fmt[], ... );
+void dbgmsg( const char fmt[], ... ) ATTRIBUTE_PRINTF_1;
void gcc_location_set( const YYLTYPE& loc );
--- gcc/cobol/gcobolspec.cc.jj 2025-04-08 14:08:48.595318840 +0200
+++ gcc/cobol/gcobolspec.cc 2025-05-02 12:16:43.492925973 +0200
@@ -541,13 +541,14 @@ lang_specific_driver (struct cl_decoded_
#endif
if( verbose && new_options != original_options )
{
- fprintf(stderr, _("Driving: (%ld)\n"), new_option_count);
+ fprintf(stderr, _("Driving: (" HOST_SIZE_T_PRINT_DEC ")\n"),
+ (fmt_size_t)new_option_count);
for(size_t i=0; i<new_option_count; i++)
{
fprintf(stderr,
- " [%2ld] %4ld %s\n",
- i,
- new_options[i].opt_index,
+ " [%2" GCC_PRISZ "d] %4" GCC_PRISZ "d %s\n",
+ (fmt_size_t)i,
+ (fmt_size_t)new_options[i].opt_index,
new_options[i].orig_option_with_args_text);
}
fprintf (stderr, "\n");
--- gcc/cobol/parse_ante.h.jj 2025-04-08 14:08:48.680317657 +0200
+++ gcc/cobol/parse_ante.h 2025-05-02 12:16:43.533925426 +0200
@@ -142,7 +142,8 @@ literal_of( size_t value ) {
case 0: return literally_zero;
case 1: return literally_one;
}
- cbl_err("logic error: %s: %zu not supported", __func__, value);
+ cbl_err("logic error: %s: " HOST_SIZE_T_PRINT_UNSIGNED " not supported",
+ __func__, (fmt_size_t)value);
return NULL;
}
@@ -312,7 +313,9 @@ struct evaluate_elem_t {
case_iter pcase;
void dump() const {
- dbgmsg( "nother=%zu label '%s', %zu cases", nother, label.name,
cases.size() );
+ dbgmsg( "nother=" HOST_SIZE_T_PRINT_UNSIGNED " label '%s', "
+ HOST_SIZE_T_PRINT_UNSIGNED " cases",
+ (fmt_size_t)nother, label.name, (fmt_size_t)cases.size() );
std::for_each( cases.begin(), cases.end(), case_t::Dump );
}
@@ -542,8 +545,10 @@ struct arith_t {
res.refer.field = cbl_field_of(symbol_at(tgt));
tgts.push_back( res );
- dbgmsg("%s:%d: SRC: %3zu %s", __func__, __LINE__, src, a.str());
- dbgmsg("%s:%d: to %3zu %s", __func__, __LINE__, tgt, res.refer.str());
+ dbgmsg("%s:%d: SRC: %3" GCC_PRISZ "u %s",
+ __func__, __LINE__, (fmt_size_t)src, a.str());
+ dbgmsg("%s:%d: to %3" GCC_PRISZ "u %s",
+ __func__, __LINE__, (fmt_size_t)tgt, res.refer.str());
}
void operator()( const corresponding_fields_t::const_reference elem ) {
another_pair( elem.first, elem.second );
@@ -2089,8 +2094,10 @@ static class current_t {
size_t n =
parser_call_target_update(caller, called->name, mangled_name);
// Zero is not an error
- dbgmsg("updated %zu calls from #%-3zu (%s) s/%s/%s/",
- n, caller, caller_name, called->name, mangled_name);
+ dbgmsg("updated " HOST_SIZE_T_PRINT_UNSIGNED
+ " calls from #%-3" GCC_PRISZ "u (%s) s/%s/%s/",
+ (fmt_size_t)n, (fmt_size_t)caller, caller_name,
+ called->name, mangled_name);
}
}
if( yydebug ) parser_call_targets_dump();
@@ -3006,8 +3013,8 @@ file_add( YYLTYPE loc, cbl_file_t *file
}
file = cbl_file_of(e);
snprintf(field->name, sizeof(field->name),
- "%s%zu_%s",
- record_area_name_stem, symbol_index(e), file->name);
+ "%s" HOST_SIZE_T_PRINT_UNSIGNED "_%s",
+ record_area_name_stem, (fmt_size_t)symbol_index(e), file->name);
if( file->attr & external_e ) {
snprintf(field->name, sizeof(field->name),
"%s%s", record_area_name_stem, file->name);
@@ -3153,7 +3160,8 @@ static cbl_label_t *
implicit_paragraph()
{
cbl_name_t name;
- sprintf(name, "_implicit_paragraph_%zu", symbol_index());
+ sprintf(name, "_implicit_paragraph_" HOST_SIZE_T_PRINT_UNSIGNED,
+ (fmt_size_t)symbol_index());
// Programs have to start with an implicit paragraph
return label_add(LblParagraph, name, yylineno);
}
@@ -3161,7 +3169,8 @@ static cbl_label_t *
implicit_section()
{
cbl_name_t name;
- sprintf(name, "_implicit_section_%zu", symbol_index());
+ sprintf(name, "_implicit_section_" HOST_SIZE_T_PRINT_UNSIGNED,
+ (fmt_size_t)symbol_index());
// Programs have to start with an implicit section
return label_add(LblSection, name, yylineno);
}
@@ -3236,7 +3245,8 @@ data_division_ready() {
}
if( nsymbol == 0 || nparse_error > 0 ) {
- dbgmsg( "%d errors in DATA DIVISION, compilation ceases", nparse_error );
+ dbgmsg( HOST_SIZE_T_PRINT_DEC " errors in DATA DIVISION, compilation
ceases",
+ (fmt_size_t)nparse_error );
return false;
}
--- gcc/cobol/symbols.h.jj 2025-04-08 14:08:48.739316835 +0200
+++ gcc/cobol/symbols.h 2025-05-02 12:16:43.558925092 +0200
@@ -494,7 +494,7 @@ bool is_elementary( enum cbl_field_type_
struct cbl_field_t {
size_t offset;
enum cbl_field_type_t type, usage;
- size_t attr;
+ uint64_t attr;
static_assert(sizeof(attr) == sizeof(cbl_field_attr_t), "wrong attr size");
size_t parent; // symbols[] index of our parent
size_t our_index; // symbols[] index of this field, set in symbol_add()
@@ -597,8 +597,8 @@ struct cbl_field_t {
bool has_attr( cbl_field_attr_t attr ) const {
return cbl_field_attr_t(this->attr & attr) == attr;
}
- size_t set_attr( cbl_field_attr_t attr );
- size_t clear_attr( cbl_field_attr_t attr );
+ uint64_t set_attr( cbl_field_attr_t attr );
+ uint64_t clear_attr( cbl_field_attr_t attr );
const char * attr_str( const std::vector<cbl_field_attr_t>& attrs ) const;
bool is_justifiable() const {
@@ -1273,7 +1273,8 @@ struct function_descr_t {
static function_descr_t init( const char name[] ) {
function_descr_t descr = {};
if( -1 == snprintf( descr.name, sizeof(descr.name), "%s", name ) ) {
- dbgmsg("name truncated to '%s' (max %zu characters)", name);
+ dbgmsg("name truncated to '%s' (max " HOST_SIZE_T_PRINT_UNSIGNED
+ " characters)", name, (fmt_size_t)sizeof(descr.name));
}
return descr; // truncation also reported elsewhere ?
}
@@ -2049,11 +2050,12 @@ struct cbl_perform_tgt_t {
void dump() const {
assert(ifrom);
if( !ito ) {
- dbgmsg( "%s:%d: #%3zu %s", __PRETTY_FUNCTION__, __LINE__,
- ifrom, from()->str() );
+ dbgmsg( "%s:%d: #%3" GCC_PRISZ "u %s", __PRETTY_FUNCTION__, __LINE__,
+ (fmt_size_t)ifrom, from()->str() );
} else {
- dbgmsg( "%s:%d: #%3zu %s THRU #%3zu %s", __PRETTY_FUNCTION__, __LINE__,
- ifrom, from()->str(), ito, to()->str() );
+ dbgmsg( "%s:%d: #%3" GCC_PRISZ "u %s THRU #%3" GCC_PRISZ "u %s",
+ __PRETTY_FUNCTION__, __LINE__,
+ (fmt_size_t)ifrom, from()->str(), (fmt_size_t)ito, to()->str() );
}
}
@@ -2246,7 +2248,7 @@ cbl_file_t * symbol_record_file( const c
struct cbl_field_t * symbol_find_odo( const cbl_field_t * field );
-size_t numeric_group_attrs( const cbl_field_t *field );
+uint64_t numeric_group_attrs( const cbl_field_t *field );
static inline struct cbl_field_t *
field_at( size_t index ) {
Jakub