The analyzer printed 64-bit location_t values and size_t values with
%lx, %lu and %li.  On LLP64 hosts such as x86_64-w64-mingw32, long is
32 bits, so -Wformat rejects these and the bootstrap fails with -Werror.

Print location_t with the pretty-printer's %wx, which already emits the
"0x" prefix, so drop the literal one.  Print size_t with %zu in
pretty-printer formats and with HOST_SIZE_T_PRINT_UNSIGNED in the raw
fprintf.  Make two loop indices unsigned to match the unsigned lengths
they are compared against.

Also drop an unused variable and use the otherwise unused fn_result in
interprocedural_return::try_to_rewind_data_flow.

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 and drop the redundant "0x" prefix.
        (interprocedural_return::try_to_rewind_data_flow): Remove unused
        logger.  Use fn_result.
        (exploded_graph_diagnostic_digraph::add_node_for_enode): Make loop
        index unsigned.
        (strongly_connected_components::dump): Print index with
        HOST_SIZE_T_PRINT_UNSIGNED.
        * supergraph.cc (supergraph::populate_for_basic_block): Print
        location_t with %wx and drop the redundant "0x" prefix.
        (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]>
---
 gcc/analyzer/diagnostic-manager.cc         |  4 ++--
 gcc/analyzer/engine.cc                     | 16 ++++++++--------
 gcc/analyzer/supergraph-fixup-locations.cc |  2 +-
 gcc/analyzer/supergraph-sorting.cc         |  2 +-
 gcc/analyzer/supergraph.cc                 | 10 +++++-----
 5 files changed, 17 insertions(+), 17 deletions(-)

Addressed issues found by Sashiko.

diff --git a/gcc/analyzer/diagnostic-manager.cc 
b/gcc/analyzer/diagnostic-manager.cc
index 2e7acba091..8e016d9a6e 100644
--- a/gcc/analyzer/diagnostic-manager.cc
+++ b/gcc/analyzer/diagnostic-manager.cc
@@ -1910,11 +1910,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 a42350531b..295a4ae9d5 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 %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 %wx from stmt",
                                       stmt->location);
                        ploc.m_event_loc_info.m_loc = stmt->location;
                        return;
@@ -1792,8 +1792,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;
@@ -1802,7 +1800,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;
 }
@@ -1993,7 +1991,7 @@ private:
 
     auto &cs = point.get_call_string ();
     auto cs_arr = std::make_unique<json::array> ();
-    for (int i = 0; i < cs.length (); ++i)
+    for (unsigned int i = 0; i < cs.length (); ++i)
       {
        auto e = cs[i];
        auto obj = std::make_unique<json::object> ();
@@ -2190,8 +2188,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 5455516469..201da64c03 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 %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 2d87e26685..6af5d90971 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 b9b5e70795..9506933aa6 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 %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: %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: %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: %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: %wx)", cfg_edge->goto_locus);
     }
 }
 
-- 
2.56.0.windows.4

Reply via email to