From patchwork Sat Feb 10 09:38:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1897329 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iMhV77a6; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TX5JV2LZgz1yP6 for ; Sat, 10 Feb 2024 20:38:48 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 328833858CDA for ; Sat, 10 Feb 2024 09:38:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 5B4B73858D20 for ; Sat, 10 Feb 2024 09:38:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5B4B73858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5B4B73858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707557905; cv=none; b=nWQvsTGsNYjxX9kiRQh63fjrGQCCbcr6tRW2A4wDxxfS+8+2vLdrxEGV68boDmUQDHuCcAoDGyzKwKqeSw9VAKTo+WwX7loa5TjN/WpPHHqG/MaaUsOUGdTzHwBwbo1o/ErV4hc5xv4PsaRX1cdkTQ+wU5o1uAzHgxkEihN55m0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707557905; c=relaxed/simple; bh=y7+yDD0VCslXGrZ/QfuCezQ1jefgxcdM9leerqhzL4M=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=MIFBZu6rHLojHfbPWWzJf4tQuItZRlwVbK6FCuZPc2Izd1RyYBypVnutIJmgf2DSqO9sJPxhKXt0uNGvEos4zwv2ZZeTir2mFTcO7gPuuuwPqQJw1uosVIZK/pbjbtn24oHIA0oL0t5lBASZLKDiSyvNxPKRrfc9vacJuCyGJok= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707557902; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=5xAA33gejuZUbI6G9LGblDDqP+fjrMnqaRmVuh6zpWM=; b=iMhV77a6C8tKHXsYy/qSNVSd7Bwf8M6LdXiVARXcRLojimnMgqkONZOv5UkGUCOS3L11Ak mgP+eqqjHFGU9Yps29w+vjpnavGSpdhKyMXvBIzu2vDJ06NnLZujbVoRFABeVMzI52H2XJ jtM9m6XjiF5k44Q5y/LsnONCLzh+aRE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-451--B95nXupNcSXTW2LaNaBWQ-1; Sat, 10 Feb 2024 04:38:16 -0500 X-MC-Unique: -B95nXupNcSXTW2LaNaBWQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB8E6846D58; Sat, 10 Feb 2024 09:38:15 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 584FA111FF; Sat, 10 Feb 2024 09:38:15 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 41A9cCQB4023391 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Sat, 10 Feb 2024 10:38:13 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 41A9cBLm4023390; Sat, 10 Feb 2024 10:38:11 +0100 Date: Sat, 10 Feb 2024 10:38:11 +0100 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Use HOST_SIZE_T_PRINT_* and HOST_WIDE_INT_T_PRINT_* some more Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi! I went through suspicios %l in format strings of *printf family functions combined with casts to (long) or (unsigned long) and tried to find out the types of the original expressions that were cast. Quite a few had size_t type, so I've used the new HOST_SIZE_T_PRINT_* macros together with cast to fmt_size_t for those, and then there were quite a few HOST_WIDE_INTs cast to long, used HOST_WIDE_INT_PRINT_* for those without casts. There was one case of a weird unsigned int variable used with %lu and (long) cast too. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2024-02-10 Jakub Jelinek gcc/ * ipa-icf.cc (sem_item_optimizer::process_cong_reduction, sem_item_optimizer::dump_cong_classes): Use HOST_SIZE_T_PRINT_UNSIGNED and casts to fmt_size_t instead of "%lu" and casts to unsigned long. * tree.cc (print_debug_expr_statistics): Use HOST_SIZE_T_PRINT_DEC and casts to fmt_size_t instead of "%ld" and casts to long. (print_value_expr_statistics, print_type_hash_statistics): Likewise. * dwarf2out.cc (output_macinfo_op): Use HOST_WIDE_INT_PRINT_UNSIGNED instead of "%lu" and casts to unsigned long. * gcov-dump.cc (dump_gcov_file): Use %u instead of %lu and casts to unsigned long. * tree-ssa-dom.cc (htab_statistics): Use HOST_SIZE_T_PRINT_DEC and casts to fmt_size_t instead of "%ld" and casts to long. * cfgexpand.cc (dump_stack_var_partition): Use HOST_SIZE_T_PRINT_UNSIGNED and casts to fmt_size_t instead of "%lu" and casts to unsigned long. * gengtype.cc (adjust_field_rtx_def): Likewise. * tree-into-ssa.cc (htab_statistics): Use HOST_SIZE_T_PRINT_DEC and casts to fmt_size_t instead of "%ld" and casts to long. * postreload-gcse.cc (dump_hash_table): Likewise. * ggc-page.cc (alloc_page): Use HOST_SIZE_T_PRINT_UNSIGNED and casts to fmt_size_t instead of "%lu" and casts to unsigned long. (ggc_internal_alloc, ggc_free): Likewise. * genpreds.cc (write_lookup_constraint_1): Likewise. (write_insn_constraint_len): Likewise. * tree-dfa.cc (dump_dfa_stats): Use HOST_SIZE_T_PRINT_DEC and casts to fmt_size_t instead of "%ld" and casts to long. * varasm.cc (output_constant_pool_contents): Use HOST_WIDE_INT_PRINT_DEC instead of "%ld" and casts to long. * var-tracking.cc (dump_var): Likewise. gcc/c-family/ * c-ada-spec.cc (dump_template_types): Use HOST_SIZE_T_PRINT_UNSIGNED and casts to fmt_size_t instead of "%lu" and casts to unsigned long. gcc/c/ * c-decl.cc (get_parm_array_spec): Use HOST_WIDE_INT_PRINT_UNSIGNED instead of "%lu" and casts to unsigned long or unsigned long long. gcc/cp/ * tree.cc (debug_binfo): Use HOST_WIDE_INT_PRINT_DEC instead of "%ld" and casts to long. * pt.cc (print_template_statistics): Use HOST_SIZE_T_PRINT_DEC and casts to fmt_size_t instead of "%ld" and casts to long. * class.cc (dump_class_hierarchy_1): Use HOST_WIDE_INT_PRINT_UNSIGNED instead of "%lu" and casts to unsigned long. For TYPE_ALIGN, use %u instead of %lu and drop casts to unsigned long. * parser.cc (cp_lexer_peek_nth_token): Use HOST_SIZE_T_PRINT_DEC and casts to fmt_size_t instead of "%ld" and casts to long. gcc/fortran/ * trans-common.cc (build_common_decl): Use %wu instead of %lu and casts to unsigned long. * resolve.cc (resolve_ordinary_assign): Use %wd instead of %ld and casts to long. * array.cc (gfc_resolve_character_array_constructor): Likewise. * data.cc (create_character_initializer): Likewise. gcc/jit/ * jit-playback.cc (new_bitcast): Use HOST_WIDE_INT_PRINT_DEC instead of "%ld" and casts to long. gcc/lto/ * lto-common.cc (print_lto_report_1): Use HOST_SIZE_T_PRINT_DEC and casts to fmt_size_t instead of "%ld" and casts to long. Use %d instead of %ld and casts to long for searches and collisions. Jakub --- gcc/ipa-icf.cc.jj 2024-01-12 10:07:58.211851417 +0100 +++ gcc/ipa-icf.cc 2024-02-09 13:02:33.289090629 +0100 @@ -3191,8 +3191,9 @@ sem_item_optimizer::process_cong_reducti worklist_push ((*it)->classes[i]); if (dump_file) - fprintf (dump_file, "Worklist has been filled with: %lu\n", - (unsigned long) worklist.nodes ()); + fprintf (dump_file, "Worklist has been filled with: " + HOST_SIZE_T_PRINT_UNSIGNED "\n", + (fmt_size_t) worklist.nodes ()); if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Congruence class reduction\n"); @@ -3239,8 +3240,9 @@ sem_item_optimizer::dump_cong_classes (v } fprintf (dump_file, - "Congruence classes: %lu with total: %u items (in a non-singular " - "class: %u)\n", (unsigned long) m_classes.elements (), + "Congruence classes: " HOST_SIZE_T_PRINT_UNSIGNED " with total: " + "%u items (in a non-singular class: %u)\n", + (fmt_size_t) m_classes.elements (), m_items.length (), m_items.length () - single_element_classes); fprintf (dump_file, "Class size histogram [number of members]: number of classes\n"); --- gcc/tree.cc.jj 2024-01-29 09:41:19.811391522 +0100 +++ gcc/tree.cc 2024-02-09 13:11:19.074766366 +0100 @@ -5882,9 +5882,10 @@ decl_fini_priority_insert (tree decl, pr static void print_debug_expr_statistics (void) { - fprintf (stderr, "DECL_DEBUG_EXPR hash: size %ld, %ld elements, %f collisions\n", - (long) debug_expr_for_decl->size (), - (long) debug_expr_for_decl->elements (), + fprintf (stderr, "DECL_DEBUG_EXPR hash: size " HOST_SIZE_T_PRINT_DEC ", " + HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n", + (fmt_size_t) debug_expr_for_decl->size (), + (fmt_size_t) debug_expr_for_decl->elements (), debug_expr_for_decl->collisions ()); } @@ -5893,9 +5894,10 @@ print_debug_expr_statistics (void) static void print_value_expr_statistics (void) { - fprintf (stderr, "DECL_VALUE_EXPR hash: size %ld, %ld elements, %f collisions\n", - (long) value_expr_for_decl->size (), - (long) value_expr_for_decl->elements (), + fprintf (stderr, "DECL_VALUE_EXPR hash: size " HOST_SIZE_T_PRINT_DEC ", " + HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n", + (fmt_size_t) value_expr_for_decl->size (), + (fmt_size_t) value_expr_for_decl->elements (), value_expr_for_decl->collisions ()); } @@ -6287,9 +6289,10 @@ type_hash_canon (unsigned int hashcode, static void print_type_hash_statistics (void) { - fprintf (stderr, "Type hash: size %ld, %ld elements, %f collisions\n", - (long) type_hash_table->size (), - (long) type_hash_table->elements (), + fprintf (stderr, "Type hash: size " HOST_SIZE_T_PRINT_DEC ", " + HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n", + (fmt_size_t) type_hash_table->size (), + (fmt_size_t) type_hash_table->elements (), type_hash_table->collisions ()); } --- gcc/cp/tree.cc.jj 2024-02-06 08:43:39.428547083 +0100 +++ gcc/cp/tree.cc 2024-02-09 13:28:46.265295073 +0100 @@ -2253,9 +2253,10 @@ debug_binfo (tree elem) while (virtuals) { tree fndecl = TREE_VALUE (virtuals); - fprintf (stderr, "%s [%ld =? %ld]\n", + fprintf (stderr, "%s [" HOST_WIDE_INT_PRINT_DEC " =? " + HOST_WIDE_INT_PRINT_DEC "]\n", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl)), - (long) n, (long) TREE_INT_CST_LOW (DECL_VINDEX (fndecl))); + n, TREE_INT_CST_LOW (DECL_VINDEX (fndecl))); ++n; virtuals = TREE_CHAIN (virtuals); } --- gcc/cp/pt.cc.jj 2024-02-09 11:02:15.270829624 +0100 +++ gcc/cp/pt.cc 2024-02-09 13:27:13.536568285 +0100 @@ -31593,13 +31593,15 @@ init_template_processing (void) void print_template_statistics (void) { - fprintf (stderr, "decl_specializations: size %ld, %ld elements, " - "%f collisions\n", (long) decl_specializations->size (), - (long) decl_specializations->elements (), + fprintf (stderr, "decl_specializations: size " HOST_SIZE_T_PRINT_DEC ", " + HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n", + (fmt_size_t) decl_specializations->size (), + (fmt_size_t) decl_specializations->elements (), decl_specializations->collisions ()); - fprintf (stderr, "type_specializations: size %ld, %ld elements, " - "%f collisions\n", (long) type_specializations->size (), - (long) type_specializations->elements (), + fprintf (stderr, "type_specializations: size " HOST_SIZE_T_PRINT_DEC ", " + HOST_SIZE_T_PRINT_DEC " elements, %f collisions\n", + (fmt_size_t) type_specializations->size (), + (fmt_size_t) type_specializations->elements (), type_specializations->collisions ()); } --- gcc/cp/class.cc.jj 2024-01-12 17:02:46.149056360 +0100 +++ gcc/cp/class.cc 2024-02-09 13:24:55.209467585 +0100 @@ -9585,14 +9585,14 @@ static void dump_class_hierarchy_1 (FILE *stream, dump_flags_t flags, tree t) { fprintf (stream, "Class %s\n", type_as_string (t, TFF_PLAIN_IDENTIFIER)); - fprintf (stream, " size=%lu align=%lu\n", - (unsigned long)(tree_to_shwi (TYPE_SIZE (t)) / BITS_PER_UNIT), - (unsigned long)(TYPE_ALIGN (t) / BITS_PER_UNIT)); + fprintf (stream, " size=" HOST_WIDE_INT_PRINT_UNSIGNED " align=%u\n", + tree_to_shwi (TYPE_SIZE (t)) / BITS_PER_UNIT, + TYPE_ALIGN (t) / BITS_PER_UNIT); if (tree as_base = CLASSTYPE_AS_BASE (t)) - fprintf (stream, " base size=%lu base align=%lu\n", - (unsigned long)(tree_to_shwi (TYPE_SIZE (as_base)) - / BITS_PER_UNIT), - (unsigned long)(TYPE_ALIGN (as_base) / BITS_PER_UNIT)); + fprintf (stream, " base size=" HOST_WIDE_INT_PRINT_UNSIGNED + " base align=%u\n", + tree_to_shwi (TYPE_SIZE (as_base)) / BITS_PER_UNIT, + TYPE_ALIGN (as_base) / BITS_PER_UNIT); dump_class_hierarchy_r (stream, flags, TYPE_BINFO (t), TYPE_BINFO (t), 0); fprintf (stream, "\n"); } --- gcc/cp/parser.cc.jj 2024-02-06 22:34:49.347204151 +0100 +++ gcc/cp/parser.cc 2024-02-09 13:27:37.092244855 +0100 @@ -1310,7 +1310,8 @@ cp_lexer_peek_nth_token (cp_lexer* lexer if (cp_lexer_debugging_p (lexer)) fprintf (cp_lexer_debug_stream, - "cp_lexer: peeking ahead %ld at token: ", (long)n); + "cp_lexer: peeking ahead " HOST_SIZE_T_PRINT_DEC " at token: ", + (fmt_size_t) n); --n; token = lexer->next_token; --- gcc/dwarf2out.cc.jj 2024-01-31 10:56:08.401735483 +0100 +++ gcc/dwarf2out.cc 2024-02-09 12:11:50.046496238 +0100 @@ -28987,8 +28987,9 @@ output_macinfo_op (macinfo_entry *ref) file_num = maybe_emit_file (fd); dw2_asm_output_data (1, DW_MACINFO_start_file, "Start new file"); dw2_asm_output_data_uleb128 (ref->lineno, - "Included from line number %lu", - (unsigned long) ref->lineno); + "Included from line number " + HOST_WIDE_INT_PRINT_UNSIGNED, + ref->lineno); dw2_asm_output_data_uleb128 (file_num, "file %s", ref->info); break; case DW_MACINFO_end_file: @@ -29014,8 +29015,10 @@ output_macinfo_op (macinfo_entry *ref) dw2_asm_output_data (1, ref->code, ref->code == DW_MACINFO_define ? "Define macro" : "Undefine macro"); - dw2_asm_output_data_uleb128 (ref->lineno, "At line number %lu", - (unsigned long) ref->lineno); + dw2_asm_output_data_uleb128 (ref->lineno, + "At line number " + HOST_WIDE_INT_PRINT_UNSIGNED, + ref->lineno); dw2_asm_output_nstring (ref->info, -1, "The macro"); break; case DW_MACRO_define_strp: @@ -29047,8 +29050,10 @@ output_macinfo_op (macinfo_entry *ref) gcc_assert (node && (node->form == DW_FORM_strp || node->form == dwarf_FORM (DW_FORM_strx))); - dw2_asm_output_data_uleb128 (ref->lineno, "At line number %lu", - (unsigned long) ref->lineno); + dw2_asm_output_data_uleb128 (ref->lineno, + "At line number " + HOST_WIDE_INT_PRINT_UNSIGNED, + ref->lineno); if (node->form == DW_FORM_strp) dw2_asm_output_offset (dwarf_offset_size, node->label, debug_str_section, "The macro: \"%s\"", --- gcc/gcov-dump.cc.jj 2024-01-03 11:51:22.789852519 +0100 +++ gcc/gcov-dump.cc 2024-02-09 12:42:53.227527157 +0100 @@ -218,11 +218,11 @@ dump_gcov_file (const char *filename) /* stamp */ unsigned stamp = gcov_read_unsigned (); - printf ("%s:stamp %lu\n", filename, (unsigned long)stamp); + printf ("%s:stamp %u\n", filename, stamp); /* Checksum */ unsigned checksum = gcov_read_unsigned (); - printf ("%s:checksum %lu\n", filename, (unsigned long)checksum); + printf ("%s:checksum %u\n", filename, checksum); if (!is_data_type) { --- gcc/tree-ssa-dom.cc.jj 2024-01-03 11:51:24.536828272 +0100 +++ gcc/tree-ssa-dom.cc 2024-02-09 13:16:26.529483473 +0100 @@ -1482,9 +1482,10 @@ record_equivalences_from_incoming_edge ( static void htab_statistics (FILE *file, const hash_table &htab) { - fprintf (file, "size %ld, %ld elements, %f collision/search ratio\n", - (long) htab.size (), - (long) htab.elements (), + fprintf (file, "size " HOST_SIZE_T_PRINT_DEC ", " HOST_SIZE_T_PRINT_DEC + " elements, %f collision/search ratio\n", + (fmt_size_t) htab.size (), + (fmt_size_t) htab.elements (), htab.collisions ()); } --- gcc/cfgexpand.cc.jj 2024-02-09 11:08:18.803739218 +0100 +++ gcc/cfgexpand.cc 2024-02-09 12:08:11.826537416 +0100 @@ -1024,7 +1024,8 @@ dump_stack_var_partition (void) if (stack_vars[i].representative != i) continue; - fprintf (dump_file, "Partition %lu: size ", (unsigned long) i); + fprintf (dump_file, "Partition " HOST_SIZE_T_PRINT_UNSIGNED ": size ", + (fmt_size_t) i); print_dec (stack_vars[i].size, dump_file); fprintf (dump_file, " align %u\n", stack_vars[i].alignb); --- gcc/c/c-decl.cc.jj 2024-02-05 18:53:51.602936388 +0100 +++ gcc/c/c-decl.cc 2024-02-09 13:20:19.067259157 +0100 @@ -6236,7 +6236,7 @@ get_parm_array_spec (const struct c_parm index. */ HOST_WIDE_INT n = tree_to_shwi (max) + 1; char buf[40]; - sprintf (buf, "%lu", (unsigned long)n); + sprintf (buf, HOST_WIDE_INT_PRINT_UNSIGNED, n); spec += buf; } continue; @@ -6309,7 +6309,7 @@ get_parm_array_spec (const struct c_parm char buf[40]; unsigned HOST_WIDE_INT n = tree_to_uhwi (nelts); - sprintf (buf, "%llu", (unsigned long long)n); + sprintf (buf, HOST_WIDE_INT_PRINT_UNSIGNED, n); spec += buf; break; } --- gcc/c-family/c-ada-spec.cc.jj 2024-01-17 10:34:45.178663167 +0100 +++ gcc/c-family/c-ada-spec.cc 2024-02-09 13:21:27.586318355 +0100 @@ -1852,7 +1852,8 @@ dump_template_types (pretty_printer *buf if (!dump_ada_node (buffer, elem, NULL_TREE, spc, false, true)) { pp_string (buffer, "unknown"); - pp_scalar (buffer, "%lu", (unsigned long) TREE_HASH (elem)); + pp_scalar (buffer, HOST_SIZE_T_PRINT_UNSIGNED, + (fmt_size_t) TREE_HASH (elem)); } } } --- gcc/jit/jit-playback.cc.jj 2024-02-02 22:13:29.307363148 +0100 +++ gcc/jit/jit-playback.cc 2024-02-09 13:40:25.347671757 +0100 @@ -1602,11 +1602,11 @@ new_bitcast (location *loc, { active_playback_ctxt->add_error (loc, "bitcast with types of different sizes"); - fprintf (stderr, "input expression (size: %ld):\n", - (long) tree_to_uhwi (expr_size)); + fprintf (stderr, "input expression (size: " HOST_WIDE_INT_PRINT_DEC "):\n", + tree_to_uhwi (expr_size)); debug_tree (t_expr); - fprintf (stderr, "requested type (size: %ld):\n", - (long) tree_to_uhwi (type_size)); + fprintf (stderr, "requested type (size: " HOST_WIDE_INT_PRINT_DEC "):\n", + tree_to_uhwi (type_size)); debug_tree (t_dst_type); } tree t_bitcast = build1 (VIEW_CONVERT_EXPR, t_dst_type, t_expr); --- gcc/gengtype.cc.jj 2024-01-17 11:21:09.470514694 +0100 +++ gcc/gengtype.cc 2024-02-09 21:28:42.792433561 +0100 @@ -1294,8 +1294,9 @@ adjust_field_rtx_def (type_p t, options_ { error_at_line (&lexer_line, - "rtx type `%s' has `0' in position %lu, can't handle", - rtx_name[i], (unsigned long) aindex); + "rtx type `%s' has `0' in position " + HOST_SIZE_T_PRINT_UNSIGNED ", can't handle", + rtx_name[i], (fmt_size_t) aindex); t = &string_type; subname = "rt_int"; } @@ -1333,9 +1334,10 @@ adjust_field_rtx_def (type_p t, options_ default: error_at_line (&lexer_line, - "rtx type `%s' has `%c' in position %lu, can't handle", + "rtx type `%s' has `%c' in position " + HOST_SIZE_T_PRINT_UNSIGNED ", can't handle", rtx_name[i], rtx_format[i][aindex], - (unsigned long) aindex); + (fmt_size_t) aindex); t = &string_type; subname = "rt_int"; break; --- gcc/tree-into-ssa.cc.jj 2024-01-17 11:21:09.469514708 +0100 +++ gcc/tree-into-ssa.cc 2024-02-09 13:15:38.583151380 +0100 @@ -1707,9 +1707,10 @@ debug_tree_ssa (void) static void htab_statistics (FILE *file, const hash_table &htab) { - fprintf (file, "size %ld, %ld elements, %f collision/search ratio\n", - (long) htab.size (), - (long) htab.elements (), + fprintf (file, "size " HOST_SIZE_T_PRINT_DEC ", " HOST_SIZE_T_PRINT_DEC + " elements, %f collision/search ratio\n", + (fmt_size_t) htab.size (), + (fmt_size_t) htab.elements (), htab.collisions ()); } --- gcc/postreload-gcse.cc.jj 2024-01-03 11:51:29.700756602 +0100 +++ gcc/postreload-gcse.cc 2024-02-09 13:03:46.087076550 +0100 @@ -487,9 +487,10 @@ static void dump_hash_table (FILE *file) { fprintf (file, "\n\nexpression hash table\n"); - fprintf (file, "size %ld, %ld elements, %f collision/search ratio\n", - (long) expr_table->size (), - (long) expr_table->elements (), + fprintf (file, "size " HOST_SIZE_T_PRINT_DEC ", " HOST_SIZE_T_PRINT_DEC + " elements, %f collision/search ratio\n", + (fmt_size_t) expr_table->size (), + (fmt_size_t) expr_table->elements (), expr_table->collisions ()); if (!expr_table->is_empty ()) { --- gcc/ggc-page.cc.jj 2024-01-03 11:51:39.237624239 +0100 +++ gcc/ggc-page.cc 2024-02-09 13:48:31.212953474 +0100 @@ -940,8 +940,9 @@ alloc_page (unsigned order) if (GGC_DEBUG_LEVEL >= 2) fprintf (G.debug_file, - "Allocating page at %p, object size=%lu, data %p-%p\n", - (void *) entry, (unsigned long) OBJECT_SIZE (order), + "Allocating page at %p, object size=" + HOST_SIZE_T_PRINT_UNSIGNED ", data %p-%p\n", + (void *) entry, (fmt_size_t) OBJECT_SIZE (order), (void *) page, (void *) (page + entry_size - 1)); return entry; @@ -1448,8 +1449,10 @@ ggc_internal_alloc (size_t size, void (* if (GGC_DEBUG_LEVEL >= 3) fprintf (G.debug_file, - "Allocating object, requested size=%lu, actual=%lu at %p on %p\n", - (unsigned long) size, (unsigned long) object_size, result, + "Allocating object, requested size=" + HOST_SIZE_T_PRINT_UNSIGNED ", actual=" HOST_SIZE_T_PRINT_UNSIGNED + " at %p on %p\n", + (fmt_size_t) size, (fmt_size_t) object_size, result, (void *) entry); return result; @@ -1621,8 +1624,9 @@ ggc_free (void *p) if (GGC_DEBUG_LEVEL >= 3) fprintf (G.debug_file, - "Freeing object, actual size=%lu, at %p on %p\n", - (unsigned long) size, p, (void *) pe); + "Freeing object, actual size=" + HOST_SIZE_T_PRINT_UNSIGNED ", at %p on %p\n", + (fmt_size_t) size, p, (void *) pe); #ifdef ENABLE_GC_CHECKING /* Poison the data, to indicate the data is garbage. */ --- gcc/fortran/trans-common.cc.jj 2024-01-03 12:07:07.077665411 +0100 +++ gcc/fortran/trans-common.cc 2024-02-09 13:39:00.610843452 +0100 @@ -409,10 +409,10 @@ build_common_decl (gfc_common_head *com, if (!tree_int_cst_equal (DECL_SIZE_UNIT (decl), size) && strcmp (com->name, BLANK_COMMON_NAME)) gfc_warning (0, "Named COMMON block %qs at %L shall be of the " - "same size as elsewhere (%lu vs %lu bytes)", com->name, + "same size as elsewhere (%wu vs %wu bytes)", com->name, &com->where, - (unsigned long) TREE_INT_CST_LOW (size), - (unsigned long) TREE_INT_CST_LOW (DECL_SIZE_UNIT (decl))); + TREE_INT_CST_LOW (size), + TREE_INT_CST_LOW (DECL_SIZE_UNIT (decl))); if (tree_int_cst_lt (DECL_SIZE_UNIT (decl), size)) { --- gcc/fortran/resolve.cc.jj 2024-01-03 12:07:05.943681297 +0100 +++ gcc/fortran/resolve.cc 2024-02-09 13:38:30.753256308 +0100 @@ -11291,8 +11291,8 @@ resolve_ordinary_assign (gfc_code *code, if (rlen && llen && rlen > llen) gfc_warning_now (OPT_Wcharacter_truncation, "CHARACTER expression will be truncated " - "in assignment (%ld/%ld) at %L", - (long) llen, (long) rlen, &code->loc); + "in assignment (%wd/%wd) at %L", + llen, rlen, &code->loc); } /* Ensure that a vector index expression for the lvalue is evaluated --- gcc/fortran/array.cc.jj 2024-01-15 09:56:49.488545789 +0100 +++ gcc/fortran/array.cc 2024-02-09 13:31:13.994266679 +0100 @@ -2212,9 +2212,9 @@ got_charlen: found_length = current_length; else if (found_length != current_length) { - gfc_error ("Different CHARACTER lengths (%ld/%ld) in array" - " constructor at %L", (long) found_length, - (long) current_length, &p->expr->where); + gfc_error ("Different CHARACTER lengths (%wd/%wd) in array" + " constructor at %L", found_length, + current_length, &p->expr->where); return false; } --- gcc/fortran/data.cc.jj 2024-01-03 12:07:06.368675343 +0100 +++ gcc/fortran/data.cc 2024-02-09 13:33:35.489323884 +0100 @@ -209,8 +209,8 @@ create_character_initializer (gfc_expr * else { gfc_warning_now (0, "Initialization string at %L was truncated to " - "fit the variable (%ld/%ld)", &rvalue->where, - (long) tlen, (long) len); + "fit the variable (%wd/%wd)", &rvalue->where, + tlen, len); len = tlen; } } --- gcc/genpreds.cc.jj 2024-01-03 11:51:22.724853421 +0100 +++ gcc/genpreds.cc 2024-02-09 12:57:02.393699795 +0100 @@ -1095,9 +1095,10 @@ write_lookup_constraint_1 (void) do { if (c->namelen > 2) - printf (" if (!strncmp (str + 1, \"%s\", %lu))\n" + printf (" if (!strncmp (str + 1, \"%s\", " + HOST_SIZE_T_PRINT_UNSIGNED "))\n" " return CONSTRAINT_%s;\n", - c->name + 1, (unsigned long int) c->namelen - 1, + c->name + 1, (fmt_size_t) (c->namelen - 1), c->c_name); else printf (" if (str[1] == '%c')\n" @@ -1174,8 +1175,8 @@ write_insn_constraint_len (void) } } - printf (" case '%c': return %lu;\n", - i, (unsigned long int) c->namelen); + printf (" case '%c': return " HOST_SIZE_T_PRINT_UNSIGNED ";\n", + i, (fmt_size_t) c->namelen); } puts (" default: break;\n" --- gcc/tree-dfa.cc.jj 2024-01-03 11:51:27.847782320 +0100 +++ gcc/tree-dfa.cc 2024-02-09 13:14:56.611736051 +0100 @@ -230,9 +230,10 @@ dump_dfa_stats (FILE *file) fprintf (file, "\n"); if (dfa_stats.num_phis) - fprintf (file, "Average number of arguments per PHI node: %.1f (max: %ld)\n", + fprintf (file, "Average number of arguments per PHI node: %.1f (max: " + HOST_SIZE_T_PRINT_DEC ")\n", (float) dfa_stats.num_phi_args / (float) dfa_stats.num_phis, - (long) dfa_stats.max_num_phi_args); + (fmt_size_t) dfa_stats.max_num_phi_args); fprintf (file, "\n"); } --- gcc/varasm.cc.jj 2024-02-01 09:13:53.596871319 +0100 +++ gcc/varasm.cc 2024-02-09 13:17:39.461467529 +0100 @@ -4365,7 +4365,7 @@ output_constant_pool_contents (struct rt p = label; if (desc->offset) { - sprintf (buffer, "%s+%ld", p, (long) (desc->offset)); + sprintf (buffer, "%s+" HOST_WIDE_INT_PRINT_DEC, p, desc->offset); p = buffer; } ASM_OUTPUT_DEF (asm_out_file, name, p); --- gcc/var-tracking.cc.jj 2024-01-03 11:51:27.944780973 +0100 +++ gcc/var-tracking.cc 2024-02-09 13:19:00.820334190 +0100 @@ -7335,8 +7335,8 @@ dump_var (variable *var) for (i = 0; i < var->n_var_parts; i++) { - fprintf (dump_file, " offset %ld\n", - (long)(var->onepart ? 0 : VAR_PART_OFFSET (var, i))); + fprintf (dump_file, " offset " HOST_WIDE_INT_PRINT_DEC "\n", + var->onepart ? 0 : VAR_PART_OFFSET (var, i)); for (node = var->var_part[i].loc_chain; node; node = node->next) { fprintf (dump_file, " "); --- gcc/lto/lto-common.cc.jj 2024-01-03 12:07:08.367647338 +0100 +++ gcc/lto/lto-common.cc 2024-02-09 13:43:37.416015946 +0100 @@ -3021,10 +3021,10 @@ print_lto_report_1 (void) total_scc_size + num_unshared_trees_read); if (flag_wpa && tree_scc_hash && num_sccs_read) { - fprintf (stderr, "[%s] tree SCC table: size %ld, %ld elements, " - "collision ratio: %f\n", pfx, - (long) tree_scc_hash->size (), - (long) tree_scc_hash->elements (), + fprintf (stderr, "[%s] tree SCC table: size " HOST_SIZE_T_PRINT_DEC ", " + HOST_SIZE_T_PRINT_DEC " elements, collision ratio: %f\n", pfx, + (fmt_size_t) tree_scc_hash->size (), + (fmt_size_t) tree_scc_hash->elements (), tree_scc_hash->collisions ()); hash_table::iterator hiter; tree_scc *scc, *max_scc = NULL; @@ -3052,12 +3052,13 @@ print_lto_report_1 (void) fprintf (stderr, "[%s] Merged %lu types\n", pfx, num_merged_types); fprintf (stderr, "[%s] %lu types prevailed (%lu associated trees)\n", pfx, num_prevailing_types, num_type_scc_trees); - fprintf (stderr, "[%s] GIMPLE canonical type table: size %ld, " - "%ld elements, %ld searches, %ld collisions (ratio: %f)\n", pfx, - (long) htab_size (gimple_canonical_types), - (long) htab_elements (gimple_canonical_types), - (long) gimple_canonical_types->searches, - (long) gimple_canonical_types->collisions, + fprintf (stderr, "[%s] GIMPLE canonical type table: size " + HOST_SIZE_T_PRINT_DEC ", " HOST_SIZE_T_PRINT_DEC + " elements, %d searches, %d collisions (ratio: %f)\n", pfx, + (fmt_size_t) htab_size (gimple_canonical_types), + (fmt_size_t) htab_elements (gimple_canonical_types), + gimple_canonical_types->searches, + gimple_canonical_types->collisions, htab_collisions (gimple_canonical_types)); fprintf (stderr, "[%s] GIMPLE canonical type pointer-map: " "%lu elements, %ld searches\n", pfx,