diff --git a/gcc/ada/gcc-interface/misc.cc b/gcc/ada/gcc-interface/misc.cc
index 2aa1bfd410b2..8c921db7dcdd 100644
--- a/gcc/ada/gcc-interface/misc.cc
+++ b/gcc/ada/gcc-interface/misc.cc
@@ -23,6 +23,7 @@
  *                                                                          *
  ****************************************************************************/
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index a073b2d94f1c..5f5cbe5b4774 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -23,6 +23,7 @@
  *                                                                          *
  ****************************************************************************/
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index a88a23860d3e..951d3848d09b 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -23,6 +23,7 @@
  *                                                                          *
  ****************************************************************************/
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/analyzer/analyzer-logging.cc b/gcc/analyzer/analyzer-logging.cc
index d3b04f2d9b10..2a4d02f83ba6 100644
--- a/gcc/analyzer/analyzer-logging.cc
+++ b/gcc/analyzer/analyzer-logging.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
@@ -50,12 +51,12 @@ logger::logger (FILE *f_out,
   m_log_refcount_changes (false),
   m_pp (reference_pp.clone ())
 {
-  pp_show_color (m_pp) = 0;
-  pp_buffer (m_pp)->m_stream = f_out;
+  pp_show_color (m_pp.get ()) = 0;
+  pp_buffer (m_pp.get ())->m_stream = f_out;
 
   /* %qE in logs for SSA_NAMEs should show the ssa names, rather than
      trying to prettify things by showing the underlying var.  */
-  pp_format_decoder (m_pp) = default_tree_printer;
+  pp_format_decoder (m_pp.get ()) = default_tree_printer;
 
   /* Begin the log by writing the GCC version.  */
   print_version (f_out, "", false);
@@ -70,7 +71,6 @@ logger::~logger ()
   /* This should be the last message emitted.  */
   log ("%s", __PRETTY_FUNCTION__);
   gcc_assert (m_refcount == 0);
-  delete m_pp;
 }
 
 /* Increment the reference count of the logger.  */
@@ -145,15 +145,15 @@ void
 logger::log_va_partial (const char *fmt, va_list *ap)
 {
   text_info text (fmt, ap, 0);
-  pp_format (m_pp, &text);
-  pp_output_formatted_text (m_pp);
+  pp_format (m_pp.get (), &text);
+  pp_output_formatted_text (m_pp.get ());
 }
 
 void
 logger::end_log_line ()
 {
-  pp_flush (m_pp);
-  pp_clear_output_area (m_pp);
+  pp_flush (m_pp.get ());
+  pp_clear_output_area (m_pp.get ());
   fprintf (m_f_out, "\n");
   fflush (m_f_out);
 }
diff --git a/gcc/analyzer/analyzer-logging.h b/gcc/analyzer/analyzer-logging.h
index eb2cde7a306b..aaa3d79a30e4 100644
--- a/gcc/analyzer/analyzer-logging.h
+++ b/gcc/analyzer/analyzer-logging.h
@@ -57,7 +57,7 @@ class logger
   void inc_indent () { m_indent_level++; }
   void dec_indent () { m_indent_level--; }
 
-  pretty_printer *get_printer () const { return m_pp; }
+  pretty_printer *get_printer () const { return m_pp.get (); }
   FILE *get_file () const { return m_f_out; }
 
 private:
@@ -67,7 +67,7 @@ private:
   FILE *m_f_out;
   int m_indent_level;
   bool m_log_refcount_changes;
-  pretty_printer *m_pp;
+  std::unique_ptr<pretty_printer> m_pp;
 };
 
 /* The class log_scope is an RAII-style class intended to make
diff --git a/gcc/analyzer/analyzer.cc b/gcc/analyzer/analyzer.cc
index 4a1a36157133..0f998e3f66f7 100644
--- a/gcc/analyzer/analyzer.cc
+++ b/gcc/analyzer/analyzer.cc
@@ -494,11 +494,11 @@ get_user_facing_name (const gcall *call)
 label_text
 make_label_text (bool can_colorize, const char *fmt, ...)
 {
-  pretty_printer *pp = global_dc->m_printer->clone ();
-  pp_clear_output_area (pp);
+  std::unique_ptr<pretty_printer> pp (global_dc->clone_printer ());
+  pp_clear_output_area (pp.get ());
 
   if (!can_colorize)
-    pp_show_color (pp) = false;
+    pp_show_color (pp.get ()) = false;
 
   rich_location rich_loc (line_table, UNKNOWN_LOCATION);
 
@@ -507,13 +507,12 @@ make_label_text (bool can_colorize, const char *fmt, ...)
   va_start (ap, fmt);
 
   text_info ti (_(fmt), &ap, 0, NULL, &rich_loc);
-  pp_format (pp, &ti);
-  pp_output_formatted_text (pp);
+  pp_format (pp.get (), &ti);
+  pp_output_formatted_text (pp.get ());
 
   va_end (ap);
 
-  label_text result = label_text::take (xstrdup (pp_formatted_text (pp)));
-  delete pp;
+  label_text result = label_text::take (xstrdup (pp_formatted_text (pp.get ())));
   return result;
 }
 
@@ -524,11 +523,11 @@ make_label_text_n (bool can_colorize, unsigned HOST_WIDE_INT n,
 		   const char *singular_fmt,
 		   const char *plural_fmt, ...)
 {
-  pretty_printer *pp = global_dc->m_printer->clone ();
-  pp_clear_output_area (pp);
+  std::unique_ptr<pretty_printer> pp (global_dc->clone_printer ());
+  pp_clear_output_area (pp.get ());
 
   if (!can_colorize)
-    pp_show_color (pp) = false;
+    pp_show_color (pp.get ()) = false;
 
   rich_location rich_loc (line_table, UNKNOWN_LOCATION);
 
@@ -540,13 +539,13 @@ make_label_text_n (bool can_colorize, unsigned HOST_WIDE_INT n,
 
   text_info ti (fmt, &ap, 0, NULL, &rich_loc);
 
-  pp_format (pp, &ti);
-  pp_output_formatted_text (pp);
+  pp_format (pp.get (), &ti);
+  pp_output_formatted_text (pp.get ());
 
   va_end (ap);
 
-  label_text result = label_text::take (xstrdup (pp_formatted_text (pp)));
-  delete pp;
+  label_text result
+    = label_text::take (xstrdup (pp_formatted_text (pp.get ())));
   return result;
 }
 
diff --git a/gcc/analyzer/bar-chart.cc b/gcc/analyzer/bar-chart.cc
index 4a4acf5f377c..3a259f80066b 100644
--- a/gcc/analyzer/bar-chart.cc
+++ b/gcc/analyzer/bar-chart.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/analyzer/pending-diagnostic.cc b/gcc/analyzer/pending-diagnostic.cc
index ec6f5acf21f3..a900839375cb 100644
--- a/gcc/analyzer/pending-diagnostic.cc
+++ b/gcc/analyzer/pending-diagnostic.cc
@@ -93,21 +93,19 @@ interesting_t::dump_to_pp (pretty_printer *pp, bool simple) const
 label_text
 evdesc::event_desc::formatted_print (const char *fmt, ...) const
 {
-  pretty_printer *pp = global_dc->m_printer->clone ();
+  auto pp = global_dc->clone_printer ();
 
-  pp_show_color (pp) = m_colorize;
+  pp_show_color (pp.get ()) = m_colorize;
 
   rich_location rich_loc (line_table, UNKNOWN_LOCATION);
   va_list ap;
   va_start (ap, fmt);
   text_info ti (_(fmt), &ap, 0, nullptr, &rich_loc);
-  pp_format (pp, &ti);
-  pp_output_formatted_text (pp);
+  pp_format (pp.get (), &ti);
+  pp_output_formatted_text (pp.get ());
   va_end (ap);
 
-  label_text result = label_text::take (xstrdup (pp_formatted_text (pp)));
-  delete pp;
-  return result;
+  return label_text::take (xstrdup (pp_formatted_text (pp.get ())));
 }
 
 /* class diagnostic_emission_context.  */
diff --git a/gcc/analyzer/sm-malloc.cc b/gcc/analyzer/sm-malloc.cc
index 11c0e1b1a2fd..12465cbe42b2 100644
--- a/gcc/analyzer/sm-malloc.cc
+++ b/gcc/analyzer/sm-malloc.cc
@@ -1648,14 +1648,13 @@ private:
 
   static bool sufficiently_similar_p (tree expr_a, tree expr_b)
   {
-    pretty_printer *pp_a = global_dc->m_printer->clone ();
-    pretty_printer *pp_b = global_dc->m_printer->clone ();
-    pp_printf (pp_a, "%qE", expr_a);
-    pp_printf (pp_b, "%qE", expr_b);
-    bool result = (strcmp (pp_formatted_text (pp_a), pp_formatted_text (pp_b))
+    auto pp_a = global_dc->clone_printer ();
+    auto pp_b = global_dc->clone_printer ();
+    pp_printf (pp_a.get (), "%qE", expr_a);
+    pp_printf (pp_b.get (), "%qE", expr_b);
+    bool result = (strcmp (pp_formatted_text (pp_a.get ()),
+			   pp_formatted_text (pp_b.get ()))
 		   == 0);
-    delete pp_a;
-    delete pp_b;
     return result;
   }
 
diff --git a/gcc/analyzer/supergraph.cc b/gcc/analyzer/supergraph.cc
index 55bd42a89a1a..826f8f614f75 100644
--- a/gcc/analyzer/supergraph.cc
+++ b/gcc/analyzer/supergraph.cc
@@ -437,16 +437,15 @@ supergraph::dump_dot_to_pp (pretty_printer *pp,
 void
 supergraph::dump_dot_to_file (FILE *fp, const dump_args_t &dump_args) const
 {
-  pretty_printer *pp = global_dc->m_printer->clone ();
-  pp_show_color (pp) = 0;
+  std::unique_ptr<pretty_printer> pp (global_dc->clone_printer ());
+  pp_show_color (pp.get ()) = 0;
   /* %qE in logs for SSA_NAMEs should show the ssa names, rather than
      trying to prettify things by showing the underlying var.  */
-  pp_format_decoder (pp) = default_tree_printer;
+  pp_format_decoder (pp.get ()) = default_tree_printer;
 
   pp->set_output_stream (fp);
-  dump_dot_to_pp (pp, dump_args);
-  pp_flush (pp);
-  delete pp;
+  dump_dot_to_pp (pp.get (), dump_args);
+  pp_flush (pp.get ());
 }
 
 /* Dump this graph in .dot format to PATH, using DUMP_ARGS.  */
diff --git a/gcc/asan.cc b/gcc/asan.cc
index 5f262d54a3ac..0a348a6decdb 100644
--- a/gcc/asan.cc
+++ b/gcc/asan.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/attribs.cc b/gcc/attribs.cc
index 9fb564bd55dd..53cf53836e3d 100644
--- a/gcc/attribs.cc
+++ b/gcc/attribs.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #define INCLUDE_STRING
 #include "config.h"
 #include "system.h"
@@ -2673,10 +2674,9 @@ attr_access::array_as_string (tree type) const
 
   /* Format the type using the current pretty printer.  The generic tree
      printer does a terrible job.  */
-  pretty_printer *pp = global_dc->m_printer->clone ();
-  pp_printf (pp, "%qT", type);
-  typstr = pp_formatted_text (pp);
-  delete pp;
+  std::unique_ptr<pretty_printer> pp (global_dc->clone_printer ());
+  pp_printf (pp.get (), "%qT", type);
+  typstr = pp_formatted_text (pp.get ());
 
   return typstr;
 }
diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc
index de59b94bcb33..242b71d11655 100644
--- a/gcc/auto-profile.cc
+++ b/gcc/auto-profile.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "config.h"
 #define INCLUDE_MAP
+#define INCLUDE_MEMORY
 #define INCLUDE_SET
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc
index fbba44362540..db5c0b5d746d 100644
--- a/gcc/c-family/c-ada-spec.cc
+++ b/gcc/c-family/c-ada-spec.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index 4dd2eecbea54..cf9523aacf56 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #define INCLUDE_STRING
 #include "config.h"
 #include "system.h"
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index ec6a5da892dd..12098ccfbf0d 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define GCC_C_COMMON_C
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c-family/c-format.cc b/gcc/c-family/c-format.cc
index f4a65a5019c3..211fb3be7d91 100644
--- a/gcc/c-family/c-format.cc
+++ b/gcc/c-family/c-format.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c-family/c-gimplify.cc b/gcc/c-family/c-gimplify.cc
index 3e29766e092e..93c1935ae564 100644
--- a/gcc/c-family/c-gimplify.cc
+++ b/gcc/c-family/c-gimplify.cc
@@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c-family/c-indentation.cc b/gcc/c-family/c-indentation.cc
index 38be7d24da0e..7adec84ce2b0 100644
--- a/gcc/c-family/c-indentation.cc
+++ b/gcc/c-family/c-indentation.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
index 510e0870140e..efbe7980c579 100644
--- a/gcc/c-family/c-opts.cc
+++ b/gcc/c-family/c-opts.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c-family/c-pch.cc b/gcc/c-family/c-pch.cc
index f104575d3d08..50479ad43f43 100644
--- a/gcc/c-family/c-pch.cc
+++ b/gcc/c-family/c-pch.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c-family/c-pragma.cc b/gcc/c-family/c-pragma.cc
index ed2a7a00e9eb..9d7153489f9c 100644
--- a/gcc/c-family/c-pragma.cc
+++ b/gcc/c-family/c-pragma.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c-family/c-pretty-print.cc b/gcc/c-family/c-pretty-print.cc
index 0c764aecc3de..2596685e8b60 100644
--- a/gcc/c-family/c-pretty-print.cc
+++ b/gcc/c-family/c-pretty-print.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
@@ -36,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "function.h"
 #include "basic-block.h"
 #include "gimple.h"
+#include "make-unique.h"
 
 /* The pretty-printer code is primarily designed to closely follow
    (GNU) C and C++ grammars.  That is to be contrasted with spaghetti
@@ -2971,10 +2973,10 @@ c_pretty_printer::c_pretty_printer ()
 
 /* c_pretty_printer's implementation of pretty_printer::clone vfunc.  */
 
-pretty_printer *
+std::unique_ptr<pretty_printer>
 c_pretty_printer::clone () const
 {
-  return new c_pretty_printer (*this);
+  return ::make_unique<c_pretty_printer> (*this);
 }
 
 /* Print the tree T in full, on file FILE.  */
diff --git a/gcc/c-family/c-pretty-print.h b/gcc/c-family/c-pretty-print.h
index 550e4cb68820..80854b079175 100644
--- a/gcc/c-family/c-pretty-print.h
+++ b/gcc/c-family/c-pretty-print.h
@@ -51,7 +51,7 @@ class c_pretty_printer : public pretty_printer
 {
 public:
   c_pretty_printer ();
-  pretty_printer *clone () const override;
+  std::unique_ptr<pretty_printer> clone () const override;
 
   // Format string, possibly translated.
   void translate_string (const char *);
diff --git a/gcc/c-family/c-type-mismatch.cc b/gcc/c-family/c-type-mismatch.cc
index 89646854f3c7..abc8cb83cc54 100644
--- a/gcc/c-family/c-type-mismatch.cc
+++ b/gcc/c-family/c-type-mismatch.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c-family/c-warn.cc b/gcc/c-family/c-warn.cc
index 47e0a6bfa073..979467bb7df2 100644
--- a/gcc/c-family/c-warn.cc
+++ b/gcc/c-family/c-warn.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #define INCLUDE_STRING
 #include "config.h"
 #include "system.h"
diff --git a/gcc/c/c-aux-info.cc b/gcc/c/c-aux-info.cc
index f6b5980aa830..b422da0e7264 100644
--- a/gcc/c/c-aux-info.cc
+++ b/gcc/c/c-aux-info.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c/c-convert.cc b/gcc/c/c-convert.cc
index 7c1064c6691b..9180c6ae14ec 100644
--- a/gcc/c/c-convert.cc
+++ b/gcc/c/c-convert.cc
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
    Every language front end must have a `convert' function
    but what kind of conversions it does will depend on the language.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c/c-errors.cc b/gcc/c/c-errors.cc
index c6b7c108354b..38b11a7c70a8 100644
--- a/gcc/c/c-errors.cc
+++ b/gcc/c/c-errors.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c/c-fold.cc b/gcc/c/c-fold.cc
index 57b67c74bd8e..83b7b4879b93 100644
--- a/gcc/c/c-fold.cc
+++ b/gcc/c/c-fold.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c/c-lang.cc b/gcc/c/c-lang.cc
index 870e23b4a33c..7e5604fce6b6 100644
--- a/gcc/c/c-lang.cc
+++ b/gcc/c/c-lang.cc
@@ -18,6 +18,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c/c-objc-common.cc b/gcc/c/c-objc-common.cc
index eb0c4b85772f..dc91373f5b98 100644
--- a/gcc/c/c-objc-common.cc
+++ b/gcc/c/c-objc-common.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
@@ -295,11 +296,11 @@ print_type (c_pretty_printer *cpp, tree t, bool *quoted,
 void
 pp_markup::element_quoted_type::print_type (pp_markup::context &ctxt)
 {
-  c_pretty_printer *cpp = (c_pretty_printer *) ctxt.m_pp.clone ();
+  auto pp = ctxt.m_pp.clone ();
+  c_pretty_printer *cpp = (c_pretty_printer *)pp.get ();
   cpp->set_padding (pp_none);
   ::print_type (cpp, m_type, &ctxt.m_quoted, m_highlight_color);
   pp_string (&ctxt.m_pp, pp_formatted_text (cpp));
-  delete cpp;
 }
 
 /* Called during diagnostic message formatting process to print a
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index ba6d96d26b2b..39d5e3716ab8 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
    including computing the types of the result, C-specific error checks,
    and some optimization.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc
index d156d83cd378..8d1db33b8441 100644
--- a/gcc/c/gimple-parser.cc
+++ b/gcc/c/gimple-parser.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/calls.cc b/gcc/calls.cc
index c5c26f65280f..05eaa0d7b148 100644
--- a/gcc/calls.cc
+++ b/gcc/calls.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cfganal.cc b/gcc/cfganal.cc
index 35c59f3f5d26..863f88ff1eab 100644
--- a/gcc/cfganal.cc
+++ b/gcc/cfganal.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* This file contains various simple utilities to analyze the CFG.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
index 6c1096363afb..885f488a9d41 100644
--- a/gcc/cfgexpand.cc
+++ b/gcc/cfgexpand.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cfghooks.cc b/gcc/cfghooks.cc
index 3ced91c96394..55fdf983e1ce 100644
--- a/gcc/cfghooks.cc
+++ b/gcc/cfghooks.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cfgloop.cc b/gcc/cfgloop.cc
index 5202c3865d16..df0ec7722bc2 100644
--- a/gcc/cfgloop.cc
+++ b/gcc/cfgloop.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 39a3adbc7c35..03d3b30b511a 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3.  If not see
     optimization.  It represents a multi-graph where nodes are functions
     (symbols within symbol table) and edges are call sites. */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cgraphclones.cc b/gcc/cgraphclones.cc
index 4fff6873a369..ede720f4b157 100644
--- a/gcc/cgraphclones.cc
+++ b/gcc/cgraphclones.cc
@@ -64,6 +64,7 @@ along with GCC; see the file COPYING3.  If not see
    only difference is that clones are not visible during the
    Generate Summary stage.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc
index 2bd0289ffba5..0052b92715ad 100644
--- a/gcc/cgraphunit.cc
+++ b/gcc/cgraphunit.cc
@@ -157,6 +157,7 @@ along with GCC; see the file COPYING3.  If not see
       and apply simple transformations
 */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/collect-utils.cc b/gcc/collect-utils.cc
index 981a14a554b9..5397fe2c7a09 100644
--- a/gcc/collect-utils.cc
+++ b/gcc/collect-utils.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/collect2.cc b/gcc/collect2.cc
index 902014a9cc15..2bd618d27c16 100644
--- a/gcc/collect2.cc
+++ b/gcc/collect2.cc
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Build tables of static constructors and destructors and run ld.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/common/config/aarch64/aarch64-common.cc b/gcc/common/config/aarch64/aarch64-common.cc
index 64b65b7ff9e4..2bfc597e333b 100644
--- a/gcc/common/config/aarch64/aarch64-common.cc
+++ b/gcc/common/config/aarch64/aarch64-common.cc
@@ -19,6 +19,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_STRING
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/common/config/arm/arm-common.cc b/gcc/common/config/arm/arm-common.cc
index dbcbe3f6e996..68674575ccfc 100644
--- a/gcc/common/config/arm/arm-common.cc
+++ b/gcc/common/config/arm/arm-common.cc
@@ -18,6 +18,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #define INCLUDE_LIST
+#define INCLUDE_MEMORY
 #define INCLUDE_VECTOR
 #define INCLUDE_ALGORITHM
 #include "config.h"
diff --git a/gcc/common/config/avr/avr-common.cc b/gcc/common/config/avr/avr-common.cc
index bb454a208568..f14a4a48e7c9 100644
--- a/gcc/common/config/avr/avr-common.cc
+++ b/gcc/common/config/avr/avr-common.cc
@@ -17,6 +17,7 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/aarch64/aarch64-cc-fusion.cc b/gcc/config/aarch64/aarch64-cc-fusion.cc
index 3af8c00d8462..3cae4c4d8bd5 100644
--- a/gcc/config/aarch64/aarch64-cc-fusion.cc
+++ b/gcc/config/aarch64/aarch64-cc-fusion.cc
@@ -64,6 +64,7 @@
 #define INCLUDE_ALGORITHM
 #define INCLUDE_FUNCTIONAL
 #define INCLUDE_ARRAY
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/aarch64/aarch64-early-ra.cc b/gcc/config/aarch64/aarch64-early-ra.cc
index 6e544dd61915..bbd84686e13f 100644
--- a/gcc/config/aarch64/aarch64-early-ra.cc
+++ b/gcc/config/aarch64/aarch64-early-ra.cc
@@ -40,6 +40,7 @@
 
 #define INCLUDE_ALGORITHM
 #define INCLUDE_FUNCTIONAL
+#define INCLUDE_MEMORY
 #define INCLUDE_ARRAY
 #include "config.h"
 #include "system.h"
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc
index e7c703c987e8..745c5bcc537d 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins.cc
@@ -19,6 +19,7 @@
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/arc/arc.cc b/gcc/config/arc/arc.cc
index a225adeff573..78b7c7381c1c 100644
--- a/gcc/config/arc/arc.cc
+++ b/gcc/config/arc/arc.cc
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/arm/aarch-common.cc b/gcc/config/arm/aarch-common.cc
index aa405af8192b..44012feb5be7 100644
--- a/gcc/config/arm/aarch-common.cc
+++ b/gcc/config/arm/aarch-common.cc
@@ -23,6 +23,7 @@
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/arm/arm-mve-builtins.cc b/gcc/config/arm/arm-mve-builtins.cc
index 7e8217666fee..8909ed3dcc41 100644
--- a/gcc/config/arm/arm-mve-builtins.cc
+++ b/gcc/config/arm/arm-mve-builtins.cc
@@ -19,6 +19,7 @@
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/avr/avr-devices.cc b/gcc/config/avr/avr-devices.cc
index 456a6b72c8b0..83b4a2ec64cd 100644
--- a/gcc/config/avr/avr-devices.cc
+++ b/gcc/config/avr/avr-devices.cc
@@ -20,6 +20,7 @@
 #ifndef IN_GEN_AVR_MMCU_TEXI
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/avr/driver-avr.cc b/gcc/config/avr/driver-avr.cc
index 4dcabc604e85..3eefcabe48dd 100644
--- a/gcc/config/avr/driver-avr.cc
+++ b/gcc/config/avr/driver-avr.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc
index 2051fa5b08b1..aa00d149c4d3 100644
--- a/gcc/config/bpf/bpf.cc
+++ b/gcc/config/bpf/bpf.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/bpf/btfext-out.cc b/gcc/config/bpf/btfext-out.cc
index b3df7b555d5f..ca6241aa52ee 100644
--- a/gcc/config/bpf/btfext-out.cc
+++ b/gcc/config/bpf/btfext-out.cc
@@ -19,6 +19,7 @@
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/bpf/core-builtins.cc b/gcc/config/bpf/core-builtins.cc
index 86e2e9d6e39f..deb368a1d3db 100644
--- a/gcc/config/bpf/core-builtins.cc
+++ b/gcc/config/bpf/core-builtins.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index 9129378be373..176974706381 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/i386/driver-i386.cc b/gcc/config/i386/driver-i386.cc
index 445f5640155a..26f094cd45d3 100644
--- a/gcc/config/i386/driver-i386.cc
+++ b/gcc/config/i386/driver-i386.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/i386/i386-builtins.cc b/gcc/config/i386/i386-builtins.cc
index 4286eeb80e63..a778f049a88c 100644
--- a/gcc/config/i386/i386-builtins.cc
+++ b/gcc/config/i386/i386-builtins.cc
@@ -18,6 +18,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index 2b774ff7c4e1..81d58ad46566 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -18,6 +18,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
index 3434d0069439..16b1e6ca66e5 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -18,6 +18,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
index 55e0210260f5..5fa6e021778f 100644
--- a/gcc/config/i386/i386-options.cc
+++ b/gcc/config/i386/i386-options.cc
@@ -18,6 +18,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/loongarch/loongarch-builtins.cc b/gcc/config/loongarch/loongarch-builtins.cc
index cf92770de30e..64529da8250c 100644
--- a/gcc/config/loongarch/loongarch-builtins.cc
+++ b/gcc/config/loongarch/loongarch-builtins.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/mingw/winnt-cxx.cc b/gcc/config/mingw/winnt-cxx.cc
index f4d7a50262bf..621366e99743 100644
--- a/gcc/config/mingw/winnt-cxx.cc
+++ b/gcc/config/mingw/winnt-cxx.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/mingw/winnt.cc b/gcc/config/mingw/winnt.cc
index 803e5f5ec857..fb4b8a484158 100644
--- a/gcc/config/mingw/winnt.cc
+++ b/gcc/config/mingw/winnt.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
index 173f792bf55a..cd5c5970f0b1 100644
--- a/gcc/config/mips/mips.cc
+++ b/gcc/config/mips/mips.cc
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/msp430/driver-msp430.cc b/gcc/config/msp430/driver-msp430.cc
index a11fd3d7dec8..5ffa8ef35e65 100644
--- a/gcc/config/msp430/driver-msp430.cc
+++ b/gcc/config/msp430/driver-msp430.cc
@@ -20,6 +20,7 @@
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/nvptx/mkoffload.cc b/gcc/config/nvptx/mkoffload.cc
index df16ee647364..ddb1c6631648 100644
--- a/gcc/config/nvptx/mkoffload.cc
+++ b/gcc/config/nvptx/mkoffload.cc
@@ -29,6 +29,7 @@
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 96a1134220ed..3ac61b498944 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -20,6 +20,7 @@
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include <sstream>
 #include "system.h"
diff --git a/gcc/config/riscv/riscv-avlprop.cc b/gcc/config/riscv/riscv-avlprop.cc
index 91d80aa00d62..066377c5c14b 100644
--- a/gcc/config/riscv/riscv-avlprop.cc
+++ b/gcc/config/riscv/riscv-avlprop.cc
@@ -65,6 +65,7 @@ along with GCC; see the file COPYING3.  If not see
 #define IN_TARGET_CODE 1
 #define INCLUDE_ALGORITHM
 #define INCLUDE_FUNCTIONAL
+#define INCLUDE_MEMORY
 #define INCLUDE_ARRAY
 
 #include "config.h"
diff --git a/gcc/config/riscv/riscv-vector-builtins.cc b/gcc/config/riscv/riscv-vector-builtins.cc
index 41730c483ee1..458d9b0886e3 100644
--- a/gcc/config/riscv/riscv-vector-builtins.cc
+++ b/gcc/config/riscv/riscv-vector-builtins.cc
@@ -20,6 +20,7 @@
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index 030ffbe2ebbc..0b53b20f9f6c 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -63,6 +63,7 @@ along with GCC; see the file COPYING3.  If not see
 #define IN_TARGET_CODE 1
 #define INCLUDE_ALGORITHM
 #define INCLUDE_FUNCTIONAL
+#define INCLUDE_MEMORY
 #define INCLUDE_ARRAY
 
 #include "config.h"
diff --git a/gcc/config/rs6000/driver-rs6000.cc b/gcc/config/rs6000/driver-rs6000.cc
index f4900724b98a..fd457e72d972 100644
--- a/gcc/config/rs6000/driver-rs6000.cc
+++ b/gcc/config/rs6000/driver-rs6000.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/rs6000/host-darwin.cc b/gcc/config/rs6000/host-darwin.cc
index e0001776339d..15c40b16e674 100644
--- a/gcc/config/rs6000/host-darwin.cc
+++ b/gcc/config/rs6000/host-darwin.cc
@@ -19,6 +19,7 @@
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/rs6000/rs6000-c.cc b/gcc/config/rs6000/rs6000-c.cc
index 04882c396bfe..5ff346edc2e2 100644
--- a/gcc/config/rs6000/rs6000-c.cc
+++ b/gcc/config/rs6000/rs6000-c.cc
@@ -22,6 +22,7 @@
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/s390/s390-c.cc b/gcc/config/s390/s390-c.cc
index 4521a86f0480..0332fb4e904b 100644
--- a/gcc/config/s390/s390-c.cc
+++ b/gcc/config/s390/s390-c.cc
@@ -29,6 +29,7 @@
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
index 25d43ae3e138..874b11274a43 100644
--- a/gcc/config/s390/s390.cc
+++ b/gcc/config/s390/s390.cc
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/sol2-cxx.cc b/gcc/config/sol2-cxx.cc
index aa558be585ef..4f5fbc602249 100644
--- a/gcc/config/sol2-cxx.cc
+++ b/gcc/config/sol2-cxx.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/vms/vms-c.cc b/gcc/config/vms/vms-c.cc
index d0620b4d7a5f..0e9fa2f14d6f 100644
--- a/gcc/config/vms/vms-c.cc
+++ b/gcc/config/vms/vms-c.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define IN_TARGET_CODE 1
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/config/xtensa/xtensa-dynconfig.cc b/gcc/config/xtensa/xtensa-dynconfig.cc
index 3bd2760e4d89..6ddc02a6e9b0 100644
--- a/gcc/config/xtensa/xtensa-dynconfig.cc
+++ b/gcc/config/xtensa/xtensa-dynconfig.cc
@@ -17,6 +17,7 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/coroutine-passes.cc b/gcc/coroutine-passes.cc
index 0f8e24f8d551..ce74a0278b3e 100644
--- a/gcc/coroutine-passes.cc
+++ b/gcc/coroutine-passes.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/coverage.cc b/gcc/coverage.cc
index 22778361da13..80941ee67ee9 100644
--- a/gcc/coverage.cc
+++ b/gcc/coverage.cc
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define GCOV_LINKAGE
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 309ab01d12d3..cc25b48d362d 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* High-level class interface.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc
index 646072d4f202..62175e77b437 100644
--- a/gcc/cp/class.cc
+++ b/gcc/cp/class.cc
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* High-level class interface.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 4e4df94f4206..ad68afef96ec 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index cf0e5d37571c..8a36b9c88c4d 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc
index 4d2849a289a1..2a55b87bd036 100644
--- a/gcc/cp/contracts.cc
+++ b/gcc/cp/contracts.cc
@@ -130,6 +130,7 @@ along with GCC; see the file COPYING3.  If not see
    More helpful for optimization might be to make the contracts a wrapper
    function that could be inlined into the caller, the callee, or both.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 86a5ac8999ac..ef64a98972ba 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
index 003e68f1ea72..68f651e96051 100644
--- a/gcc/cp/cp-gimplify.cc
+++ b/gcc/cp/cp-gimplify.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/cp-lang.cc b/gcc/cp/cp-lang.cc
index e1e2ab2e3966..3959b3194e51 100644
--- a/gcc/cp/cp-lang.cc
+++ b/gcc/cp/cp-lang.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc
index cd379514991d..7a0636f16532 100644
--- a/gcc/cp/cp-objcp-common.cc
+++ b/gcc/cp/cp-objcp-common.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/cp-ubsan.cc b/gcc/cp/cp-ubsan.cc
index c4ae0fe7eea3..1055714fa357 100644
--- a/gcc/cp/cp-ubsan.cc
+++ b/gcc/cp/cp-ubsan.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/cvt.cc b/gcc/cp/cvt.cc
index 526937d36181..54e700ceeda5 100644
--- a/gcc/cp/cvt.cc
+++ b/gcc/cp/cvt.cc
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3.  If not see
    Every language front end must have a `convert' function
    but what kind of conversions it does will depend on the language.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/cxx-pretty-print.cc b/gcc/cp/cxx-pretty-print.cc
index 41e6bdfdda50..c0608ac0b26f 100644
--- a/gcc/cp/cxx-pretty-print.cc
+++ b/gcc/cp/cxx-pretty-print.cc
@@ -18,12 +18,14 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
 #include "cp-tree.h"
 #include "cxx-pretty-print.h"
 #include "tree-pretty-print.h"
+#include "make-unique.h"
 
 static void pp_cxx_unqualified_id (cxx_pretty_printer *, tree);
 static void pp_cxx_nested_name_specifier (cxx_pretty_printer *, tree);
@@ -2927,8 +2929,8 @@ cxx_pretty_printer::cxx_pretty_printer ()
 
 /* cxx_pretty_printer's implementation of pretty_printer::clone vfunc.  */
 
-pretty_printer *
+std::unique_ptr<pretty_printer>
 cxx_pretty_printer::clone () const
 {
-  return new cxx_pretty_printer (*this);
+  return ::make_unique<cxx_pretty_printer> (*this);
 }
diff --git a/gcc/cp/cxx-pretty-print.h b/gcc/cp/cxx-pretty-print.h
index a4fcf7c71024..f0865cc9d8ca 100644
--- a/gcc/cp/cxx-pretty-print.h
+++ b/gcc/cp/cxx-pretty-print.h
@@ -34,7 +34,7 @@ class cxx_pretty_printer : public c_pretty_printer
 public:
   cxx_pretty_printer ();
 
-  pretty_printer *clone () const override;
+  std::unique_ptr<pretty_printer> clone () const override;
 
   void constant (tree) final override;
   void id_expression (tree) final override;
diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc
index a0c319086d71..a455eb481b1a 100644
--- a/gcc/cp/decl2.cc
+++ b/gcc/cp/decl2.cc
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3.  If not see
 /* ??? not all decl nodes are given the most useful possible
    line numbers.  For example, the CONST_DECLs for enum values.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/dump.cc b/gcc/cp/dump.cc
index aafb62ffaa01..8166bbfdee6e 100644
--- a/gcc/cp/dump.cc
+++ b/gcc/cp/dump.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/except.cc b/gcc/cp/except.cc
index 7b4abd1f56e5..e14a9fd3f9c9 100644
--- a/gcc/cp/except.cc
+++ b/gcc/cp/except.cc
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/expr.cc b/gcc/cp/expr.cc
index de4991e616cd..e5ec2352f57f 100644
--- a/gcc/cp/expr.cc
+++ b/gcc/cp/expr.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/friend.cc b/gcc/cp/friend.cc
index 2e70d0160c46..5261daa4994c 100644
--- a/gcc/cp/friend.cc
+++ b/gcc/cp/friend.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index f785015e4774..8b1dce594fd9 100644
--- a/gcc/cp/init.cc
+++ b/gcc/cp/init.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* High-level class interface.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc
index e17c00217b2e..4f404a11a9e6 100644
--- a/gcc/cp/lambda.cc
+++ b/gcc/cp/lambda.cc
@@ -21,6 +21,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/logic.cc b/gcc/cp/logic.cc
index fab2c357dc4e..f36abb2d4e46 100644
--- a/gcc/cp/logic.cc
+++ b/gcc/cp/logic.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "config.h"
 #define INCLUDE_LIST
+#define INCLUDE_MEMORY
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
diff --git a/gcc/cp/mangle.cc b/gcc/cp/mangle.cc
index 17988d69e1ea..828e32633578 100644
--- a/gcc/cp/mangle.cc
+++ b/gcc/cp/mangle.cc
@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3.  If not see
      mangle_ctor_vtbl_for_type:		`C-in-B' constructor virtual table data
      mangle_thunk:			thunk function or entry  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc
index d704db2af061..adffa9ba0f33 100644
--- a/gcc/cp/method.cc
+++ b/gcc/cp/method.cc
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 
 
 /* Handle method declarations.  */
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/optimize.cc b/gcc/cp/optimize.cc
index 8429d856728f..f93e0262fa76 100644
--- a/gcc/cp/optimize.cc
+++ b/gcc/cp/optimize.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 03a1144765b2..6c5810b18aab 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "config.h"
 #define INCLUDE_ALGORITHM // for std::equal
+#define INCLUDE_MEMORY
 #include "system.h"
 #include "coretypes.h"
 #include "cp-tree.h"
diff --git a/gcc/cp/ptree.cc b/gcc/cp/ptree.cc
index 15e46752d011..77bffa0b8997 100644
--- a/gcc/cp/ptree.cc
+++ b/gcc/cp/ptree.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/rtti.cc b/gcc/cp/rtti.cc
index cc006ea927f2..fff89856e6b7 100644
--- a/gcc/cp/rtti.cc
+++ b/gcc/cp/rtti.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/search.cc b/gcc/cp/search.cc
index b0421ee05247..b2d6c2491894 100644
--- a/gcc/cp/search.cc
+++ b/gcc/cp/search.cc
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* High-level class interface.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 0370d81de01f..e919944d6ed1 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 0a7a56cc6e2e..153adab76ee7 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index d1204d922bbd..b0267aeb41df 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3.  If not see
    including computing the types of the result, C and C++ specific error
    checks, and some optimization.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index 79b397a69faf..9f57020e2537 100644
--- a/gcc/cp/typeck2.cc
+++ b/gcc/cp/typeck2.cc
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
    including computing the types of the result, C and C++ specific error
    checks, and some optimization.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/cp/vtable-class-hierarchy.cc b/gcc/cp/vtable-class-hierarchy.cc
index afe1e96f5e27..7e4f613c2051 100644
--- a/gcc/cp/vtable-class-hierarchy.cc
+++ b/gcc/cp/vtable-class-hierarchy.cc
@@ -110,6 +110,7 @@ along with GCC; see the file COPYING3.  If not see
   gcc/vtable-verify.h, because they are used both here and in
   gcc/vtable-verify.cc.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/d-attribs.cc b/gcc/d/d-attribs.cc
index 0f7ca10e0175..873140ee7c8b 100644
--- a/gcc/d/d-attribs.cc
+++ b/gcc/d/d-attribs.cc
@@ -18,6 +18,7 @@ along with GCC; see the file COPYING3.  If not see
 /* Implementation of attribute handlers for user defined attributes and
    internal built-in functions.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
index 4546c0e9b563..2ca02fe691cb 100644
--- a/gcc/d/d-builtins.cc
+++ b/gcc/d/d-builtins.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 2b3089b5f6dd..eeeb48defa28 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc
index 5c79cdf6e1e4..a07c7d8ba68e 100644
--- a/gcc/d/d-convert.cc
+++ b/gcc/d/d-convert.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/d-diagnostic.cc b/gcc/d/d-diagnostic.cc
index 373075ca54de..d584d2ac2b23 100644
--- a/gcc/d/d-diagnostic.cc
+++ b/gcc/d/d-diagnostic.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/d-frontend.cc b/gcc/d/d-frontend.cc
index 0d7f4a3ec7fd..c3e5d8594adc 100644
--- a/gcc/d/d-frontend.cc
+++ b/gcc/d/d-frontend.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index 89ffa7e61ea1..2aa2a3f9767f 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/d-longdouble.cc b/gcc/d/d-longdouble.cc
index e4c8c5e6eb06..ba10a3569096 100644
--- a/gcc/d/d-longdouble.cc
+++ b/gcc/d/d-longdouble.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/d-target.cc b/gcc/d/d-target.cc
index dd46e5358918..17cae450623f 100644
--- a/gcc/d/d-target.cc
+++ b/gcc/d/d-target.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 0a87c85ae2e5..0afaa71664d5 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index d055e0b4025b..a690f2ef2cf1 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/intrinsics.cc b/gcc/d/intrinsics.cc
index c895c1a1a529..34143b343e8b 100644
--- a/gcc/d/intrinsics.cc
+++ b/gcc/d/intrinsics.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/modules.cc b/gcc/d/modules.cc
index b111ee90cea0..f9b4a1e8e412 100644
--- a/gcc/d/modules.cc
+++ b/gcc/d/modules.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/toir.cc b/gcc/d/toir.cc
index a6848f2ffa2c..2bbba1035c7f 100644
--- a/gcc/d/toir.cc
+++ b/gcc/d/toir.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/typeinfo.cc b/gcc/d/typeinfo.cc
index cadcbe8164e9..56aaf29d54eb 100644
--- a/gcc/d/typeinfo.cc
+++ b/gcc/d/typeinfo.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index 9fa2f888cb22..2f78c917de23 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/data-streamer-in.cc b/gcc/data-streamer-in.cc
index 07dbc5e2bc36..64dec35296cc 100644
--- a/gcc/data-streamer-in.cc
+++ b/gcc/data-streamer-in.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/data-streamer-out.cc b/gcc/data-streamer-out.cc
index c237e30f7048..95715436cdc5 100644
--- a/gcc/data-streamer-out.cc
+++ b/gcc/data-streamer-out.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/data-streamer.cc b/gcc/data-streamer.cc
index 896413e8d2b6..1caf72f9e965 100644
--- a/gcc/data-streamer.cc
+++ b/gcc/data-streamer.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/diagnostic-client-data-hooks.h b/gcc/diagnostic-client-data-hooks.h
index a67a3dbff479..9e2bd606378a 100644
--- a/gcc/diagnostic-client-data-hooks.h
+++ b/gcc/diagnostic-client-data-hooks.h
@@ -53,7 +53,7 @@ class diagnostic_client_data_hooks
    for use in the compiler (i.e. with knowledge of "tree", access to
    langhooks, etc).  */
 
-extern diagnostic_client_data_hooks *make_compiler_data_hooks ();
+extern std::unique_ptr<diagnostic_client_data_hooks> make_compiler_data_hooks ();
 
 class diagnostic_client_plugin_info;
 
diff --git a/gcc/diagnostic-format-json.cc b/gcc/diagnostic-format-json.cc
index b4c1f13ee671..48b836768b15 100644
--- a/gcc/diagnostic-format-json.cc
+++ b/gcc/diagnostic-format-json.cc
@@ -404,7 +404,7 @@ diagnostic_output_format_init_json (diagnostic_context &context,
   pp_show_color (fmt->get_printer ()) = false;
   context.set_show_highlight_colors (false);
 
-  context.set_output_format (fmt.release ());
+  context.set_output_format (std::move (fmt));
 }
 
 /* Populate CONTEXT in preparation for JSON output to stderr.  */
diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc
index 70832513b6d9..0e6e4f32b19f 100644
--- a/gcc/diagnostic-format-sarif.cc
+++ b/gcc/diagnostic-format-sarif.cc
@@ -3396,7 +3396,7 @@ diagnostic_output_format_init_sarif (diagnostic_context &context,
 
   context.m_printer->set_token_printer
     (&fmt->get_builder ().get_token_printer ());
-  context.set_output_format (fmt.release ());
+  context.set_output_format (std::move (fmt));
 }
 
 /* Populate CONTEXT in preparation for SARIF output to stderr.  */
@@ -3982,7 +3982,7 @@ test_message_with_embedded_link (enum sarif_version version)
     };
 
     test_sarif_diagnostic_context dc ("test.c", version);
-    dc.set_urlifier (new test_urlifier ());
+    dc.set_urlifier (::make_unique<test_urlifier> ());
     rich_location richloc (line_table, UNKNOWN_LOCATION);
     dc.report (DK_ERROR, richloc, nullptr, 0,
 	       "foo %<-foption%> %<unrecognized%> bar");
diff --git a/gcc/diagnostic-format-text.cc b/gcc/diagnostic-format-text.cc
index 0d58d5fb082d..4f599437a409 100644
--- a/gcc/diagnostic-format-text.cc
+++ b/gcc/diagnostic-format-text.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 
 
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/diagnostic-global-context.cc b/gcc/diagnostic-global-context.cc
index 9e151905a6bb..e82588e54047 100644
--- a/gcc/diagnostic-global-context.cc
+++ b/gcc/diagnostic-global-context.cc
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 /* This file implements the parts of the language independent aspect
    of diagnostic messages that implicitly use global_dc.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/diagnostic-macro-unwinding.cc b/gcc/diagnostic-macro-unwinding.cc
index a9838ffb52ca..38f827f66381 100644
--- a/gcc/diagnostic-macro-unwinding.cc
+++ b/gcc/diagnostic-macro-unwinding.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/diagnostic-show-locus.cc b/gcc/diagnostic-show-locus.cc
index 415de42cbc7b..79499dc549d3 100644
--- a/gcc/diagnostic-show-locus.cc
+++ b/gcc/diagnostic-show-locus.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/diagnostic-spec.cc b/gcc/diagnostic-spec.cc
index addaf089f035..77e4b67dc887 100644
--- a/gcc/diagnostic-spec.cc
+++ b/gcc/diagnostic-spec.cc
@@ -19,6 +19,7 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index 41656a607b81..4f8c7680a03c 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -433,19 +433,21 @@ diagnostic_context::execution_failed_p () const
 }
 
 void
-diagnostic_context::set_output_format (diagnostic_output_format *output_format)
+diagnostic_context::
+set_output_format (std::unique_ptr<diagnostic_output_format> output_format)
 {
-  /* Ideally we'd use a std::unique_ptr here.  */
   delete m_output_format;
-  m_output_format = output_format;
+  /* Ideally this field would be a std::unique_ptr.  */
+  m_output_format = output_format.release ();
 }
 
 void
-diagnostic_context::set_client_data_hooks (diagnostic_client_data_hooks *hooks)
+diagnostic_context::
+set_client_data_hooks (std::unique_ptr<diagnostic_client_data_hooks> hooks)
 {
-  /* Ideally we'd use a std::unique_ptr here.  */
   delete m_client_data_hooks;
-  m_client_data_hooks = hooks;
+  /* Ideally the field would be a std::unique_ptr here.  */
+  m_client_data_hooks = hooks.release ();
 }
 
 void
@@ -462,20 +464,21 @@ diagnostic_context::set_original_argv (unique_argv original_argv)
 }
 
 void
-diagnostic_context::set_option_manager (diagnostic_option_manager *mgr,
-					unsigned lang_mask)
+diagnostic_context::
+set_option_manager (std::unique_ptr<diagnostic_option_manager> mgr,
+		    unsigned lang_mask)
 {
   delete m_option_mgr;
-  m_option_mgr = mgr;
+  m_option_mgr = mgr.release ();
   m_lang_mask = lang_mask;
 }
 
 void
-diagnostic_context::set_urlifier (urlifier *urlifier)
+diagnostic_context::set_urlifier (std::unique_ptr<urlifier> urlifier)
 {
-  /* Ideally we'd use a std::unique_ptr here.  */
   delete m_urlifier;
-  m_urlifier = urlifier;
+  /* Ideally the field would be a std::unique_ptr here.  */
+  m_urlifier = urlifier.release ();
 }
 
 void
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index 83d73d2c4b70..60eb370a1883 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -21,6 +21,14 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_DIAGNOSTIC_H
 #define GCC_DIAGNOSTIC_H
 
+/* This header uses std::unique_ptr, but <memory> can't be directly
+   included due to issues with macros.  Hence it must be included from
+   system.h by defining INCLUDE_MEMORY in any source file using it.  */
+
+#ifndef INCLUDE_MEMORY
+# error "You must define INCLUDE_MEMORY before including system.h to use diagnostic.h"
+#endif
+
 #include "unique-argv.h"
 #include "rich-location.h"
 #include "pretty-print.h"
@@ -556,10 +564,10 @@ public:
   }
 
   /* Various setters for use by option-handling logic.  */
-  void set_output_format (diagnostic_output_format *output_format);
+  void set_output_format (std::unique_ptr<diagnostic_output_format> output_format);
   void set_text_art_charset (enum diagnostic_text_art_charset charset);
-  void set_client_data_hooks (diagnostic_client_data_hooks *hooks);
-  void set_urlifier (urlifier *);
+  void set_client_data_hooks (std::unique_ptr<diagnostic_client_data_hooks> hooks);
+  void set_urlifier (std::unique_ptr<urlifier>);
   void create_edit_context ();
   void set_warning_as_error_requested (bool val)
   {
@@ -654,7 +662,7 @@ public:
   }
 
   void
-  set_option_manager (diagnostic_option_manager *mgr,
+  set_option_manager (std::unique_ptr<diagnostic_option_manager> mgr,
 		      unsigned lang_mask);
 
   unsigned get_lang_mask () const
@@ -682,6 +690,11 @@ public:
     return m_option_classifier.pch_restore (f);
   }
 
+  std::unique_ptr<pretty_printer> clone_printer () const
+  {
+    return m_printer->clone ();
+  }
+
 private:
   void error_recursion () ATTRIBUTE_NORETURN;
 
@@ -693,11 +706,15 @@ private:
      Ideally, all of these would be private.  */
 
 public:
-  /* Where most of the diagnostic formatting work is done.  */
+  /* Where most of the diagnostic formatting work is done.
+     Owned by the context; this would be a std::unique_ptr if
+     diagnostic_context had a proper ctor.  */
   pretty_printer *m_printer;
 
 private:
-  /* Cache of source code.  */
+  /* Cache of source code.
+     Owned by the context; this would be a std::unique_ptr if
+     diagnostic_context had a proper ctor.  */
   file_cache *m_file_cache;
 
   /* The number of times we have issued diagnostics.  */
@@ -789,11 +806,15 @@ public:
   void (*m_adjust_diagnostic_info)(diagnostic_context *, diagnostic_info *);
 
 private:
+  /* Owned by the context; this would be a std::unique_ptr if
+     diagnostic_context had a proper ctor.  */
   diagnostic_option_manager *m_option_mgr;
   unsigned m_lang_mask;
 
   /* An optional hook for adding URLs to quoted text strings in
-     diagnostics.  Only used for the main diagnostic message.  */
+     diagnostics.  Only used for the main diagnostic message.
+     Owned by the context; this would be a std::unique_ptr if
+     diagnostic_context had a proper ctor.  */
   urlifier *m_urlifier;
 
 public:
@@ -836,7 +857,9 @@ private:
   enum diagnostics_escape_format m_escape_format;
 
   /* If non-NULL, an edit_context to which fix-it hints should be
-     applied, for generating patches.  */
+     applied, for generating patches.
+     Owned by the context; this would be a std::unique_ptr if
+     diagnostic_context had a proper ctor.  */
   edit_context *m_edit_context_ptr;
 
   /* Fields relating to diagnostic groups.  */
@@ -850,7 +873,9 @@ private:
   } m_diagnostic_groups;
 
   /* How to output diagnostics (text vs a structured format such as JSON).
-     Must be non-NULL; owned by context.  */
+     Must be non-NULL; owned by context.
+     This would be a std::unique_ptr if diagnostic_context had a proper
+     ctor.  */
   diagnostic_output_format *m_output_format;
 
   /* Callback to set the locations of call sites along the inlining
@@ -865,14 +890,18 @@ private:
   /* A bundle of hooks for providing data to the context about its client
      e.g. version information, plugins, etc.
      Used by SARIF output to give metadata about the client that's
-     producing diagnostics.  */
+     producing diagnostics.
+     Owned by the context; this would be a std::unique_ptr if
+     diagnostic_context had a proper ctor.  */
   diagnostic_client_data_hooks *m_client_data_hooks;
 
   /* Support for diagrams.  */
   struct
   {
     /* Theme to use when generating diagrams.
-       Can be NULL (if text art is disabled).  */
+       Can be NULL (if text art is disabled).
+       Owned by the context; this would be a std::unique_ptr if
+       diagnostic_context had a proper ctor.  */
     text_art::theme *m_theme;
 
   } m_diagrams;
diff --git a/gcc/digraph.cc b/gcc/digraph.cc
index b323764a93cd..7b2726d24fe3 100644
--- a/gcc/digraph.cc
+++ b/gcc/digraph.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 38aedb644709..fc23e4ba4601 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3.  If not see
    DW_CFA_... = DWARF2 CFA call frame instruction
    DW_TAG_... = DWARF2 DIE tag */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/edit-context.cc b/gcc/edit-context.cc
index 37ac4989de0b..f51ebf0e5158 100644
--- a/gcc/edit-context.cc
+++ b/gcc/edit-context.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/except.cc b/gcc/except.cc
index 5bb5edbd8065..4bec795010b0 100644
--- a/gcc/except.cc
+++ b/gcc/except.cc
@@ -109,6 +109,7 @@ along with GCC; see the file COPYING3.  If not see
    output_call_frame_info (dwarf2out.cc) emits the required unwind data.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/expr.cc b/gcc/expr.cc
index 7a471f20e794..85c9e5e08a69 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/file-prefix-map.cc b/gcc/file-prefix-map.cc
index 6b432e2a15af..6841559c5ed8 100644
--- a/gcc/file-prefix-map.cc
+++ b/gcc/file-prefix-map.cc
@@ -15,6 +15,7 @@
    along with this program; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/final.cc b/gcc/final.cc
index 5d911586de5b..11141f2b56c8 100644
--- a/gcc/final.cc
+++ b/gcc/final.cc
@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "config.h"
 #define INCLUDE_ALGORITHM /* reverse */
+#define INCLUDE_MEMORY
 #include "system.h"
 #include "coretypes.h"
 #include "backend.h"
diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc
index a214b8bc1b37..3ecbbd30cfa2 100644
--- a/gcc/fortran/arith.cc
+++ b/gcc/fortran/arith.cc
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
    would evaluate them.  We use the GNU MP library and the MPFR
    library to do arithmetic, and this file provides the interface.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc
index 773c5b72c851..31bdd736a9ee 100644
--- a/gcc/fortran/array.cc
+++ b/gcc/fortran/array.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/bbt.cc b/gcc/fortran/bbt.cc
index f564ce104e87..556baeec71db 100644
--- a/gcc/fortran/bbt.cc
+++ b/gcc/fortran/bbt.cc
@@ -35,6 +35,7 @@ along with GCC; see the file COPYING3.  If not see
    This implementation is based on Stefan Nilsson's article in the
    July 1997 Doctor Dobb's Journal, "Treaps in Java".  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc
index 79e6668d0afe..55cca8344415 100644
--- a/gcc/fortran/check.cc
+++ b/gcc/fortran/check.cc
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
    has been sorted into the right order and has NULL arguments in the
    correct places for missing optional arguments.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/class.cc b/gcc/fortran/class.cc
index f9e0d416e487..4b2234a958fc 100644
--- a/gcc/fortran/class.cc
+++ b/gcc/fortran/class.cc
@@ -56,6 +56,7 @@ along with GCC; see the file COPYING3.  If not see
    type-bound procedures.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/constructor.cc b/gcc/fortran/constructor.cc
index 942e26397321..8a4e11d86861 100644
--- a/gcc/fortran/constructor.cc
+++ b/gcc/fortran/constructor.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/convert.cc b/gcc/fortran/convert.cc
index 674e3f425e85..187bda64063e 100644
--- a/gcc/fortran/convert.cc
+++ b/gcc/fortran/convert.cc
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
    different data types for the translation of the gfortran internal
    representation to GIMPLE.  The only entry point is `convert'.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/cpp.cc b/gcc/fortran/cpp.cc
index 7c5f00cfd690..9d662ac5ab23 100644
--- a/gcc/fortran/cpp.cc
+++ b/gcc/fortran/cpp.cc
@@ -16,6 +16,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/data.cc b/gcc/fortran/data.cc
index d80ba66d358d..a5671d132c5a 100644
--- a/gcc/fortran/data.cc
+++ b/gcc/fortran/data.cc
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3.  If not see
    etc., to convert the initial value. Refer to trans-expr.cc and
    trans-array.cc.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 81e5e6269f6e..991555811899 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/dependency.cc b/gcc/fortran/dependency.cc
index 15edf1af9dff..2d3db9541bba 100644
--- a/gcc/fortran/dependency.cc
+++ b/gcc/fortran/dependency.cc
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
    have different dependency checking functions for different types
    if dependencies.  Ideally these would probably be merged.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc
index bc8a95a809b2..ea5d2ab66a6f 100644
--- a/gcc/fortran/dump-parse-tree.cc
+++ b/gcc/fortran/dump-parse-tree.cc
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3.  If not see
 
    TODO: Dump DATA.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/error.cc b/gcc/fortran/error.cc
index d184ffd878ad..3da6867cf259 100644
--- a/gcc/fortran/error.cc
+++ b/gcc/fortran/error.cc
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3.  If not see
    for possible use later.  If a line does not match a legal
    construction, then the saved error message is reported.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index 36baa9bb4c8e..5c64e89d7203 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/f95-lang.cc b/gcc/fortran/f95-lang.cc
index 770f31b221d6..611c299b654a 100644
--- a/gcc/fortran/f95-lang.cc
+++ b/gcc/fortran/f95-lang.cc
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* declare required prototypes: */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc
index c7cb9d2a3892..24c71807aeeb 100644
--- a/gcc/fortran/frontend-passes.cc
+++ b/gcc/fortran/frontend-passes.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc
index b592fe4f6c7f..ca5d4aa10282 100644
--- a/gcc/fortran/interface.cc
+++ b/gcc/fortran/interface.cc
@@ -63,6 +63,7 @@ along with GCC; see the file COPYING3.  If not see
    formal argument list points to symbols within the same namespace as
    the program unit name.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/intrinsic.cc b/gcc/fortran/intrinsic.cc
index c6fb0a6de45a..61558d487502 100644
--- a/gcc/fortran/intrinsic.cc
+++ b/gcc/fortran/intrinsic.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/io.cc b/gcc/fortran/io.cc
index 6fd69f7c9a8f..7c519f8f0cfa 100644
--- a/gcc/fortran/io.cc
+++ b/gcc/fortran/io.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/iresolve.cc b/gcc/fortran/iresolve.cc
index 9fb221284928..d8b216bcc67c 100644
--- a/gcc/fortran/iresolve.cc
+++ b/gcc/fortran/iresolve.cc
@@ -26,6 +26,7 @@ along with GCC; see the file COPYING3.  If not see
    code node is passed.  The result type and library subroutine name
    are generally set according to the function arguments.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc
index 0cd78a57a2f7..f3b21cddae8a 100644
--- a/gcc/fortran/match.cc
+++ b/gcc/fortran/match.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/matchexp.cc b/gcc/fortran/matchexp.cc
index 9e773cf8feeb..f7185d5aa4ff 100644
--- a/gcc/fortran/matchexp.cc
+++ b/gcc/fortran/matchexp.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/misc.cc b/gcc/fortran/misc.cc
index 991829516efe..0ef6679fee9c 100644
--- a/gcc/fortran/misc.cc
+++ b/gcc/fortran/misc.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/module.cc b/gcc/fortran/module.cc
index 880aef2c7a89..9ab4d2bf1ea3 100644
--- a/gcc/fortran/module.cc
+++ b/gcc/fortran/module.cc
@@ -64,6 +64,7 @@ along with GCC; see the file COPYING3.  If not see
    which are zero based.  Symbols are written to the module in no
    particular order.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 2c12f5e362d6..d9e1372c75fb 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #define INCLUDE_VECTOR
 #define INCLUDE_STRING
 #include "config.h"
diff --git a/gcc/fortran/options.cc b/gcc/fortran/options.cc
index a55f1f36f3f9..db7bfa001009 100644
--- a/gcc/fortran/options.cc
+++ b/gcc/fortran/options.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc
index 9e06dbf0911d..f1ec2ba14b89 100644
--- a/gcc/fortran/parse.cc
+++ b/gcc/fortran/parse.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc
index c11359a559b2..99a6e71d9f48 100644
--- a/gcc/fortran/primary.cc
+++ b/gcc/fortran/primary.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index ebe449e71190..527eee49efe3 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/scanner.cc b/gcc/fortran/scanner.cc
index 0631e7b8284c..4e835d47570a 100644
--- a/gcc/fortran/scanner.cc
+++ b/gcc/fortran/scanner.cc
@@ -40,6 +40,7 @@ along with GCC; see the file COPYING3.  If not see
    From the scanner's viewpoint, the higher level subroutines ask for
    new characters and do a lot of jumping backwards.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index 2f6c3c39dad8..1e2fa3eb8ea2 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/st.cc b/gcc/fortran/st.cc
index 904b00080705..076b642483da 100644
--- a/gcc/fortran/st.cc
+++ b/gcc/fortran/st.cc
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
    GENERIC tree structures and from there to executable code for a
    target.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index 557bd3bcc34c..513ff7cad327 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/target-memory.cc b/gcc/fortran/target-memory.cc
index c71c40320900..235ecc49e399 100644
--- a/gcc/fortran/target-memory.cc
+++ b/gcc/fortran/target-memory.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 0b8ef0b5e018..f77d408f52f5 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -75,6 +75,7 @@ along with GCC; see the file COPYING3.  If not see
    After the loop code has been added into its parent scope gfc_cleanup_loop
    is called to free all the SS allocated by the scalarizer.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/trans-common.cc b/gcc/fortran/trans-common.cc
index 481d468040e0..b2b92d39cbeb 100644
--- a/gcc/fortran/trans-common.cc
+++ b/gcc/fortran/trans-common.cc
@@ -94,6 +94,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "config.h"
 #define INCLUDE_MAP
+#define INCLUDE_MEMORY
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
diff --git a/gcc/fortran/trans-const.cc b/gcc/fortran/trans-const.cc
index 204f4df301c0..9c2d683b1a16 100644
--- a/gcc/fortran/trans-const.cc
+++ b/gcc/fortran/trans-const.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* trans-const.cc -- convert constant values */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 56b6202510e8..1ea8de378b52 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* trans-decl.cc -- Handling of backend function and variable decls, etc */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index b9f585d0d2f1..c71922254431 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* trans-expr.cc-- generate GENERIC trees for gfc_expr.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc
index 80d75f26b095..20ccbb123c68 100644
--- a/gcc/fortran/trans-intrinsic.cc
+++ b/gcc/fortran/trans-intrinsic.cc
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* trans-intrinsic.cc-- generate GENERIC trees for calls to intrinsics.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/trans-io.cc b/gcc/fortran/trans-io.cc
index f3580ce42b5e..83caeb2b8745 100644
--- a/gcc/fortran/trans-io.cc
+++ b/gcc/fortran/trans-io.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index d3783f56a693..01ef51937174 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc
index 86c549704751..d6baa8da9007 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index d59c0cc19d4f..d3cbbc170805 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.  If not see
 
 /* trans-types.cc -- gfortran backend types */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc
index 2c5133a8e05e..7407f0af90dd 100644
--- a/gcc/fortran/trans.cc
+++ b/gcc/fortran/trans.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/fwprop.cc b/gcc/fwprop.cc
index 2ebb2f146cc6..8cba6b7ce9fa 100644
--- a/gcc/fwprop.cc
+++ b/gcc/fwprop.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #define INCLUDE_ALGORITHM
 #define INCLUDE_FUNCTIONAL
+#define INCLUDE_MEMORY
 #define INCLUDE_ARRAY
 #include "config.h"
 #include "system.h"
diff --git a/gcc/gcc-rich-location.cc b/gcc/gcc-rich-location.cc
index 568744b39a31..0fa9db8e66db 100644
--- a/gcc/gcc-rich-location.cc
+++ b/gcc/gcc-rich-location.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gcc-urlifier.cc b/gcc/gcc-urlifier.cc
index be6459e8d7c1..0db5429395eb 100644
--- a/gcc/gcc-urlifier.cc
+++ b/gcc/gcc-urlifier.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
@@ -27,6 +28,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "opts.h"
 #include "options.h"
 #include "selftest.h"
+#include "make-unique.h"
 
 namespace {
 
@@ -213,10 +215,10 @@ gcc_urlifier::make_doc_url (const char *doc_url_suffix)
 
 } // anonymous namespace
 
-urlifier *
+std::unique_ptr<urlifier>
 make_gcc_urlifier (unsigned int lang_mask)
 {
-  return new gcc_urlifier (lang_mask);
+  return ::make_unique<gcc_urlifier> (lang_mask);
 }
 
 #if CHECKING_P
diff --git a/gcc/gcc-urlifier.h b/gcc/gcc-urlifier.h
index 660d4f8828e7..c4cd03cc34ae 100644
--- a/gcc/gcc-urlifier.h
+++ b/gcc/gcc-urlifier.h
@@ -21,6 +21,6 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_GCC_URLIFIER_H
 #define GCC_GCC_URLIFIER_H
 
-extern urlifier *make_gcc_urlifier (unsigned int lang_mask);
+extern std::unique_ptr<urlifier> make_gcc_urlifier (unsigned int lang_mask);
 
 #endif /* GCC_GCC_URLIFIER_H */
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 16fed46fb35f..9998fd33343f 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -27,6 +27,7 @@ CC recognizes how to compile each input file by suffixes in the file names.
 Once it knows which kind of compilation to perform, the procedure for
 compilation is specified by a string called a "spec".  */
 
+#define INCLUDE_MEMORY
 #define INCLUDE_STRING
 #include "config.h"
 #include "system.h"
@@ -41,6 +42,7 @@ compilation is specified by a string called a "spec".  */
 #include "gcc.h"
 #include "diagnostic.h"
 #include "diagnostic-format.h"
+#include "pretty-print-urlifier.h"
 #include "flags.h"
 #include "opts.h"
 #include "filenames.h"
diff --git a/gcc/gcov-dump.cc b/gcc/gcov-dump.cc
index 375058c3c7b7..7f44fa9756b2 100644
--- a/gcc/gcov-dump.cc
+++ b/gcc/gcov-dump.cc
@@ -17,6 +17,7 @@ along with Gcov; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gcov-tool.cc b/gcc/gcov-tool.cc
index 100f7357bcf8..0f3c5c751102 100644
--- a/gcc/gcov-tool.cc
+++ b/gcc/gcov-tool.cc
@@ -23,6 +23,7 @@ a copy of the GCC Runtime Library Exception along with this program;
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gengtype.cc b/gcc/gengtype.cc
index c0ecbe8558b1..4cd0974966d9 100644
--- a/gcc/gengtype.cc
+++ b/gcc/gengtype.cc
@@ -1724,6 +1724,7 @@ open_base_files (void)
     outf_p gtype_desc_c;
 
     gtype_desc_c = create_file ("GCC", "gtype-desc.cc");
+    oprintf (gtype_desc_c, "#define INCLUDE_MEMORY\n");
     for (ifp = ifiles; *ifp; ifp++)
       oprintf (gtype_desc_c, "#include \"%s\"\n", *ifp);
     for (int j = 0; j < (int) num_build_headers; j++)
diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 9a84483f9bff..6f0e8b334ae0 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-harden-conditionals.cc b/gcc/gimple-harden-conditionals.cc
index 4ab086e1ab0b..7bfa75a5bd6d 100644
--- a/gcc/gimple-harden-conditionals.cc
+++ b/gcc/gimple-harden-conditionals.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-harden-control-flow.cc b/gcc/gimple-harden-control-flow.cc
index 70383e6e2658..f5654c3bb9f6 100644
--- a/gcc/gimple-harden-control-flow.cc
+++ b/gcc/gimple-harden-control-flow.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "config.h"
 #define INCLUDE_ALGORITHM /* find */
+#define INCLUDE_MEMORY
 #include "system.h"
 #include "coretypes.h"
 #include "backend.h"
diff --git a/gcc/gimple-if-to-switch.cc b/gcc/gimple-if-to-switch.cc
index 96ce1c380a59..4246e12606f9 100644
--- a/gcc/gimple-if-to-switch.cc
+++ b/gcc/gimple-if-to-switch.cc
@@ -28,6 +28,7 @@ along with GCC; see the file COPYING3.  If not see
    d) We move all GIMPLE statements in the removed blocks into the
       first one.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc
index 58deaf253e93..1d1e300643c7 100644
--- a/gcc/gimple-lower-bitint.cc
+++ b/gcc/gimple-lower-bitint.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-predicate-analysis.cc b/gcc/gimple-predicate-analysis.cc
index 01688b8581bc..6b9043cc2dd0 100644
--- a/gcc/gimple-predicate-analysis.cc
+++ b/gcc/gimple-predicate-analysis.cc
@@ -20,6 +20,7 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #define INCLUDE_STRING
 #include "config.h"
 #include "system.h"
diff --git a/gcc/gimple-pretty-print.cc b/gcc/gimple-pretty-print.cc
index 01d7c9f6eebd..30da3af36bdf 100644
--- a/gcc/gimple-pretty-print.cc
+++ b/gcc/gimple-pretty-print.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index 035076be5d87..4210841645c0 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-range-edge.cc b/gcc/gimple-range-edge.cc
index 0c75ad0519c0..6e082ffc9e8d 100644
--- a/gcc/gimple-range-edge.cc
+++ b/gcc/gimple-range-edge.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index 65d31adde54c..b02b0d329453 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
index f2e2b5049aaa..f5103fd0e98f 100644
--- a/gcc/gimple-range-gori.cc
+++ b/gcc/gimple-range-gori.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-range-infer.cc b/gcc/gimple-range-infer.cc
index 98642e2438fc..dd748248eaa5 100644
--- a/gcc/gimple-range-infer.cc
+++ b/gcc/gimple-range-infer.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc
index 68a7df8d01bc..030030cb1562 100644
--- a/gcc/gimple-range-op.cc
+++ b/gcc/gimple-range-op.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc
index f64a7a5e8cae..85c3d15c9039 100644
--- a/gcc/gimple-range-path.cc
+++ b/gcc/gimple-range-path.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-range-phi.cc b/gcc/gimple-range-phi.cc
index c679e4ed7f29..aeb6c400ae93 100644
--- a/gcc/gimple-range-phi.cc
+++ b/gcc/gimple-range-phi.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-range-trace.cc b/gcc/gimple-range-trace.cc
index e1679a1bfc9f..5302646ed49f 100644
--- a/gcc/gimple-range-trace.cc
+++ b/gcc/gimple-range-trace.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index 7ba7d464b5ea..e250b26281e3 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-ssa-backprop.cc b/gcc/gimple-ssa-backprop.cc
index e3374b181386..ea3ae0bf0438 100644
--- a/gcc/gimple-ssa-backprop.cc
+++ b/gcc/gimple-ssa-backprop.cc
@@ -84,6 +84,7 @@ along with GCC; see the file COPYING3.  If not see
    Note that this pass does not deal with direct redundancies,
    such as cos(-x)->cos(x).  match.pd handles those cases instead.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-ssa-sprintf.cc b/gcc/gimple-ssa-sprintf.cc
index 0900710647c4..2e06b9112f0b 100644
--- a/gcc/gimple-ssa-sprintf.cc
+++ b/gcc/gimple-ssa-sprintf.cc
@@ -45,6 +45,7 @@ along with GCC; see the file COPYING3.  If not see
    character arrays that a character pointer may point to as a bound
    on the longest string.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-ssa-store-merging.cc b/gcc/gimple-ssa-store-merging.cc
index 7dba4a7a781f..99103076945e 100644
--- a/gcc/gimple-ssa-store-merging.cc
+++ b/gcc/gimple-ssa-store-merging.cc
@@ -138,6 +138,7 @@
   [p]      (32-bit) := 0x12345678; // (val & 0xffffffff0000) >> 16;
   [p + 4B] (16-bit) := 0xabcd;     //  val & 0x00000000ffff;  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-ssa-strength-reduction.cc b/gcc/gimple-ssa-strength-reduction.cc
index 39cd9339c778..13e05b094de4 100644
--- a/gcc/gimple-ssa-strength-reduction.cc
+++ b/gcc/gimple-ssa-strength-reduction.cc
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
    If desired, it could be extended to floating-point operations under
    control of something like -funsafe-math-optimizations.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc
index 950d96bf9d62..904ec2bf3243 100644
--- a/gcc/gimple-ssa-warn-access.cc
+++ b/gcc/gimple-ssa-warn-access.cc
@@ -20,6 +20,7 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #define INCLUDE_STRING
 #include "config.h"
 #include "system.h"
diff --git a/gcc/gimple-ssa-warn-alloca.cc b/gcc/gimple-ssa-warn-alloca.cc
index f12e55bc7957..c85f5c773121 100644
--- a/gcc/gimple-ssa-warn-alloca.cc
+++ b/gcc/gimple-ssa-warn-alloca.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-ssa-warn-restrict.cc b/gcc/gimple-ssa-warn-restrict.cc
index d71f1331c854..4bccca52f0d1 100644
--- a/gcc/gimple-ssa-warn-restrict.cc
+++ b/gcc/gimple-ssa-warn-restrict.cc
@@ -19,6 +19,7 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-streamer-in.cc b/gcc/gimple-streamer-in.cc
index 61f6d069875f..d7843c5ecaae 100644
--- a/gcc/gimple-streamer-in.cc
+++ b/gcc/gimple-streamer-in.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple-streamer-out.cc b/gcc/gimple-streamer-out.cc
index e63d8b4df0cc..f30f06ee720c 100644
--- a/gcc/gimple-streamer-out.cc
+++ b/gcc/gimple-streamer-out.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimple.cc b/gcc/gimple.cc
index 6e28cf291e16..13aa3d27844d 100644
--- a/gcc/gimple.cc
+++ b/gcc/gimple.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 3f602469d571..29fde04568cd 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/go/go-backend.cc b/gcc/go/go-backend.cc
index 25e5d35e6f1e..69dbef664151 100644
--- a/gcc/go/go-backend.cc
+++ b/gcc/go/go-backend.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/go/go-lang.cc b/gcc/go/go-lang.cc
index 9316425b2aaf..42a21594f358 100644
--- a/gcc/go/go-lang.cc
+++ b/gcc/go/go-lang.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/graph.cc b/gcc/graph.cc
index 07da0798f51d..677dc50b61bc 100644
--- a/gcc/graph.cc
+++ b/gcc/graph.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/graphviz.cc b/gcc/graphviz.cc
index e41c8bc0ef38..daa970669533 100644
--- a/gcc/graphviz.cc
+++ b/gcc/graphviz.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/input.cc b/gcc/input.cc
index 9f5228d255c0..04462ef6f5a7 100644
--- a/gcc/input.cc
+++ b/gcc/input.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index fa7bd6a15da7..212d9ccbbfe0 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -101,6 +101,7 @@ along with GCC; see the file COPYING3.  If not see
    the second stage.  */
 
 #define INCLUDE_ALGORITHM
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc
index a7ce434bffb4..b77adcac8fa0 100644
--- a/gcc/ipa-devirt.cc
+++ b/gcc/ipa-devirt.cc
@@ -105,6 +105,7 @@ along with GCC; see the file COPYING3.  If not see
   pass_ipa_devirt performs simple speculative devirtualization.
 */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-fnsummary.cc b/gcc/ipa-fnsummary.cc
index b38247834065..42e3efc53b6d 100644
--- a/gcc/ipa-fnsummary.cc
+++ b/gcc/ipa-fnsummary.cc
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see
    inlined performs analysis via its analyze_function method. */
 
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-free-lang-data.cc b/gcc/ipa-free-lang-data.cc
index 3ad203fec4c2..80e30f587540 100644
--- a/gcc/ipa-free-lang-data.cc
+++ b/gcc/ipa-free-lang-data.cc
@@ -29,6 +29,7 @@
    It is intended to be language-independent but can occasionally
    calls language-dependent routines.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-icf-gimple.cc b/gcc/ipa-icf-gimple.cc
index 31f6cdbda060..73fc56557fe7 100644
--- a/gcc/ipa-icf-gimple.cc
+++ b/gcc/ipa-icf-gimple.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-icf.cc b/gcc/ipa-icf.cc
index 6f9941522c8f..29cff3127a39 100644
--- a/gcc/ipa-icf.cc
+++ b/gcc/ipa-icf.cc
@@ -51,6 +51,7 @@ along with GCC; see the file COPYING3.  If not see
 
 */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-inline-analysis.cc b/gcc/ipa-inline-analysis.cc
index a190cb6501b8..e52199872cf4 100644
--- a/gcc/ipa-inline-analysis.cc
+++ b/gcc/ipa-inline-analysis.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-inline.cc b/gcc/ipa-inline.cc
index 9fc41b7696d8..adabb7b6ee27 100644
--- a/gcc/ipa-inline.cc
+++ b/gcc/ipa-inline.cc
@@ -89,6 +89,7 @@ along with GCC; see the file COPYING3.  If not see
 	 This should almost always lead to reduction of code size by eliminating
 	 the need for offline copy of the function.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-modref-tree.cc b/gcc/ipa-modref-tree.cc
index 961d46621a0c..4bf7158535c5 100644
--- a/gcc/ipa-modref-tree.cc
+++ b/gcc/ipa-modref-tree.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-modref.cc b/gcc/ipa-modref.cc
index 19359662f8ff..c1973aa36c4c 100644
--- a/gcc/ipa-modref.cc
+++ b/gcc/ipa-modref.cc
@@ -53,6 +53,7 @@ along with GCC; see the file COPYING3.  If not see
        That is a vector recording what function parameters
        may escape to a function call (and with what parameter index).  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-param-manipulation.cc b/gcc/ipa-param-manipulation.cc
index ad36b8389c00..e1f6f3db2999 100644
--- a/gcc/ipa-param-manipulation.cc
+++ b/gcc/ipa-param-manipulation.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #define INCLUDE_ALGORITHM
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-polymorphic-call.cc b/gcc/ipa-polymorphic-call.cc
index 81de6d7fc33a..f676357d5902 100644
--- a/gcc/ipa-polymorphic-call.cc
+++ b/gcc/ipa-polymorphic-call.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-predicate.cc b/gcc/ipa-predicate.cc
index 164aba4a1266..fbe1d6d917d0 100644
--- a/gcc/ipa-predicate.cc
+++ b/gcc/ipa-predicate.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-profile.cc b/gcc/ipa-profile.cc
index 27f411ce81a0..88e7523c0f24 100644
--- a/gcc/ipa-profile.cc
+++ b/gcc/ipa-profile.cc
@@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
      once, executed at startup and executed at exit.  These flags are used to
      control code size/performance threshold and code placement (by producing
      .text.unlikely/.text.hot/.text.startup/.text.exit subsections).  */
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
index 78d1fb7086d5..e96ade34b34c 100644
--- a/gcc/ipa-prop.cc
+++ b/gcc/ipa-prop.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-pure-const.cc b/gcc/ipa-pure-const.cc
index b5a1dcdc154f..79fde2449d2d 100644
--- a/gcc/ipa-pure-const.cc
+++ b/gcc/ipa-pure-const.cc
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3.  If not see
    should be one of the later passes since it's information is used by
    the rest of the compilation. */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-reference.cc b/gcc/ipa-reference.cc
index 4c8a362b57b7..2930888e356a 100644
--- a/gcc/ipa-reference.cc
+++ b/gcc/ipa-reference.cc
@@ -36,6 +36,7 @@ along with GCC; see the file COPYING3.  If not see
    traumatic, promote some statics to registers, and improve aliasing
    information.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-split.cc b/gcc/ipa-split.cc
index caf6279ab218..eb1f7937a0ba 100644
--- a/gcc/ipa-split.cc
+++ b/gcc/ipa-split.cc
@@ -74,6 +74,7 @@ along with GCC; see the file COPYING3.  If not see
    7) There is nothing preventing us from producing multiple parts of single function
       when needed or splitting also the parts.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-sra.cc b/gcc/ipa-sra.cc
index 6d6da4089251..9d8dfdb79b13 100644
--- a/gcc/ipa-sra.cc
+++ b/gcc/ipa-sra.cc
@@ -56,6 +56,7 @@ along with GCC; see the file COPYING3.  If not see
    ipa-param-manipulation.h for more details.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc
index 8fa7bdf53002..6dbef204de60 100644
--- a/gcc/ipa-strub.cc
+++ b/gcc/ipa-strub.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ipa-utils.cc b/gcc/ipa-utils.cc
index dbfc60ff8acb..1be96f185da2 100644
--- a/gcc/ipa-utils.cc
+++ b/gcc/ipa-utils.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/jit/dummy-frontend.cc b/gcc/jit/dummy-frontend.cc
index 17f37a3f405a..12167829b277 100644
--- a/gcc/jit/dummy-frontend.cc
+++ b/gcc/jit/dummy-frontend.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
index 583956fb4635..e732c2287518 100644
--- a/gcc/jit/jit-playback.cc
+++ b/gcc/jit/jit-playback.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_MUTEX
 #include "libgccjit.h"
 #include "system.h"
diff --git a/gcc/jit/jit-recording.cc b/gcc/jit/jit-recording.cc
index cc7f529c9e8a..83a36db653de 100644
--- a/gcc/jit/jit-recording.cc
+++ b/gcc/jit/jit-recording.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_SSTREAM
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/langhooks.cc b/gcc/langhooks.cc
index 54fc94e4364e..fe32be449560 100644
--- a/gcc/langhooks.cc
+++ b/gcc/langhooks.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/late-combine.cc b/gcc/late-combine.cc
index 1d81b386c3d6..1b6cd0bea2c1 100644
--- a/gcc/late-combine.cc
+++ b/gcc/late-combine.cc
@@ -30,6 +30,7 @@
 
 #define INCLUDE_ALGORITHM
 #define INCLUDE_FUNCTIONAL
+#define INCLUDE_MEMORY
 #define INCLUDE_ARRAY
 #include "config.h"
 #include "system.h"
diff --git a/gcc/lto-cgraph.cc b/gcc/lto-cgraph.cc
index 1d4311a8832b..e1d19f909dd6 100644
--- a/gcc/lto-cgraph.cc
+++ b/gcc/lto-cgraph.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/lto-compress.cc b/gcc/lto-compress.cc
index bebf0277ef67..1895bb433458 100644
--- a/gcc/lto-compress.cc
+++ b/gcc/lto-compress.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/lto-opts.cc b/gcc/lto-opts.cc
index a3a1d110329c..93ac83081f63 100644
--- a/gcc/lto-opts.cc
+++ b/gcc/lto-opts.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/lto-section-in.cc b/gcc/lto-section-in.cc
index fc2ba1906e19..22c203b22625 100644
--- a/gcc/lto-section-in.cc
+++ b/gcc/lto-section-in.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/lto-section-out.cc b/gcc/lto-section-out.cc
index d9c42653713f..c05e97133b74 100644
--- a/gcc/lto-section-out.cc
+++ b/gcc/lto-section-out.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/lto-streamer-in.cc b/gcc/lto-streamer-in.cc
index 15181c3f5746..c541a0524c8f 100644
--- a/gcc/lto-streamer-in.cc
+++ b/gcc/lto-streamer-in.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/lto-streamer-out.cc b/gcc/lto-streamer-out.cc
index 807b935537be..19cbd549bc63 100644
--- a/gcc/lto-streamer-out.cc
+++ b/gcc/lto-streamer-out.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/lto-streamer.cc b/gcc/lto-streamer.cc
index 40ca6b2da1b8..884861d4dd15 100644
--- a/gcc/lto-streamer.cc
+++ b/gcc/lto-streamer.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/lto-wrapper.cc b/gcc/lto-wrapper.cc
index 9d7fe18b2296..a8bf847eb8c4 100644
--- a/gcc/lto-wrapper.cc
+++ b/gcc/lto-wrapper.cc
@@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
    ./ccCJuXGv.lto.ltrans.o
 */
 
+#define INCLUDE_MEMORY
 #define INCLUDE_STRING
 #include "config.h"
 #include "system.h"
@@ -52,6 +53,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "opts-diagnostic.h"
 #include "opt-suggestions.h"
 #include "opts-jobserver.h"
+#include "make-unique.h"
 
 /* Environment variable, used for passing the names of offload targets from GCC
    driver to lto-wrapper.  */
@@ -2174,7 +2176,8 @@ main (int argc, char *argv[])
   diagnostic_initialize (global_dc, 0);
   diagnostic_color_init (global_dc);
   diagnostic_urls_init (global_dc);
-  global_dc->set_option_manager (new lto_diagnostic_option_manager (), 0);
+  global_dc->set_option_manager
+    (::make_unique<lto_diagnostic_option_manager> (), 0);
 
   if (atexit (lto_wrapper_cleanup) != 0)
     fatal_error (input_location, "%<atexit%> failed");
diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc
index 34aa63b179cd..77607751db52 100644
--- a/gcc/lto/lto-common.cc
+++ b/gcc/lto/lto-common.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/lto/lto-dump.cc b/gcc/lto/lto-dump.cc
index b570bccf8edd..be869c29431a 100644
--- a/gcc/lto/lto-dump.cc
+++ b/gcc/lto/lto-dump.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/lto/lto-partition.cc b/gcc/lto/lto-partition.cc
index 2238650fa0eb..2267b4edaf4f 100644
--- a/gcc/lto/lto-partition.cc
+++ b/gcc/lto/lto-partition.cc
@@ -18,6 +18,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/lto/lto-symtab.cc b/gcc/lto/lto-symtab.cc
index a40218beac55..b12937c6a0ad 100644
--- a/gcc/lto/lto-symtab.cc
+++ b/gcc/lto/lto-symtab.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/lto/lto.cc b/gcc/lto/lto.cc
index 1ee215d8f1d3..e5b24f243704 100644
--- a/gcc/lto/lto.cc
+++ b/gcc/lto/lto.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #define INCLUDE_STRING
 #include "config.h"
 #include "system.h"
diff --git a/gcc/m2/gm2-gcc/gcc-consolidation.h b/gcc/m2/gm2-gcc/gcc-consolidation.h
index 637ec0bcc54e..e0a94eeb279d 100644
--- a/gcc/m2/gm2-gcc/gcc-consolidation.h
+++ b/gcc/m2/gm2-gcc/gcc-consolidation.h
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/m2/gm2-gcc/m2configure.cc b/gcc/m2/gm2-gcc/m2configure.cc
index 9e0e82f86c01..d55d6c25e8fd 100644
--- a/gcc/m2/gm2-gcc/m2configure.cc
+++ b/gcc/m2/gm2-gcc/m2configure.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GNU Modula-2; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "libiberty.h"
diff --git a/gcc/multiple_target.cc b/gcc/multiple_target.cc
index 1fdd279da04a..d2c9671fc1bd 100644
--- a/gcc/multiple_target.cc
+++ b/gcc/multiple_target.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/objc/objc-act.cc b/gcc/objc/objc-act.cc
index cec64c4bfbd4..58d465f6c339 100644
--- a/gcc/objc/objc-act.cc
+++ b/gcc/objc/objc-act.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/objc/objc-encoding.cc b/gcc/objc/objc-encoding.cc
index 7cb0e5add7ba..d0078eb23be3 100644
--- a/gcc/objc/objc-encoding.cc
+++ b/gcc/objc/objc-encoding.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/objc/objc-gnu-runtime-abi-01.cc b/gcc/objc/objc-gnu-runtime-abi-01.cc
index 2eca5f4446bb..1f504f437f52 100644
--- a/gcc/objc/objc-gnu-runtime-abi-01.cc
+++ b/gcc/objc/objc-gnu-runtime-abi-01.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/objc/objc-lang.cc b/gcc/objc/objc-lang.cc
index b0b3e138ba31..430b6b2cb035 100644
--- a/gcc/objc/objc-lang.cc
+++ b/gcc/objc/objc-lang.cc
@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/objc/objc-next-runtime-abi-01.cc b/gcc/objc/objc-next-runtime-abi-01.cc
index 32a8d694b0ec..60cd7637bf6a 100644
--- a/gcc/objc/objc-next-runtime-abi-01.cc
+++ b/gcc/objc/objc-next-runtime-abi-01.cc
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
    of additions made for properties and optional protocol methods as
    ABI=1 (module version 7).  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/objc/objc-next-runtime-abi-02.cc b/gcc/objc/objc-next-runtime-abi-02.cc
index 248ef641281f..a9614e65dd3b 100644
--- a/gcc/objc/objc-next-runtime-abi-02.cc
+++ b/gcc/objc/objc-next-runtime-abi-02.cc
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
    This version is intended to match (logically) the output of Apple's
    4.2.1 compiler.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/objc/objc-runtime-shared-support.cc b/gcc/objc/objc-runtime-shared-support.cc
index 21a88224a0a8..bd40195a413c 100644
--- a/gcc/objc/objc-runtime-shared-support.cc
+++ b/gcc/objc/objc-runtime-shared-support.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/objcp/objcp-decl.cc b/gcc/objcp/objcp-decl.cc
index 1c8912f6aa0c..9d100c926c37 100644
--- a/gcc/objcp/objcp-decl.cc
+++ b/gcc/objcp/objcp-decl.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/objcp/objcp-lang.cc b/gcc/objcp/objcp-lang.cc
index 83447f8cb589..3b54050f029c 100644
--- a/gcc/objcp/objcp-lang.cc
+++ b/gcc/objcp/objcp-lang.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/omp-expand.cc b/gcc/omp-expand.cc
index 9ff9553c3ead..0c3f98627509 100644
--- a/gcc/omp-expand.cc
+++ b/gcc/omp-expand.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/omp-general.cc b/gcc/omp-general.cc
index f4c5f5770474..f74b9bf5e96c 100644
--- a/gcc/omp-general.cc
+++ b/gcc/omp-general.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
index da2051b02797..6f7b740788df 100644
--- a/gcc/omp-low.cc
+++ b/gcc/omp-low.cc
@@ -22,6 +22,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/omp-oacc-neuter-broadcast.cc b/gcc/omp-oacc-neuter-broadcast.cc
index 64a596cf0eca..651284ba35f3 100644
--- a/gcc/omp-oacc-neuter-broadcast.cc
+++ b/gcc/omp-oacc-neuter-broadcast.cc
@@ -18,6 +18,7 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/omp-offload.cc b/gcc/omp-offload.cc
index 934fbd80bdd1..5c9853682411 100644
--- a/gcc/omp-offload.cc
+++ b/gcc/omp-offload.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/omp-simd-clone.cc b/gcc/omp-simd-clone.cc
index 864586207ee8..14a37f709482 100644
--- a/gcc/omp-simd-clone.cc
+++ b/gcc/omp-simd-clone.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
index 0eccb1951ef7..551cc5cf138e 100644
--- a/gcc/optc-gen.awk
+++ b/gcc/optc-gen.awk
@@ -158,6 +158,7 @@ for (i = 0; i < n_opts; i++) {
 
 print "/* This file is auto-generated by optc-gen.awk.  */"
 print ""
+print "#define INCLUDE_MEMORY"
 n_headers = split(header_name, headers, " ")
 for (i = 1; i <= n_headers; i++)
 	print "#include " quote headers[i] quote
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index b1289c281e7b..6fa10c5171ff 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -31,6 +31,7 @@
 END {
 print "/* This file is auto-generated by optc-save-gen.awk.  */"
 print ""
+print "#define INCLUDE_MEMORY"
 n_headers = split(header_name, headers, " ")
 for (i = 1; i <= n_headers; i++)
 	print "#include " quote headers[i] quote
diff --git a/gcc/options-urls-cc-gen.awk b/gcc/options-urls-cc-gen.awk
index a2933233abef..33715a6c1d2c 100644
--- a/gcc/options-urls-cc-gen.awk
+++ b/gcc/options-urls-cc-gen.awk
@@ -29,6 +29,7 @@ END {
 
 print "/* This file is auto-generated by options-urls-cc-gen.awk.  */"
 print ""
+print "#define INCLUDE_MEMORY"
 n_headers = split(header_name, headers, " ")
 for (i = 1; i <= n_headers; i++)
 	print "#include " quote headers[i] quote
diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc
index 70ac225e3968..ac0e2bdc61de 100644
--- a/gcc/opts-common.cc
+++ b/gcc/opts-common.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #define INCLUDE_STRING
 #include "config.h"
 #include "system.h"
diff --git a/gcc/opts-global.cc b/gcc/opts-global.cc
index a9bc0d53b586..893d29936b51 100644
--- a/gcc/opts-global.cc
+++ b/gcc/opts-global.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/opts.cc b/gcc/opts.cc
index acd53befdbfc..1c5092e22feb 100644
--- a/gcc/opts.cc
+++ b/gcc/opts.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "intl.h"
diff --git a/gcc/pair-fusion.cc b/gcc/pair-fusion.cc
index 653055fdcf67..7c18ecde620e 100644
--- a/gcc/pair-fusion.cc
+++ b/gcc/pair-fusion.cc
@@ -20,6 +20,7 @@
 #define INCLUDE_ALGORITHM
 #define INCLUDE_FUNCTIONAL
 #define INCLUDE_LIST
+#define INCLUDE_MEMORY
 #define INCLUDE_TYPE_TRAITS
 #define INCLUDE_ARRAY
 #include "config.h"
diff --git a/gcc/passes.cc b/gcc/passes.cc
index b5475fce5228..6023c056ea30 100644
--- a/gcc/passes.cc
+++ b/gcc/passes.cc
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
    in the proper order, and counts the time used by each.
    Error messages and low-level interface to malloc also handled here.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/pointer-query.cc b/gcc/pointer-query.cc
index a85c04128ffb..fea69c8e5915 100644
--- a/gcc/pointer-query.cc
+++ b/gcc/pointer-query.cc
@@ -18,6 +18,7 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/predict.cc b/gcc/predict.cc
index affa037371ca..3c60fd65e9e7 100644
--- a/gcc/predict.cc
+++ b/gcc/predict.cc
@@ -26,7 +26,7 @@ along with GCC; see the file COPYING3.  If not see
    [3] "Corpus-based Static Branch Prediction"
        Calder, Grunwald, Lindsay, Martin, Mozer, and Zorn; PLDI '95.  */
 
-
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/pretty-print.cc b/gcc/pretty-print.cc
index 18c4b2fa3509..ef3fc746bc27 100644
--- a/gcc/pretty-print.cc
+++ b/gcc/pretty-print.cc
@@ -2461,10 +2461,10 @@ pretty_printer::~pretty_printer ()
 
 /* Base class implementation of pretty_printer::clone vfunc.  */
 
-pretty_printer *
+std::unique_ptr<pretty_printer>
 pretty_printer::clone () const
 {
-  return new pretty_printer (*this);
+  return ::make_unique<pretty_printer> (*this);
 }
 
 /* Append a string delimited by START and END to the output area of
diff --git a/gcc/pretty-print.h b/gcc/pretty-print.h
index ec64a167327b..96d431876057 100644
--- a/gcc/pretty-print.h
+++ b/gcc/pretty-print.h
@@ -21,6 +21,14 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_PRETTY_PRINT_H
 #define GCC_PRETTY_PRINT_H
 
+/* This header uses std::unique_ptr, but <memory> can't be directly
+   included due to issues with macros.  Hence it must be included from
+   system.h by defining INCLUDE_MEMORY in any source file using it.  */
+
+#ifndef INCLUDE_MEMORY
+# error "You must define INCLUDE_MEMORY before including system.h to use pretty-print.h"
+#endif
+
 #include "obstack.h"
 #include "rich-location.h"
 #include "diagnostic-url.h"
@@ -269,7 +277,7 @@ public:
 
   virtual ~pretty_printer ();
 
-  virtual pretty_printer *clone () const;
+  virtual std::unique_ptr<pretty_printer> clone () const;
 
   void set_output_stream (FILE *outfile)
   {
diff --git a/gcc/print-rtl.cc b/gcc/print-rtl.cc
index 69c2e196e041..1688d4ec5c8f 100644
--- a/gcc/print-rtl.cc
+++ b/gcc/print-rtl.cc
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #endif
 
+#define INCLUDE_MEMORY
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
diff --git a/gcc/print-tree.cc b/gcc/print-tree.cc
index 0dda09a99e3f..d313a2adfaf7 100644
--- a/gcc/print-tree.cc
+++ b/gcc/print-tree.cc
@@ -18,6 +18,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/profile-count.cc b/gcc/profile-count.cc
index b26f38e33e47..0f30fa261538 100644
--- a/gcc/profile-count.cc
+++ b/gcc/profile-count.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/range-op-float.cc b/gcc/range-op-float.cc
index 2754dd875682..a42bca0280f7 100644
--- a/gcc/range-op-float.cc
+++ b/gcc/range-op-float.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index 24e206c00cdd..8f87f18e2c48 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 3f5cf0834402..937bee29b1e9 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/range.cc b/gcc/range.cc
index 5ee0edc54f6b..3b56556c87e3 100644
--- a/gcc/range.cc
+++ b/gcc/range.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/read-rtl-function.cc b/gcc/read-rtl-function.cc
index fa1aeb53759c..51dc11928d05 100644
--- a/gcc/read-rtl-function.cc
+++ b/gcc/read-rtl-function.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/rtl-error.cc b/gcc/rtl-error.cc
index 6d05f0b96268..0a92a1ad2c0f 100644
--- a/gcc/rtl-error.cc
+++ b/gcc/rtl-error.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/rtl-ssa/accesses.cc b/gcc/rtl-ssa/accesses.cc
index ef99759871aa..9fa7fee621c6 100644
--- a/gcc/rtl-ssa/accesses.cc
+++ b/gcc/rtl-ssa/accesses.cc
@@ -19,6 +19,7 @@
 
 #define INCLUDE_ALGORITHM
 #define INCLUDE_FUNCTIONAL
+#define INCLUDE_MEMORY
 #define INCLUDE_ARRAY
 #include "config.h"
 #include "system.h"
diff --git a/gcc/rtl-ssa/blocks.cc b/gcc/rtl-ssa/blocks.cc
index dfc4e7d0610d..780a241cab67 100644
--- a/gcc/rtl-ssa/blocks.cc
+++ b/gcc/rtl-ssa/blocks.cc
@@ -19,6 +19,7 @@
 
 #define INCLUDE_ALGORITHM
 #define INCLUDE_FUNCTIONAL
+#define INCLUDE_MEMORY
 #define INCLUDE_ARRAY
 #include "config.h"
 #include "system.h"
diff --git a/gcc/rtl-ssa/changes.cc b/gcc/rtl-ssa/changes.cc
index 0476296607bc..f2be1195bc09 100644
--- a/gcc/rtl-ssa/changes.cc
+++ b/gcc/rtl-ssa/changes.cc
@@ -19,6 +19,7 @@
 
 #define INCLUDE_ALGORITHM
 #define INCLUDE_FUNCTIONAL
+#define INCLUDE_MEMORY
 #define INCLUDE_ARRAY
 #include "config.h"
 #include "system.h"
diff --git a/gcc/rtl-ssa/functions.cc b/gcc/rtl-ssa/functions.cc
index bffccc57aabc..b14fb076da0c 100644
--- a/gcc/rtl-ssa/functions.cc
+++ b/gcc/rtl-ssa/functions.cc
@@ -19,6 +19,7 @@
 
 #define INCLUDE_ALGORITHM
 #define INCLUDE_FUNCTIONAL
+#define INCLUDE_MEMORY
 #define INCLUDE_ARRAY
 #include "config.h"
 #include "system.h"
diff --git a/gcc/rtl-ssa/insns.cc b/gcc/rtl-ssa/insns.cc
index d0c3e56b8bef..bfc6683cc458 100644
--- a/gcc/rtl-ssa/insns.cc
+++ b/gcc/rtl-ssa/insns.cc
@@ -19,6 +19,7 @@
 
 #define INCLUDE_ALGORITHM
 #define INCLUDE_FUNCTIONAL
+#define INCLUDE_MEMORY
 #define INCLUDE_ARRAY
 #include "config.h"
 #include "system.h"
diff --git a/gcc/rtl-ssa/movement.cc b/gcc/rtl-ssa/movement.cc
index 38432119f334..c34c70da1944 100644
--- a/gcc/rtl-ssa/movement.cc
+++ b/gcc/rtl-ssa/movement.cc
@@ -19,6 +19,7 @@
 
 #define INCLUDE_ALGORITHM
 #define INCLUDE_FUNCTIONAL
+#define INCLUDE_MEMORY
 #define INCLUDE_ARRAY
 #include "config.h"
 #include "system.h"
diff --git a/gcc/rtl-tests.cc b/gcc/rtl-tests.cc
index 4569770a238b..ef717cc22f32 100644
--- a/gcc/rtl-tests.cc
+++ b/gcc/rtl-tests.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/rust/resolve/rust-ast-resolve-expr.cc b/gcc/rust/resolve/rust-ast-resolve-expr.cc
index 5520dc235017..74f11dd215c9 100644
--- a/gcc/rust/resolve/rust-ast-resolve-expr.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-expr.cc
@@ -16,6 +16,7 @@
 // along with GCC; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
+#define INCLUDE_MEMORY
 #include "rust-ast-resolve-expr.h"
 #include "rust-ast-resolve-stmt.h"
 #include "rust-ast-resolve-struct-expr-field.h"
diff --git a/gcc/rust/rust-attribs.cc b/gcc/rust/rust-attribs.cc
index 86d5b3dfeb9f..ddcef72f07eb 100644
--- a/gcc/rust/rust-attribs.cc
+++ b/gcc/rust/rust-attribs.cc
@@ -15,6 +15,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/rust/rust-system.h b/gcc/rust/rust-system.h
index 2382e5b1fb4e..1833b93542d1 100644
--- a/gcc/rust/rust-system.h
+++ b/gcc/rust/rust-system.h
@@ -21,6 +21,7 @@
 #define RUST_SYSTEM_H
 
 #define INCLUDE_ALGORITHM
+#define INCLUDE_MEMORY
 #include "config.h"
 
 /* Define this so that inttypes.h defines the PRI?64 macros even
diff --git a/gcc/sanopt.cc b/gcc/sanopt.cc
index 604db6b3912a..0d79a0271f73 100644
--- a/gcc/sanopt.cc
+++ b/gcc/sanopt.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/sched-rgn.cc b/gcc/sched-rgn.cc
index 3d8cff76aaf9..4f511b3ca504 100644
--- a/gcc/sched-rgn.cc
+++ b/gcc/sched-rgn.cc
@@ -43,6 +43,7 @@ along with GCC; see the file COPYING3.  If not see
    priorities are computed, and (3) block level: insns in the block
    are actually scheduled.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/selftest-diagnostic-path.cc b/gcc/selftest-diagnostic-path.cc
index 6d21f2e55999..1b0ba2c1a3fb 100644
--- a/gcc/selftest-diagnostic-path.cc
+++ b/gcc/selftest-diagnostic-path.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/selftest-diagnostic.cc b/gcc/selftest-diagnostic.cc
index 4e9ee921b044..a066fe20066b 100644
--- a/gcc/selftest-diagnostic.cc
+++ b/gcc/selftest-diagnostic.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/splay-tree-utils.cc b/gcc/splay-tree-utils.cc
index 6437a5a98fa6..eb99b6b0e4b4 100644
--- a/gcc/splay-tree-utils.cc
+++ b/gcc/splay-tree-utils.cc
@@ -19,6 +19,7 @@
 
 #define INCLUDE_ALGORITHM
 #define INCLUDE_ARRAY
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/sreal.cc b/gcc/sreal.cc
index be557e7de803..b9f049748ef3 100644
--- a/gcc/sreal.cc
+++ b/gcc/sreal.cc
@@ -47,6 +47,7 @@ along with GCC; see the file COPYING3.  If not see
 	sig == 0 && exp == -SREAL_MAX_EXP
 */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include <math.h>
diff --git a/gcc/stmt.cc b/gcc/stmt.cc
index ae1527f0a19a..d272a45c82b0 100644
--- a/gcc/stmt.cc
+++ b/gcc/stmt.cc
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
    The functions whose names start with `expand_' are called by the
    expander to generate RTL instructions for various kinds of constructs.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/substring-locations.cc b/gcc/substring-locations.cc
index 156c12134baf..96224d3c8d00 100644
--- a/gcc/substring-locations.cc
+++ b/gcc/substring-locations.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/symtab-clones.cc b/gcc/symtab-clones.cc
index d50a95ebec60..79c93125af50 100644
--- a/gcc/symtab-clones.cc
+++ b/gcc/symtab-clones.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/symtab-thunks.cc b/gcc/symtab-thunks.cc
index c7ca06ff4798..f754a8a96e20 100644
--- a/gcc/symtab-thunks.cc
+++ b/gcc/symtab-thunks.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/symtab.cc b/gcc/symtab.cc
index 3b018ab3ea21..5e19062987e2 100644
--- a/gcc/symtab.cc
+++ b/gcc/symtab.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/text-art/box-drawing.cc b/gcc/text-art/box-drawing.cc
index 7057a4eac60d..e6092735bbe5 100644
--- a/gcc/text-art/box-drawing.cc
+++ b/gcc/text-art/box-drawing.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/text-art/canvas.cc b/gcc/text-art/canvas.cc
index 8e5d96808d8c..b2315d96d0df 100644
--- a/gcc/text-art/canvas.cc
+++ b/gcc/text-art/canvas.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/text-art/ruler.cc b/gcc/text-art/ruler.cc
index f80d9bb8758c..2abc36fc7c9c 100644
--- a/gcc/text-art/ruler.cc
+++ b/gcc/text-art/ruler.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 
 #include "config.h"
 #define INCLUDE_ALGORITHM
+#define INCLUDE_MEMORY
 #define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/text-art/selftests.cc b/gcc/text-art/selftests.cc
index 2b113b6b0177..3c72c9439296 100644
--- a/gcc/text-art/selftests.cc
+++ b/gcc/text-art/selftests.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/text-art/theme.cc b/gcc/text-art/theme.cc
index e51b8ef7a84c..580c931aef2c 100644
--- a/gcc/text-art/theme.cc
+++ b/gcc/text-art/theme.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
+#define INCLUDE_MEMORY
 #define INCLUDE_VECTOR
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/toplev.cc b/gcc/toplev.cc
index 5df59b79c803..e198be4350be 100644
--- a/gcc/toplev.cc
+++ b/gcc/toplev.cc
@@ -42,6 +42,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cgraph.h"
 #include "coverage.h"
 #include "diagnostic.h"
+#include "pretty-print-urlifier.h"
 #include "varasm.h"
 #include "tree-inline.h"
 #include "realmpfr.h"	/* For GMP/MPFR/MPC versions, in print_version.  */
@@ -94,6 +95,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "dbgcnt.h"
 #include "gcc-urlifier.h"
 #include "unique-argv.h"
+#include "make-unique.h"
 
 #include "selftest.h"
 
@@ -1094,9 +1096,9 @@ general_init (const char *argv0, bool init_signals, unique_argv original_argv)
   global_dc->m_internal_error = internal_error_function;
   const unsigned lang_mask = lang_hooks.option_lang_mask ();
   global_dc->set_option_manager
-    (new compiler_diagnostic_option_manager (*global_dc,
-					     lang_mask,
-					     &global_options),
+    (::make_unique<compiler_diagnostic_option_manager> (*global_dc,
+							lang_mask,
+							&global_options),
      lang_mask);
   global_dc->set_urlifier (make_gcc_urlifier (lang_mask));
 
diff --git a/gcc/trans-mem.cc b/gcc/trans-mem.cc
index fb0c95a8793a..3cf0bf34a121 100644
--- a/gcc/trans-mem.cc
+++ b/gcc/trans-mem.cc
@@ -19,6 +19,7 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-affine.cc b/gcc/tree-affine.cc
index 76117aa4fd6d..1373664dff1c 100644
--- a/gcc/tree-affine.cc
+++ b/gcc/tree-affine.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-call-cdce.cc b/gcc/tree-call-cdce.cc
index befe6acf178a..077d6fda6e8b 100644
--- a/gcc/tree-call-cdce.cc
+++ b/gcc/tree-call-cdce.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index fcb488d87113..a850146987fd 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-chrec.cc b/gcc/tree-chrec.cc
index 9b272074a2ed..0c9776f29997 100644
--- a/gcc/tree-chrec.cc
+++ b/gcc/tree-chrec.cc
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
    variables.
 */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-dfa.cc b/gcc/tree-dfa.cc
index 77e119a6b1b2..96719463e690 100644
--- a/gcc/tree-dfa.cc
+++ b/gcc/tree-dfa.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-diagnostic-client-data-hooks.cc b/gcc/tree-diagnostic-client-data-hooks.cc
index a2e4a5c97bd5..d966cf50f0d3 100644
--- a/gcc/tree-diagnostic-client-data-hooks.cc
+++ b/gcc/tree-diagnostic-client-data-hooks.cc
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "langhooks.h"
 #include "plugin.h"
 #include "timevar.h"
+#include "make-unique.h"
 
 /* Concrete class for supplying a diagnostic_context with information
    about a specific plugin within the client, when the client is the
@@ -166,8 +167,8 @@ private:
 /* Create a compiler_data_hooks (so that the class can be local
    to this file).  */
 
-diagnostic_client_data_hooks *
+std::unique_ptr<diagnostic_client_data_hooks>
 make_compiler_data_hooks ()
 {
-  return new compiler_data_hooks ();
+  return ::make_unique<compiler_data_hooks> ();
 }
diff --git a/gcc/tree-diagnostic.cc b/gcc/tree-diagnostic.cc
index 39471021d0f4..b7d2c51c984c 100644
--- a/gcc/tree-diagnostic.cc
+++ b/gcc/tree-diagnostic.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-dump.cc b/gcc/tree-dump.cc
index 3b5864eecb67..3aa387fff853 100644
--- a/gcc/tree-dump.cc
+++ b/gcc/tree-dump.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index 037fd1e946ae..e869b0722a0a 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-into-ssa.cc b/gcc/tree-into-ssa.cc
index fc61d47ca777..78d5b922fa61 100644
--- a/gcc/tree-into-ssa.cc
+++ b/gcc/tree-into-ssa.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-logical-location.cc b/gcc/tree-logical-location.cc
index ca8b34a42d36..5967e13e1ff9 100644
--- a/gcc/tree-logical-location.cc
+++ b/gcc/tree-logical-location.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-nested.cc b/gcc/tree-nested.cc
index fc0495d64431..a54e72c32370 100644
--- a/gcc/tree-nested.cc
+++ b/gcc/tree-nested.cc
@@ -17,6 +17,7 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-nrv.cc b/gcc/tree-nrv.cc
index 0a8f359790a8..aa01b96c953c 100644
--- a/gcc/tree-nrv.cc
+++ b/gcc/tree-nrv.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-object-size.cc b/gcc/tree-object-size.cc
index 6544730e1539..64f89bc9012b 100644
--- a/gcc/tree-object-size.cc
+++ b/gcc/tree-object-size.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-outof-ssa.cc b/gcc/tree-outof-ssa.cc
index 6d9c125f4e0d..1d9a4a370fae 100644
--- a/gcc/tree-outof-ssa.cc
+++ b/gcc/tree-outof-ssa.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc
index b378ffbfb4ca..7e519949e081 100644
--- a/gcc/tree-pretty-print.cc
+++ b/gcc/tree-pretty-print.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
index 153c9323040a..91a14927cdc4 100644
--- a/gcc/tree-profile.cc
+++ b/gcc/tree-profile.cc
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3.  If not see
 /* Generate basic block profile instrumentation and auxiliary files.
    Tree-based version.  See profile.cc for overview.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-scalar-evolution.cc b/gcc/tree-scalar-evolution.cc
index abb2bad77737..357e21013e11 100644
--- a/gcc/tree-scalar-evolution.cc
+++ b/gcc/tree-scalar-evolution.cc
@@ -253,6 +253,7 @@ along with GCC; see the file COPYING3.  If not see
    at: http://cri.ensmp.fr/~pop/gcc/20040604/gccsummit-lno-spop.pdf
 */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc
index 64e2f007d680..a8e86f04fb41 100644
--- a/gcc/tree-sra.cc
+++ b/gcc/tree-sra.cc
@@ -71,6 +71,7 @@ along with GCC; see the file COPYING3.  If not see
       Finally, if a parameter got scalarized, the scalar replacements are
       initialized with values from respective parameter aggregates.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-address.cc b/gcc/tree-ssa-address.cc
index c4dfa371bb8c..61f54ec07768 100644
--- a/gcc/tree-ssa-address.cc
+++ b/gcc/tree-ssa-address.cc
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 /* Utility functions for manipulation with TARGET_MEM_REFs -- tree expressions
    that directly map to addressing modes of the target.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc
index fab048b0b594..2cdb5c92b7a2 100644
--- a/gcc/tree-ssa-alias.cc
+++ b/gcc/tree-ssa-alias.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc
index a5f6ef5f5ddd..08d1e359b91c 100644
--- a/gcc/tree-ssa-ccp.cc
+++ b/gcc/tree-ssa-ccp.cc
@@ -118,6 +118,7 @@ along with GCC; see the file COPYING3.  If not see
      Advanced Compiler Design and Implementation,
      Steven Muchnick, Morgan Kaufmann, 1997, Section 12.6  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-coalesce.cc b/gcc/tree-ssa-coalesce.cc
index 8d8727de32f1..8c9aafb98d7e 100644
--- a/gcc/tree-ssa-coalesce.cc
+++ b/gcc/tree-ssa-coalesce.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-copy.cc b/gcc/tree-ssa-copy.cc
index 9c9ec47adcaa..6cbf59412e77 100644
--- a/gcc/tree-ssa-copy.cc
+++ b/gcc/tree-ssa-copy.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-dce.cc b/gcc/tree-ssa-dce.cc
index 3075459e25f4..9234af790223 100644
--- a/gcc/tree-ssa-dce.cc
+++ b/gcc/tree-ssa-dce.cc
@@ -42,6 +42,7 @@ along with GCC; see the file COPYING3.  If not see
       giving values to operands in necessary statements; and
    3. Removing dead statements.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-dom.cc b/gcc/tree-ssa-dom.cc
index 221fe6db3218..ef4e6c1c64ae 100644
--- a/gcc/tree-ssa-dom.cc
+++ b/gcc/tree-ssa-dom.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
index 766eaf0e4e79..7af4dc1f8dff 100644
--- a/gcc/tree-ssa-forwprop.cc
+++ b/gcc/tree-ssa-forwprop.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc
index 6a3bc99190d9..f8064094c426 100644
--- a/gcc/tree-ssa-ifcombine.cc
+++ b/gcc/tree-ssa-ifcombine.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-loop-ch.cc b/gcc/tree-ssa-loop-ch.cc
index 6552ddd1ee2f..ec936d862929 100644
--- a/gcc/tree-ssa-loop-ch.cc
+++ b/gcc/tree-ssa-loop-ch.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-loop-im.cc b/gcc/tree-ssa-loop-im.cc
index ccc56dc42f61..26b4147d07b4 100644
--- a/gcc/tree-ssa-loop-im.cc
+++ b/gcc/tree-ssa-loop-im.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-loop-manip.cc b/gcc/tree-ssa-loop-manip.cc
index 213f069c440c..326119383fd5 100644
--- a/gcc/tree-ssa-loop-manip.cc
+++ b/gcc/tree-ssa-loop-manip.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc
index f87731ef8929..99f4b78b5ef4 100644
--- a/gcc/tree-ssa-loop-niter.cc
+++ b/gcc/tree-ssa-loop-niter.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-loop-split.cc b/gcc/tree-ssa-loop-split.cc
index 68435485b791..8427b010b3c9 100644
--- a/gcc/tree-ssa-loop-split.cc
+++ b/gcc/tree-ssa-loop-split.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
index f9ccdf41d67f..e78ef76bd3bf 100644
--- a/gcc/tree-ssa-math-opts.cc
+++ b/gcc/tree-ssa-math-opts.cc
@@ -84,6 +84,7 @@ along with GCC; see the file COPYING3.  If not see
    The data structures would be more complex in order to work on all the
    variables in a single pass.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-operands.cc b/gcc/tree-ssa-operands.cc
index 1dbf6b9c7c49..a01aa51f1cc6 100644
--- a/gcc/tree-ssa-operands.cc
+++ b/gcc/tree-ssa-operands.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-phiprop.cc b/gcc/tree-ssa-phiprop.cc
index 2a1cdae46d27..ded0a4e6fb39 100644
--- a/gcc/tree-ssa-phiprop.cc
+++ b/gcc/tree-ssa-phiprop.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-pre.cc b/gcc/tree-ssa-pre.cc
index 13f2c8a5420d..7cbad301cebb 100644
--- a/gcc/tree-ssa-pre.cc
+++ b/gcc/tree-ssa-pre.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-propagate.cc b/gcc/tree-ssa-propagate.cc
index d96d0a9fe19b..43b17606a161 100644
--- a/gcc/tree-ssa-propagate.cc
+++ b/gcc/tree-ssa-propagate.cc
@@ -18,6 +18,7 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-reassoc.cc b/gcc/tree-ssa-reassoc.cc
index 347350fc98df..a898658da34d 100644
--- a/gcc/tree-ssa-reassoc.cc
+++ b/gcc/tree-ssa-reassoc.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index abf7d38d15cb..4fa37cd71721 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-scopedtables.cc b/gcc/tree-ssa-scopedtables.cc
index c367d37fa9b5..3f43b64e8980 100644
--- a/gcc/tree-ssa-scopedtables.cc
+++ b/gcc/tree-ssa-scopedtables.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-sink.cc b/gcc/tree-ssa-sink.cc
index 8c551e42a4d2..eace914e72bd 100644
--- a/gcc/tree-ssa-sink.cc
+++ b/gcc/tree-ssa-sink.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-strlen.cc b/gcc/tree-ssa-strlen.cc
index ee60909aa21a..25c0adabbcd0 100644
--- a/gcc/tree-ssa-strlen.cc
+++ b/gcc/tree-ssa-strlen.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index 73ba5aa6195c..a6adec3b0b64 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -18,6 +18,7 @@
    along with GCC; see the file COPYING3.  If not see
    <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-ter.cc b/gcc/tree-ssa-ter.cc
index 9b338bd26956..890ad0110841 100644
--- a/gcc/tree-ssa-ter.cc
+++ b/gcc/tree-ssa-ter.cc
@@ -19,6 +19,7 @@ along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssa-uninit.cc b/gcc/tree-ssa-uninit.cc
index 726684e472aa..9c3c6878ac96 100644
--- a/gcc/tree-ssa-uninit.cc
+++ b/gcc/tree-ssa-uninit.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #define INCLUDE_STRING
 #include "config.h"
 #include "system.h"
diff --git a/gcc/tree-ssa.cc b/gcc/tree-ssa.cc
index f4fa4e98c5d0..7c6807cdb98c 100644
--- a/gcc/tree-ssa.cc
+++ b/gcc/tree-ssa.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-ssanames.cc b/gcc/tree-ssanames.cc
index 4f83fcbb5171..caf667f417c5 100644
--- a/gcc/tree-ssanames.cc
+++ b/gcc/tree-ssanames.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-stdarg.cc b/gcc/tree-stdarg.cc
index 33763cd3d112..79b549ad6fa7 100644
--- a/gcc/tree-stdarg.cc
+++ b/gcc/tree-stdarg.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-streamer-in.cc b/gcc/tree-streamer-in.cc
index 329d218e7d4e..97602d1962d4 100644
--- a/gcc/tree-streamer-in.cc
+++ b/gcc/tree-streamer-in.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-streamer-out.cc b/gcc/tree-streamer-out.cc
index 81f5aeb30a6d..f0814fa37a7e 100644
--- a/gcc/tree-streamer-out.cc
+++ b/gcc/tree-streamer-out.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-streamer.cc b/gcc/tree-streamer.cc
index f4e1290b20f5..a5394145bc63 100644
--- a/gcc/tree-streamer.cc
+++ b/gcc/tree-streamer.cc
@@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-switch-conversion.cc b/gcc/tree-switch-conversion.cc
index 00426d400006..33023875ef97 100644
--- a/gcc/tree-switch-conversion.cc
+++ b/gcc/tree-switch-conversion.cc
@@ -22,6 +22,7 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
 /* This file handles the lowering of GIMPLE_SWITCH to an indexed
    load, or a series of bit-test-and-branch expressions.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-tailcall.cc b/gcc/tree-tailcall.cc
index 1901b1a13f99..d188da79aaf2 100644
--- a/gcc/tree-tailcall.cc
+++ b/gcc/tree-tailcall.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc
index a19f8ec24266..c265672bf99a 100644
--- a/gcc/tree-vrp.cc
+++ b/gcc/tree-vrp.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/tree.cc b/gcc/tree.cc
index 095c02c54741..a2022ae27cf4 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.  If not see
    It is intended to be language-independent but can occasionally
    calls language-dependent routines.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/ubsan.cc b/gcc/ubsan.cc
index 76ca7a04265b..ae48dc93475a 100644
--- a/gcc/ubsan.cc
+++ b/gcc/ubsan.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/value-pointer-equiv.cc b/gcc/value-pointer-equiv.cc
index cfb53ab4eeef..3e415c5efea4 100644
--- a/gcc/value-pointer-equiv.cc
+++ b/gcc/value-pointer-equiv.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/value-prof.cc b/gcc/value-prof.cc
index ddb4b4e1ee59..61578bedf0a7 100644
--- a/gcc/value-prof.cc
+++ b/gcc/value-prof.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/value-query.cc b/gcc/value-query.cc
index cac2cb5b2bc0..0ead7806f127 100644
--- a/gcc/value-query.cc
+++ b/gcc/value-query.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/value-range-pretty-print.cc b/gcc/value-range-pretty-print.cc
index b11d64947741..cbd7bc5d5e16 100644
--- a/gcc/value-range-pretty-print.cc
+++ b/gcc/value-range-pretty-print.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/value-range-storage.cc b/gcc/value-range-storage.cc
index d3d98f98d7b1..b74ae7f0ad7b 100644
--- a/gcc/value-range-storage.cc
+++ b/gcc/value-range-storage.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/value-range.cc b/gcc/value-range.cc
index 3046232bbca2..775e97da11ce 100644
--- a/gcc/value-range.cc
+++ b/gcc/value-range.cc
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc
index d8a2ed920a82..5c7986e23fb0 100644
--- a/gcc/value-relation.cc
+++ b/gcc/value-relation.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/var-tracking.cc b/gcc/var-tracking.cc
index 08174669c269..5f1358c1ac25 100644
--- a/gcc/var-tracking.cc
+++ b/gcc/var-tracking.cc
@@ -85,6 +85,7 @@
 
 */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/varpool.cc b/gcc/varpool.cc
index e40504d1bd80..0b5d448f7c33 100644
--- a/gcc/varpool.cc
+++ b/gcc/varpool.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc
index cf273a3fc623..6db17042a34a 100644
--- a/gcc/vr-values.cc
+++ b/gcc/vr-values.cc
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/gcc/wide-int-print.cc b/gcc/wide-int-print.cc
index 3e02ee123089..c4ee7791bc36 100644
--- a/gcc/wide-int-print.cc
+++ b/gcc/wide-int-print.cc
@@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_MEMORY
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
diff --git a/libgcc/libgcov-util.c b/libgcc/libgcov-util.c
index f443408c4ab7..e93f5859dc0f 100644
--- a/libgcc/libgcov-util.c
+++ b/libgcc/libgcov-util.c
@@ -27,6 +27,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 
 #define IN_GCOV_TOOL 1
 
+#define INCLUDE_MEMORY
 #include "libgcov.h"
 #include "intl.h"
 #include "diagnostic.h"
