Commit 7892ff37 by Jakub Jelinek

analyzer: fix build with gcc 4.4 (PR 93276)

All that is really needed is make sure you #include "diagnostic-core.h"
before including pretty-print.h.  By including
diagnostic-core.h first, you do:
and then pretty-print.h will do:
If instead pretty-print.h is included first, then it will use __gcc_diag__
instead of __gcc_tdiag__ and thus will assume %E/%D etc. can't be handled.

2020-01-29  Jakub Jelinek  <jakub@redhat.com>

	* analyzer.h (PUSH_IGNORE_WFORMAT, POP_IGNORE_WFORMAT): Remove.
	* constraint-manager.cc: Include diagnostic-core.h before graphviz.h.
	(range::dump, equiv_class::print): Don't use PUSH_IGNORE_WFORMAT or
	POP_IGNORE_WFORMAT.
	* state-purge.cc: Include diagnostic-core.h before
	gimple-pretty-print.h.
	(state_purge_annotator::add_node_annotations, print_vec_of_names):
	Don't use PUSH_IGNORE_WFORMAT or POP_IGNORE_WFORMAT.
	* region-model.cc: Move diagnostic-core.h include before graphviz.h.
	(path_var::dump, svalue::print, constant_svalue::print_details,
	region::dump_to_pp, region::dump_child_label, region::print_fields,
	map_region::print_fields, map_region::dump_dot_to_pp,
	map_region::dump_child_label, array_region::print_fields,
	array_region::dump_dot_to_pp): Don't use PUSH_IGNORE_WFORMAT or
	POP_IGNORE_WFORMAT.
parent 148018bc
2020-01-29 Jakub Jelinek <jakub@redhat.com>
* analyzer.h (PUSH_IGNORE_WFORMAT, POP_IGNORE_WFORMAT): Remove.
* constraint-manager.cc: Include diagnostic-core.h before graphviz.h.
(range::dump, equiv_class::print): Don't use PUSH_IGNORE_WFORMAT or
POP_IGNORE_WFORMAT.
* state-purge.cc: Include diagnostic-core.h before
gimple-pretty-print.h.
(state_purge_annotator::add_node_annotations, print_vec_of_names):
Don't use PUSH_IGNORE_WFORMAT or POP_IGNORE_WFORMAT.
* region-model.cc: Move diagnostic-core.h include before graphviz.h.
(path_var::dump, svalue::print, constant_svalue::print_details,
region::dump_to_pp, region::dump_child_label, region::print_fields,
map_region::print_fields, map_region::dump_dot_to_pp,
map_region::dump_child_label, array_region::print_fields,
array_region::dump_dot_to_pp): Don't use PUSH_IGNORE_WFORMAT or
POP_IGNORE_WFORMAT.
2020-01-28 David Malcolm <dmalcolm@redhat.com> 2020-01-28 David Malcolm <dmalcolm@redhat.com>
PR analyzer/93316 PR analyzer/93316
......
...@@ -100,22 +100,6 @@ public: ...@@ -100,22 +100,6 @@ public:
~auto_cfun () { pop_cfun (); } ~auto_cfun () { pop_cfun (); }
}; };
/* Macros for temporarily suppressing -Wformat and -Wformat-extra-args,
for those versions of GCC that support pragmas within a function
(4.6 onwards). */
#if GCC_VERSION >= 4006
# define PUSH_IGNORE_WFORMAT \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wformat\"") \
_Pragma("GCC diagnostic ignored \"-Wformat-extra-args\"")
# define POP_IGNORE_WFORMAT \
_Pragma("GCC diagnostic pop")
#else
# define PUSH_IGNORE_WFORMAT
# define POP_IGNORE_WFORMAT
#endif
/* A template for creating hash traits for a POD type. */ /* A template for creating hash traits for a POD type. */
template <typename Type> template <typename Type>
......
...@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-iterator.h" #include "gimple-iterator.h"
#include "fold-const.h" #include "fold-const.h"
#include "selftest.h" #include "selftest.h"
#include "diagnostic-core.h"
#include "graphviz.h" #include "graphviz.h"
#include "function.h" #include "function.h"
#include "analyzer/analyzer.h" #include "analyzer/analyzer.h"
...@@ -120,13 +121,11 @@ bound::get_relation_as_str () const ...@@ -120,13 +121,11 @@ bound::get_relation_as_str () const
void void
range::dump (pretty_printer *pp) const range::dump (pretty_printer *pp) const
{ {
PUSH_IGNORE_WFORMAT
pp_printf (pp, "%qE %s x %s %qE", pp_printf (pp, "%qE %s x %s %qE",
m_lower_bound.m_constant, m_lower_bound.m_constant,
m_lower_bound.get_relation_as_str (), m_lower_bound.get_relation_as_str (),
m_upper_bound.get_relation_as_str (), m_upper_bound.get_relation_as_str (),
m_upper_bound.m_constant); m_upper_bound.m_constant);
POP_IGNORE_WFORMAT
} }
/* Determine if there is only one possible value for this range. /* Determine if there is only one possible value for this range.
...@@ -200,9 +199,7 @@ equiv_class::print (pretty_printer *pp) const ...@@ -200,9 +199,7 @@ equiv_class::print (pretty_printer *pp) const
{ {
if (i > 0) if (i > 0)
pp_string (pp, " == "); pp_string (pp, " == ");
PUSH_IGNORE_WFORMAT
pp_printf (pp, "%qE", m_constant); pp_printf (pp, "%qE", m_constant);
POP_IGNORE_WFORMAT
} }
pp_character (pp, '}'); pp_character (pp, '}');
} }
......
...@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3. If not see
#include "basic-block.h" #include "basic-block.h"
#include "gimple.h" #include "gimple.h"
#include "gimple-iterator.h" #include "gimple-iterator.h"
#include "diagnostic-core.h"
#include "graphviz.h" #include "graphviz.h"
#include "options.h" #include "options.h"
#include "cgraph.h" #include "cgraph.h"
...@@ -37,7 +38,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -37,7 +38,6 @@ along with GCC; see the file COPYING3. If not see
#include "tree-pretty-print.h" #include "tree-pretty-print.h"
#include "diagnostic-color.h" #include "diagnostic-color.h"
#include "diagnostic-metadata.h" #include "diagnostic-metadata.h"
#include "diagnostic-core.h"
#include "tristate.h" #include "tristate.h"
#include "bitmap.h" #include "bitmap.h"
#include "selftest.h" #include "selftest.h"
...@@ -88,14 +88,12 @@ dump_tree (pretty_printer *pp, tree t) ...@@ -88,14 +88,12 @@ dump_tree (pretty_printer *pp, tree t)
void void
path_var::dump (pretty_printer *pp) const path_var::dump (pretty_printer *pp) const
{ {
PUSH_IGNORE_WFORMAT
if (m_tree == NULL_TREE) if (m_tree == NULL_TREE)
pp_string (pp, "NULL"); pp_string (pp, "NULL");
if (CONSTANT_CLASS_P (m_tree)) if (CONSTANT_CLASS_P (m_tree))
pp_printf (pp, "%qE", m_tree); pp_printf (pp, "%qE", m_tree);
else else
pp_printf (pp, "(%qE @ %i)", m_tree, m_stack_depth); pp_printf (pp, "(%qE @ %i)", m_tree, m_stack_depth);
POP_IGNORE_WFORMAT
} }
/* For use in printing a comma-separated list. */ /* For use in printing a comma-separated list. */
...@@ -318,13 +316,11 @@ svalue::print (const region_model &model, ...@@ -318,13 +316,11 @@ svalue::print (const region_model &model,
this_sid.print (pp); this_sid.print (pp);
pp_string (pp, ": {"); pp_string (pp, ": {");
PUSH_IGNORE_WFORMAT
if (m_type) if (m_type)
{ {
gcc_assert (TYPE_P (m_type)); gcc_assert (TYPE_P (m_type));
pp_printf (pp, "type: %qT, ", m_type); pp_printf (pp, "type: %qT, ", m_type);
} }
POP_IGNORE_WFORMAT
/* vfunc. */ /* vfunc. */
print_details (model, this_sid, pp); print_details (model, this_sid, pp);
...@@ -686,9 +682,7 @@ constant_svalue::print_details (const region_model &model ATTRIBUTE_UNUSED, ...@@ -686,9 +682,7 @@ constant_svalue::print_details (const region_model &model ATTRIBUTE_UNUSED,
svalue_id this_sid ATTRIBUTE_UNUSED, svalue_id this_sid ATTRIBUTE_UNUSED,
pretty_printer *pp) const pretty_printer *pp) const
{ {
PUSH_IGNORE_WFORMAT
pp_printf (pp, "%qE", m_cst_expr); pp_printf (pp, "%qE", m_cst_expr);
POP_IGNORE_WFORMAT
} }
/* Implementation of svalue::get_child_sid vfunc for constant_svalue. */ /* Implementation of svalue::get_child_sid vfunc for constant_svalue. */
...@@ -1284,9 +1278,7 @@ region::dump_to_pp (const region_model &model, ...@@ -1284,9 +1278,7 @@ region::dump_to_pp (const region_model &model,
} }
if (m_type) if (m_type)
{ {
PUSH_IGNORE_WFORMAT
pp_printf (pp, "%s type: %qT", field_prefix, m_type); pp_printf (pp, "%s type: %qT", field_prefix, m_type);
POP_IGNORE_WFORMAT
pp_newline (pp); pp_newline (pp);
} }
...@@ -1336,9 +1328,7 @@ region::dump_child_label (const region_model &model, ...@@ -1336,9 +1328,7 @@ region::dump_child_label (const region_model &model,
pp_string (pp, "active "); pp_string (pp, "active ");
else else
pp_string (pp, "inactive "); pp_string (pp, "inactive ");
PUSH_IGNORE_WFORMAT
pp_printf (pp, "view as %qT: ", child->get_type ()); pp_printf (pp, "view as %qT: ", child->get_type ());
POP_IGNORE_WFORMAT
} }
} }
...@@ -1468,10 +1458,8 @@ region::print_fields (const region_model &model ATTRIBUTE_UNUSED, ...@@ -1468,10 +1458,8 @@ region::print_fields (const region_model &model ATTRIBUTE_UNUSED,
pp_printf (pp, ", sval: "); pp_printf (pp, ", sval: ");
m_sval_id.print (pp); m_sval_id.print (pp);
PUSH_IGNORE_WFORMAT
if (m_type) if (m_type)
pp_printf (pp, ", type: %qT", m_type); pp_printf (pp, ", type: %qT", m_type);
POP_IGNORE_WFORMAT
} }
/* Determine if a pointer to this region must be non-NULL. /* Determine if a pointer to this region must be non-NULL.
...@@ -1574,9 +1562,7 @@ map_region::print_fields (const region_model &model, ...@@ -1574,9 +1562,7 @@ map_region::print_fields (const region_model &model,
pp_string (pp, ", "); pp_string (pp, ", ");
tree expr = (*iter).first; tree expr = (*iter).first;
region_id child_rid = (*iter).second; region_id child_rid = (*iter).second;
PUSH_IGNORE_WFORMAT
pp_printf (pp, "%qE: ", expr); pp_printf (pp, "%qE: ", expr);
POP_IGNORE_WFORMAT
child_rid.print (pp); child_rid.print (pp);
} }
pp_string (pp, "}"); pp_string (pp, "}");
...@@ -1601,9 +1587,7 @@ map_region::dump_dot_to_pp (const region_model &model, ...@@ -1601,9 +1587,7 @@ map_region::dump_dot_to_pp (const region_model &model,
pp_printf (pp, "rid_label_%i [label=\"", child_rid.as_int ()); pp_printf (pp, "rid_label_%i [label=\"", child_rid.as_int ());
pp_write_text_to_stream (pp); pp_write_text_to_stream (pp);
PUSH_IGNORE_WFORMAT
pp_printf (pp, "%qE", expr); pp_printf (pp, "%qE", expr);
POP_IGNORE_WFORMAT
pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/false); pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/false);
pp_string (pp, "\"];"); pp_string (pp, "\"];");
pp_newline (pp); pp_newline (pp);
...@@ -1633,12 +1617,10 @@ map_region::dump_child_label (const region_model &model, ...@@ -1633,12 +1617,10 @@ map_region::dump_child_label (const region_model &model,
if (child_rid == (*iter).second) if (child_rid == (*iter).second)
{ {
tree key = (*iter).first; tree key = (*iter).first;
PUSH_IGNORE_WFORMAT
if (DECL_P (key)) if (DECL_P (key))
pp_printf (pp, "%qD: ", key); pp_printf (pp, "%qD: ", key);
else else
pp_printf (pp, "%qE: ", key); pp_printf (pp, "%qE: ", key);
POP_IGNORE_WFORMAT
} }
} }
} }
...@@ -2246,9 +2228,7 @@ array_region::print_fields (const region_model &model, ...@@ -2246,9 +2228,7 @@ array_region::print_fields (const region_model &model,
pp_string (pp, ", "); pp_string (pp, ", ");
int key = (*iter).first; int key = (*iter).first;
region_id child_rid = (*iter).second; region_id child_rid = (*iter).second;
PUSH_IGNORE_WFORMAT
pp_printf (pp, "[%i]: ", key); pp_printf (pp, "[%i]: ", key);
POP_IGNORE_WFORMAT
child_rid.print (pp); child_rid.print (pp);
} }
pp_string (pp, "}"); pp_string (pp, "}");
...@@ -2273,9 +2253,7 @@ array_region::dump_dot_to_pp (const region_model &model, ...@@ -2273,9 +2253,7 @@ array_region::dump_dot_to_pp (const region_model &model,
pp_printf (pp, "rid_label_%i [label=\"", child_rid.as_int ()); pp_printf (pp, "rid_label_%i [label=\"", child_rid.as_int ());
pp_write_text_to_stream (pp); pp_write_text_to_stream (pp);
PUSH_IGNORE_WFORMAT
pp_printf (pp, "%qi", key); pp_printf (pp, "%qi", key);
POP_IGNORE_WFORMAT
pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/false); pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/false);
pp_string (pp, "\"];"); pp_string (pp, "\"];");
pp_newline (pp); pp_newline (pp);
......
...@@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -34,6 +34,7 @@ along with GCC; see the file COPYING3. If not see
#include "tree-phinodes.h" #include "tree-phinodes.h"
#include "options.h" #include "options.h"
#include "ssa-iterators.h" #include "ssa-iterators.h"
#include "diagnostic-core.h"
#include "gimple-pretty-print.h" #include "gimple-pretty-print.h"
#include "function.h" #include "function.h"
#include "analyzer/analyzer.h" #include "analyzer/analyzer.h"
...@@ -444,12 +445,10 @@ state_purge_annotator::add_node_annotations (graphviz_out *gv, ...@@ -444,12 +445,10 @@ state_purge_annotator::add_node_annotations (graphviz_out *gv,
state_purge_per_ssa_name *per_name_data = (*iter).second; state_purge_per_ssa_name *per_name_data = (*iter).second;
if (per_name_data->get_function () == n.m_fun) if (per_name_data->get_function () == n.m_fun)
{ {
PUSH_IGNORE_WFORMAT
if (per_name_data->needed_at_point_p (before_supernode)) if (per_name_data->needed_at_point_p (before_supernode))
pp_printf (pp, "%qE needed here", name); pp_printf (pp, "%qE needed here", name);
else else
pp_printf (pp, "%qE not needed here", name); pp_printf (pp, "%qE not needed here", name);
POP_IGNORE_WFORMAT
} }
pp_newline (pp); pp_newline (pp);
} }
...@@ -476,9 +475,7 @@ print_vec_of_names (graphviz_out *gv, const char *title, ...@@ -476,9 +475,7 @@ print_vec_of_names (graphviz_out *gv, const char *title,
{ {
if (i > 0) if (i > 0)
pp_string (pp, ", "); pp_string (pp, ", ");
PUSH_IGNORE_WFORMAT
pp_printf (pp, "%qE", name); pp_printf (pp, "%qE", name);
POP_IGNORE_WFORMAT
} }
pp_printf (pp, "}"); pp_printf (pp, "}");
pp_write_text_as_html_like_dot_to_stream (pp); pp_write_text_as_html_like_dot_to_stream (pp);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment