public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8908] Use HOST_SIZE_T_PRINT_* and HOST_WIDE_INT_T_PRINT_* some more
@ 2024-02-10 10:28 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2024-02-10 10:28 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:89e93ce8b9a6e5d5ee2d6c469b3bc8c9b62ef579

commit r14-8908-g89e93ce8b9a6e5d5ee2d6c469b3bc8c9b62ef579
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Feb 10 11:26:26 2024 +0100

    Use HOST_SIZE_T_PRINT_* and HOST_WIDE_INT_T_PRINT_* some more
    
    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.
    
    2024-02-10  Jakub Jelinek  <jakub@redhat.com>
    
    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.

Diff:
---
 gcc/c-family/c-ada-spec.cc  |  3 ++-
 gcc/c/c-decl.cc             |  4 ++--
 gcc/cfgexpand.cc            |  3 ++-
 gcc/cp/class.cc             | 14 +++++++-------
 gcc/cp/parser.cc            |  3 ++-
 gcc/cp/pt.cc                | 14 ++++++++------
 gcc/cp/tree.cc              |  5 +++--
 gcc/dwarf2out.cc            | 17 +++++++++++------
 gcc/fortran/array.cc        |  6 +++---
 gcc/fortran/data.cc         |  4 ++--
 gcc/fortran/resolve.cc      |  4 ++--
 gcc/fortran/trans-common.cc |  6 +++---
 gcc/gcov-dump.cc            |  4 ++--
 gcc/gengtype.cc             | 10 ++++++----
 gcc/genpreds.cc             |  9 +++++----
 gcc/ggc-page.cc             | 16 ++++++++++------
 gcc/ipa-icf.cc              | 10 ++++++----
 gcc/jit/jit-playback.cc     |  8 ++++----
 gcc/lto/lto-common.cc       | 21 +++++++++++----------
 gcc/postreload-gcse.cc      |  7 ++++---
 gcc/tree-dfa.cc             |  5 +++--
 gcc/tree-into-ssa.cc        |  7 ++++---
 gcc/tree-ssa-dom.cc         |  7 ++++---
 gcc/tree.cc                 | 21 ++++++++++++---------
 gcc/var-tracking.cc         |  4 ++--
 gcc/varasm.cc               |  2 +-
 26 files changed, 121 insertions(+), 93 deletions(-)

diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc
index 4b245ed69754..e56ef10f443a 100644
--- a/gcc/c-family/c-ada-spec.cc
+++ b/gcc/c-family/c-ada-spec.cc
@@ -1852,7 +1852,8 @@ dump_template_types (pretty_printer *buffer, tree types, int spc)
       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));
 	}
     }
 }
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index fe20bc21c926..c747abe9f4ef 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -6236,7 +6236,7 @@ get_parm_array_spec (const struct c_parm *parm, tree attrs)
 		     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 *parm, tree attrs)
 
 	  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;
 	}
diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
index 027e2844a7ea..d36dfc842e15 100644
--- a/gcc/cfgexpand.cc
+++ b/gcc/cfgexpand.cc
@@ -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);
 
diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index 556943c3e551..5f258729940b 100644
--- a/gcc/cp/class.cc
+++ b/gcc/cp/class.cc
@@ -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");
 }
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 09ecfa23b5dd..54f70133778e 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -1310,7 +1310,8 @@ cp_lexer_peek_nth_token (cp_lexer* lexer, size_t n)
 
   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;
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 9c225c095c81..475f2181cc49 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -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 ());
 }
 
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 50dc345ec9af..ad312710f687 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -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);
     }
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 4b09c353365e..5d64100b95c5 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -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\"",
diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc
index 81fa99d219fd..3a6e3a7c95bc 100644
--- a/gcc/fortran/array.cc
+++ b/gcc/fortran/array.cc
@@ -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;
 	    }
 
diff --git a/gcc/fortran/data.cc b/gcc/fortran/data.cc
index deed2d3ca23c..70247490e471 100644
--- a/gcc/fortran/data.cc
+++ b/gcc/fortran/data.cc
@@ -209,8 +209,8 @@ create_character_initializer (gfc_expr *init, gfc_typespec *ts,
       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;
 	}
     }
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 6148ed94fe13..44f89f6afb4f 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -11291,8 +11291,8 @@ resolve_ordinary_assign (gfc_code *code, gfc_namespace *ns)
       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
diff --git a/gcc/fortran/trans-common.cc b/gcc/fortran/trans-common.cc
index 4fc9652a7142..5f44e7bd663d 100644
--- a/gcc/fortran/trans-common.cc
+++ b/gcc/fortran/trans-common.cc
@@ -409,10 +409,10 @@ build_common_decl (gfc_common_head *com, tree union_type, bool is_init)
       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))
 	{
diff --git a/gcc/gcov-dump.cc b/gcc/gcov-dump.cc
index 167b6f508f6b..2ff352bc766a 100644
--- a/gcc/gcov-dump.cc
+++ b/gcc/gcov-dump.cc
@@ -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)
     {
diff --git a/gcc/gengtype.cc b/gcc/gengtype.cc
index 6623acca2377..b1db727b9581 100644
--- a/gcc/gengtype.cc
+++ b/gcc/gengtype.cc
@@ -1294,8 +1294,9 @@ adjust_field_rtx_def (type_p t, options_p ARG_UNUSED (opt))
 		{
 		  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_p ARG_UNUSED (opt))
 	    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;
diff --git a/gcc/genpreds.cc b/gcc/genpreds.cc
index 230a4748efa0..55d149e8a404 100644
--- a/gcc/genpreds.cc
+++ b/gcc/genpreds.cc
@@ -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"
diff --git a/gcc/ggc-page.cc b/gcc/ggc-page.cc
index fa90dff58550..4245f843a29f 100644
--- a/gcc/ggc-page.cc
+++ b/gcc/ggc-page.cc
@@ -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 (*f)(void *), size_t s, size_t n
 
   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.  */
diff --git a/gcc/ipa-icf.cc b/gcc/ipa-icf.cc
index 29ed1f1e4c13..f56891325f3d 100644
--- a/gcc/ipa-icf.cc
+++ b/gcc/ipa-icf.cc
@@ -3191,8 +3191,9 @@ sem_item_optimizer::process_cong_reduction (void)
 	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 (void)
       }
 
   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");
diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
index e277b0132596..6baa838af10a 100644
--- a/gcc/jit/jit-playback.cc
+++ b/gcc/jit/jit-playback.cc
@@ -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);
diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc
index 11e7d63f1bec..e54ddf2ca410 100644
--- a/gcc/lto/lto-common.cc
+++ b/gcc/lto/lto-common.cc
@@ -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<tree_scc_hasher>::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,
diff --git a/gcc/postreload-gcse.cc b/gcc/postreload-gcse.cc
index 84e4f89bebac..141b5aea3243 100644
--- a/gcc/postreload-gcse.cc
+++ b/gcc/postreload-gcse.cc
@@ -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 ())
     {
diff --git a/gcc/tree-dfa.cc b/gcc/tree-dfa.cc
index 2acd31883a45..cbd3774b21f5 100644
--- a/gcc/tree-dfa.cc
+++ b/gcc/tree-dfa.cc
@@ -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");
 }
diff --git a/gcc/tree-into-ssa.cc b/gcc/tree-into-ssa.cc
index 242b11b29ca9..d12a4a97f651 100644
--- a/gcc/tree-into-ssa.cc
+++ b/gcc/tree-into-ssa.cc
@@ -1707,9 +1707,10 @@ debug_tree_ssa (void)
 static void
 htab_statistics (FILE *file, const hash_table<var_info_hasher> &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 ());
 }
 
diff --git a/gcc/tree-ssa-dom.cc b/gcc/tree-ssa-dom.cc
index d8f43585a40a..73264852ebd9 100644
--- a/gcc/tree-ssa-dom.cc
+++ b/gcc/tree-ssa-dom.cc
@@ -1482,9 +1482,10 @@ record_equivalences_from_incoming_edge (basic_block bb,
 static void
 htab_statistics (FILE *file, const hash_table<expr_elt_hasher> &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 ());
 }
 
diff --git a/gcc/tree.cc b/gcc/tree.cc
index 3dff8c510832..046a558d1b07 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -5882,9 +5882,10 @@ decl_fini_priority_insert (tree decl, priority_type priority)
 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, tree type)
 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 ());
 }
 
diff --git a/gcc/var-tracking.cc b/gcc/var-tracking.cc
index fd3aafb64183..08174669c269 100644
--- a/gcc/var-tracking.cc
+++ b/gcc/var-tracking.cc
@@ -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, "      ");
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index fa17eff551e8..008d9b133032 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -4365,7 +4365,7 @@ output_constant_pool_contents (struct rtx_constant_pool *pool)
 	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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-10 10:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-10 10:28 [gcc r14-8908] Use HOST_SIZE_T_PRINT_* and HOST_WIDE_INT_T_PRINT_* some more Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).