diff options
author | Jakub Jelinek <jakub@redhat.com> | 2024-02-10 11:26:26 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2024-02-10 11:26:26 +0100 |
commit | 89e93ce8b9a6e5d5ee2d6c469b3bc8c9b62ef579 (patch) | |
tree | 4404d7b2d7630314bcf260953d32dc8e769d93ed /gcc/fortran | |
parent | 48207a5f00d6ae7cb11038e7c17f6858de4a884e (diff) | |
download | gcc-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/fortran')
-rw-r--r-- | gcc/fortran/array.cc | 6 | ||||
-rw-r--r-- | gcc/fortran/data.cc | 4 | ||||
-rw-r--r-- | gcc/fortran/resolve.cc | 4 | ||||
-rw-r--r-- | gcc/fortran/trans-common.cc | 6 |
4 files changed, 10 insertions, 10 deletions
diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc index 81fa99d..3a6e3a7 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 deed2d3..7024749 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 6148ed9..44f89f6 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 4fc9652..5f44e7b 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)) { |