aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-02-10 11:26:26 +0100
committerJakub Jelinek <jakub@redhat.com>2024-02-10 11:26:26 +0100
commit89e93ce8b9a6e5d5ee2d6c469b3bc8c9b62ef579 (patch)
tree4404d7b2d7630314bcf260953d32dc8e769d93ed /gcc/cp
parent48207a5f00d6ae7cb11038e7c17f6858de4a884e (diff)
downloadgcc-89e93ce8b9a6e5d5ee2d6c469b3bc8c9b62ef579.zip
gcc-89e93ce8b9a6e5d5ee2d6c469b3bc8c9b62ef579.tar.gz
gcc-89e93ce8b9a6e5d5ee2d6c469b3bc8c9b62ef579.tar.bz2
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.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/class.cc14
-rw-r--r--gcc/cp/parser.cc3
-rw-r--r--gcc/cp/pt.cc14
-rw-r--r--gcc/cp/tree.cc5
4 files changed, 20 insertions, 16 deletions
diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index 556943c..5f25872 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 09ecfa2..54f7013 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 9c225c0..475f218 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 50dc345..ad31271 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);
}