From b675f8c3a1d92df74f939f3f0f5282e57484c9cb Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 21 Jun 2019 13:10:02 -0400
Subject: [PATCH 41/47] FIXME: fixing warnings

---
 gcc/analyzer/constraint-manager.cc | 11 +----------
 gcc/analyzer/impl-2.cc             |  4 ++--
 gcc/analyzer/impl-3.cc             |  2 +-
 gcc/analyzer/impl-4.cc             |  4 ++--
 gcc/analyzer/region-model.cc       | 13 ++++++-------
 gcc/analyzer/sm-sensitive.cc       | 21 +++++++++++----------
 gcc/analyzer/sm-taint.cc           | 17 +++++++++--------
 7 files changed, 32 insertions(+), 40 deletions(-)

diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc
index 565d32b..dfd17c6 100644
--- a/gcc/analyzer/constraint-manager.cc
+++ b/gcc/analyzer/constraint-manager.cc
@@ -868,7 +868,7 @@ constraint_manager::get_or_add_equiv_class (svalue_id sid)
 
   equiv_class_id new_id (m_equiv_classes.length () - 1);
 
-  if (tree cst = maybe_get_constant (sid))
+  if (maybe_get_constant (sid))
     {
       /* If we have a new EC for a constant, add constraints comparing this
 	 to other constants we may have (so that we accumulate the transitive
@@ -1572,9 +1572,6 @@ test_constraint_conditions ()
 static void
 test_transitivity ()
 {
-  tree int_42 = build_int_cst (integer_type_node, 42);
-  tree int_0 = build_int_cst (integer_type_node, 0);
-
   tree a = build_decl (UNKNOWN_LOCATION, VAR_DECL,
 		       get_identifier ("a"),
 		       integer_type_node);
@@ -1957,18 +1954,12 @@ test_assignment ()
 static void
 test_equality ()
 {
-  tree int_42 = build_int_cst (integer_type_node, 42);
-  tree int_0 = build_int_cst (integer_type_node, 0);
-
   tree x = build_decl (UNKNOWN_LOCATION, VAR_DECL,
 		       get_identifier ("x"),
 		       integer_type_node);
   tree y = build_decl (UNKNOWN_LOCATION, VAR_DECL,
 		       get_identifier ("y"),
 		       integer_type_node);
-  tree z = build_decl (UNKNOWN_LOCATION, VAR_DECL,
-		       get_identifier ("z"),
-		       integer_type_node);
 
   {
     region_model model0;
diff --git a/gcc/analyzer/impl-2.cc b/gcc/analyzer/impl-2.cc
index e0d8ec5..ab12c1d 100644
--- a/gcc/analyzer/impl-2.cc
+++ b/gcc/analyzer/impl-2.cc
@@ -3349,7 +3349,7 @@ engine::is_valid_path (const checker_path &path)
   path.maybe_log (get_logger (), "path");
 
   path_state ps;
-  for (int idx = 0; idx < path.m_events.length (); idx++)
+  for (unsigned idx = 0; idx < path.m_events.length (); idx++)
     {
       checker_event *base_event = path.m_events[idx];
       log ("event %i: %s",
@@ -3362,7 +3362,7 @@ engine::is_valid_path (const checker_path &path)
 	case EK_STMT:
 	  {
 	    statement_event *stmt_ev = (statement_event *)base_event;
-	    const gimple *stmt = stmt_ev->m_stmt;
+	    //const gimple *stmt = stmt_ev->m_stmt;
 	    // TODO: this will largely be a duplicate of on_stmt
 	  }
 	  break;
diff --git a/gcc/analyzer/impl-3.cc b/gcc/analyzer/impl-3.cc
index 3bfd44d..9e31dfd 100644
--- a/gcc/analyzer/impl-3.cc
+++ b/gcc/analyzer/impl-3.cc
@@ -152,7 +152,7 @@ enum event_kind
   EK_WARNING
 };
 
-static const char *
+static DEBUG_FUNCTION const char *
 event_kind_to_string (enum event_kind ek)
 {
   switch (ek)
diff --git a/gcc/analyzer/impl-4.cc b/gcc/analyzer/impl-4.cc
index 411ecaa..d415ade 100644
--- a/gcc/analyzer/impl-4.cc
+++ b/gcc/analyzer/impl-4.cc
@@ -1174,7 +1174,7 @@ enum event_kind
   EK_WARNING
 };
 
-static const char *
+static DEBUG_FUNCTION const char *
 event_kind_to_string (enum event_kind ek)
 {
   switch (ek)
@@ -3925,7 +3925,7 @@ public:
 
   void emit_best (diagnostic_manager *dm,
 		  const exploded_graph &eg,
-		  const shortest_paths &sp)
+		  const shortest_paths &/*sp*/)
   {
     JIT_LOG_SCOPE (dm->get_logger ());
 
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index 53a58ff..c236537 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -516,7 +516,7 @@ POP_IGNORE_WFORMAT
 /* FIXME.  */
 
 bool
-unknown_svalue::compare_fields (const unknown_svalue &other) const
+unknown_svalue::compare_fields (const unknown_svalue &) const
 {
   /* I *think* we want to return true here, in that when comparing
      two region models, we want two peer unknown_svalue instances
@@ -1622,7 +1622,7 @@ symbolic_region::symbolic_region (const symbolic_region &other)
 /* FIXME.  */
 
 bool
-symbolic_region::compare_fields (const symbolic_region &other) const
+symbolic_region::compare_fields (const symbolic_region &) const
 {
   /* Empty.  */
   return true;
@@ -3330,7 +3330,7 @@ region_model::remap_svalue_ids (const svalue_id_map &map)
 
   /* Build a reordered svalues vector.  */
   auto_vec<svalue *> new_svalues;
-  for (int i = 0; i < m_svalues.length (); i++)
+  for (unsigned i = 0; i < m_svalues.length (); i++)
     {
       svalue_id dst (svalue_id::from_int (i));
       svalue_id src = map.get_src_for_dst (dst);
@@ -3362,7 +3362,7 @@ region_model::remap_region_ids (const region_id_map &map)
 
   /* Build a reordered regions vector.  */
   auto_vec<region *> new_regions;
-  for (int i = 0; i < m_regions.length (); i++)
+  for (unsigned i = 0; i < m_regions.length (); i++)
     {
       region_id dst (region_id::from_int (i));
       region_id src = map.get_src_for_dst (dst);
@@ -3641,9 +3641,7 @@ test_svalue_equality ()
 static void
 test_region_equality ()
 {
-  tree int_42 = build_int_cst (integer_type_node, 42);
-  tree int_0 = build_int_cst (integer_type_node, 0);
-
+#if 0
   tree x = build_decl (UNKNOWN_LOCATION, VAR_DECL,
 		       get_identifier ("x"),
 		       integer_type_node);
@@ -3653,6 +3651,7 @@ test_region_equality ()
   tree z = build_decl (UNKNOWN_LOCATION, VAR_DECL,
 		       get_identifier ("z"),
 		       integer_type_node);
+#endif
   // TODO
 
   region *r0 = new map_region (region_id::from_int (3), integer_type_node);
diff --git a/gcc/analyzer/sm-sensitive.cc b/gcc/analyzer/sm-sensitive.cc
index 6330cca..d49441f 100644
--- a/gcc/analyzer/sm-sensitive.cc
+++ b/gcc/analyzer/sm-sensitive.cc
@@ -109,7 +109,7 @@ sensitive_state_machine::on_stmt (sm_context *sm_ctxt,
 	       || is_named_call_p (call, "printf"))
 	{
 	  /* Handle a match at any position in varargs.  */
-	  for (int idx = 1; idx < gimple_call_num_args (call); idx++)
+	  for (unsigned idx = 1; idx < gimple_call_num_args (call); idx++)
 	    {
 	      tree arg = gimple_call_arg (call, idx);
 	      warn_for_any_exposure (sm_ctxt, node, stmt, arg);
@@ -129,25 +129,26 @@ sensitive_state_machine::on_stmt (sm_context *sm_ctxt,
 /* FIXME.  */
 
 void
-sensitive_state_machine::on_edge (sm_context *sm_ctxt,
-				  const gimple *last_stmt,
-				  const superedge *edge) const
+sensitive_state_machine::on_edge (sm_context *sm_ctxt ATTRIBUTE_UNUSED,
+				  const gimple *last_stmt ATTRIBUTE_UNUSED,
+				  const superedge *edge ATTRIBUTE_UNUSED) const
 {
   /* Empty.  */
 }
 
 void
-sensitive_state_machine::on_leak (sm_context *sm_ctxt,
-				  const supernode *node,
-				  const gimple *stmt,
-				  tree var,
-				  state_machine::state_t state) const
+sensitive_state_machine::on_leak (sm_context *sm_ctxt ATTRIBUTE_UNUSED,
+				  const supernode *node ATTRIBUTE_UNUSED,
+				  const gimple *stmt ATTRIBUTE_UNUSED,
+				  tree var ATTRIBUTE_UNUSED,
+				  state_machine::state_t state ATTRIBUTE_UNUSED)
+  const
 {
   /* Empty.  */
 }
 
 bool
-sensitive_state_machine::can_purge_p (state_t s) const
+sensitive_state_machine::can_purge_p (state_t s ATTRIBUTE_UNUSED) const
 {
   return true;
 }
diff --git a/gcc/analyzer/sm-taint.cc b/gcc/analyzer/sm-taint.cc
index 4e3a46b..0063f1c 100644
--- a/gcc/analyzer/sm-taint.cc
+++ b/gcc/analyzer/sm-taint.cc
@@ -123,7 +123,7 @@ taint_state_machine::on_stmt (sm_context *sm_ctxt,
 
   if (const gassign *assign = dyn_cast <const gassign *> (stmt))
     {
-      tree lhs = gimple_assign_lhs (assign);
+      //tree lhs = gimple_assign_lhs (assign);
       tree rhs1 = gimple_assign_rhs1 (assign);
       enum tree_code op = gimple_assign_rhs_code (assign);
       if (op == ARRAY_REF)
@@ -183,7 +183,7 @@ taint_state_machine::on_edge (sm_context *sm_ctxt,
     {
       enum tree_code op = gimple_cond_code (cond_stmt);
       tree lhs = gimple_cond_lhs (cond_stmt);
-      tree rhs = gimple_cond_rhs (cond_stmt);
+      //tree rhs = gimple_cond_rhs (cond_stmt);
       // TODO: make it symmetric?
 
       switch (op)
@@ -218,17 +218,18 @@ taint_state_machine::on_edge (sm_context *sm_ctxt,
 }
 
 void
-taint_state_machine::on_leak (sm_context *sm_ctxt,
-			       const supernode *node,
-			       const gimple *stmt,
-			       tree var,
-			       state_machine::state_t state) const
+taint_state_machine::on_leak (sm_context *sm_ctxt ATTRIBUTE_UNUSED,
+			      const supernode *node ATTRIBUTE_UNUSED,
+			      const gimple *stmt ATTRIBUTE_UNUSED,
+			      tree var ATTRIBUTE_UNUSED,
+			      state_machine::state_t state ATTRIBUTE_UNUSED)
+  const
 {
   /* Empty.  */
 }
 
 bool
-taint_state_machine::can_purge_p (state_t s) const
+taint_state_machine::can_purge_p (state_t s ATTRIBUTE_UNUSED) const
 {
   return true;
 }
-- 
1.8.5.3

