https://gcc.gnu.org/g:aa8c47a4ebe3cec45f3ea9a330b54f7f15ca3bdc
commit r17-6362-gaa8c47a4ebe3cec45f3ea9a330b54f7f15ca3bdc Author: Oleg Tolmatcev <[email protected]> Date: Wed Nov 11 20:44:30 2026 +0100 analyzer: Fix warnings on LLP64 hosts The analyzer printed 64-bit location_t values with %lx, which -Wformat rejects on LLP64 hosts such as x86_64-w64-mingw32. Use %wx, the pretty-printer's directive for HOST_WIDE_INT. Likewise print a size_t index with HOST_SIZE_T_PRINT_UNSIGNED instead of %lu. Also drop an unused variable and use the otherwise unused fn_result in interprocedural_return::try_to_rewind_data_flow. An analyzer logging call printed a size_t with %li, which -Wformat rejects on LLP64 hosts such as x86_64-w64-mingw32. Use %zu. Also make a loop index unsigned to match the vector size it is compared against. gcc/analyzer/ChangeLog: * diagnostic-manager.cc (diagnostic_manager::annotate_exploded_path): Make idx unsigned and print it with %u. * engine.cc (leak_ploc_fixer_for_epath::fixup_for_epath): Print location_t with %wx. Add missing "x" to "0x" prefix. (interprocedural_return::try_to_rewind_data_flow): Remove unused logger. Use fn_result. (strongly_connected_components::dump): Print index with HOST_SIZE_T_PRINT_UNSIGNED. * supergraph.cc (supergraph::populate_for_basic_block): Print location_t with %wx. (supernode::dump_dot): Likewise. (superedge::dump_label_to_pp): Likewise. * supergraph-fixup-locations.cc (location_fixer::consider_node): Likewise. * supergraph-sorting.cc (supergraph::reorder_nodes_and_ids): Print size_t with %zu. Signed-off-by: Oleg Tolmatcev <[email protected]> Diff: --- gcc/analyzer/diagnostic-manager.cc | 4 ++-- gcc/analyzer/engine.cc | 14 +++++++------- gcc/analyzer/supergraph-fixup-locations.cc | 2 +- gcc/analyzer/supergraph-sorting.cc | 2 +- gcc/analyzer/supergraph.cc | 10 +++++----- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gcc/analyzer/diagnostic-manager.cc b/gcc/analyzer/diagnostic-manager.cc index f117fee4e217..9387fc447bc6 100644 --- a/gcc/analyzer/diagnostic-manager.cc +++ b/gcc/analyzer/diagnostic-manager.cc @@ -1915,11 +1915,11 @@ diagnostic_manager::annotate_exploded_path (const path_builder &pb, rewind state. */ std::vector<region_model> src_models; std::vector<region_model> dst_models; - for (int idx = 0; idx < epath.m_elements.size (); ++idx) + for (unsigned int idx = 0; idx < epath.m_elements.size (); ++idx) { auto eedge = epath.m_elements[idx].m_eedge; if (logger) - logger->log ("edge[%i]: considering EN %i -> EN %i", + logger->log ("edge[%u]: considering EN %i -> EN %i", idx, eedge->m_src->m_index, eedge->m_dest->m_index); diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index fd4c059b3501..790d940ba7de 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -328,7 +328,7 @@ public: && SSA_NAME_VAR (lhs) == SSA_NAME_VAR (m_var)) { if (logger) - logger->log ("using location 0%lx from gassign", + logger->log ("using location 0x%wx from gassign", assign->location); ploc.m_event_loc_info.m_loc = assign->location; return; @@ -386,7 +386,7 @@ public: if (useful_location_p (stmt->location)) { if (logger) - logger->log ("using location 0x%lx from stmt", + logger->log ("using location 0x%wx from stmt", stmt->location); ploc.m_event_loc_info.m_loc = stmt->location; return; @@ -1801,8 +1801,6 @@ interprocedural_return::add_events_to_path (checker_path *emission_path, bool interprocedural_return::try_to_rewind_data_flow (rewind_context &ctxt) const { - auto logger = ctxt.m_logger; - tree lhs = gimple_call_lhs (&m_call_stmt); if (!lhs) return true; @@ -1811,7 +1809,7 @@ interprocedural_return::try_to_rewind_data_flow (rewind_context &ctxt) const tree fndecl = src_enode_model.get_current_function ()->decl; tree fn_result = DECL_RESULT (fndecl); - ctxt.on_data_flow (DECL_RESULT (fndecl), lhs); + ctxt.on_data_flow (fn_result, lhs); return true; } @@ -2199,8 +2197,10 @@ strongly_connected_components::dump () const for (size_t i = 0; i < m_sg.m_nodes.length (); i++) { const per_node_data &v = m_per_node[i]; - fprintf (stderr, "SN %lu: index: %i lowlink: %i on_stack: %i\n", - i, v.m_id, v.m_lowlink, v.m_on_stack); + fprintf (stderr, + "SN " HOST_SIZE_T_PRINT_UNSIGNED + ": index: %i lowlink: %i on_stack: %i\n", + (fmt_size_t) i, v.m_id, v.m_lowlink, v.m_on_stack); } } diff --git a/gcc/analyzer/supergraph-fixup-locations.cc b/gcc/analyzer/supergraph-fixup-locations.cc index 54555164692a..d03714872f75 100644 --- a/gcc/analyzer/supergraph-fixup-locations.cc +++ b/gcc/analyzer/supergraph-fixup-locations.cc @@ -75,7 +75,7 @@ public: node->m_loc = in_edge->m_src->m_loc; m_stats.m_num_copies++; if (m_logger) - m_logger->log ("copying location 0x%lx from SN %i to SN %i", + m_logger->log ("copying location 0x%wx from SN %i to SN %i", node->m_loc, in_edge->m_src->m_id, node->m_id); for (auto out_edge : node->m_succs) diff --git a/gcc/analyzer/supergraph-sorting.cc b/gcc/analyzer/supergraph-sorting.cc index 2d87e26685a1..6af5d9097142 100644 --- a/gcc/analyzer/supergraph-sorting.cc +++ b/gcc/analyzer/supergraph-sorting.cc @@ -54,7 +54,7 @@ supergraph::reorder_nodes_and_ids (const std::vector<supernode *> &ordering, if ((size_t)snode->m_id == new_id) logger->log ("SN %i is unchanged", snode->m_id); else - logger->log ("old SN %i is now SN %li", snode->m_id, new_id); + logger->log ("old SN %i is now SN %zu", snode->m_id, new_id); } m_nodes.safe_push (snode); snode->m_id = new_id; diff --git a/gcc/analyzer/supergraph.cc b/gcc/analyzer/supergraph.cc index b9b5e70795a1..254c9423393c 100644 --- a/gcc/analyzer/supergraph.cc +++ b/gcc/analyzer/supergraph.cc @@ -251,7 +251,7 @@ supergraph::populate_for_basic_block (basic_block bb, /* We have an empty basic block with one out-edge, perhaps part of an empty infinite loop. */ if (logger) - logger->log ("using location 0x%lx from outedge", + logger->log ("using location 0x%wx from outedge", outedge->goto_locus); initial_snode_in_bb->m_loc = outedge->goto_locus; } @@ -1007,7 +1007,7 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const pp_string (pp, "<TR><TD>UNKNOWN_LOCATION</TD></TR>"); else if (get_pure_location (m_loc) == UNKNOWN_LOCATION) { - pp_printf (pp, "<TR><TD>location: 0x%lx</TD></TR>", m_loc); + pp_printf (pp, "<TR><TD>location: 0x%wx</TD></TR>", m_loc); pp_string (pp, "<TR><TD>UNKNOWN_LOCATION</TD></TR>"); } else @@ -1024,7 +1024,7 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const } if (show_location) { - pp_printf (pp, "<TR><TD>location: 0x%lx</TD></TR>", m_loc); + pp_printf (pp, "<TR><TD>location: 0x%wx</TD></TR>", m_loc); /* Print changes to the expanded location (or all of it if we have multiple in-edges). */ @@ -1074,7 +1074,7 @@ supernode::dump_dot (graphviz_out *gv, const dump_args_t &args) const if (args.m_node_annotator) args.m_node_annotator->add_node_annotations (gv, *this); - pp_printf (pp, "<TR><TD>m_stmt_loc: 0x%lx</TD></TR>", m_stmt_loc); + pp_printf (pp, "<TR><TD>m_stmt_loc: 0x%wx</TD></TR>", m_stmt_loc); pp_string (pp, "</TABLE>>];\n\n"); pp_flush (pp); @@ -1260,7 +1260,7 @@ superedge::dump_label_to_pp (pretty_printer *pp, bool user_facing) const pp_string (pp, ")"); } if (cfg_edge->goto_locus > BUILTINS_LOCATION) - pp_printf (pp, " (has goto_locus: 0x%lx)", cfg_edge->goto_locus); + pp_printf (pp, " (has goto_locus: 0x%wx)", cfg_edge->goto_locus); } }
