From d59167d27fd95c62c6e3d0c9196860beb6aeee65 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 25 Jan 2018 17:07:50 -0500
Subject: [PATCH 13/14] FIXME: WIP on converting diagnostic_context to a class

---
 gcc/c-family/c-common.c     |   8 +-
 gcc/c-family/c-opts.c       |  10 +-
 gcc/c-family/c-pragma.c     |   4 +-
 gcc/c/c-decl.c              |   2 +-
 gcc/c/c-errors.c            |  10 +-
 gcc/c/c-objc-common.c       |   4 +-
 gcc/collect2.c              |   2 +-
 gcc/cp/error.c              |  68 +++----
 gcc/cp/typeck2.c            |   4 +-
 gcc/diagnostic-show-locus.c | 114 ++++++------
 gcc/diagnostic.c            | 421 ++++++++++++++++++++++----------------------
 gcc/diagnostic.h            | 186 +++++++++++--------
 gcc/fortran/cpp.c           |   8 +-
 gcc/fortran/error.c         |  99 ++++++-----
 gcc/fortran/options.c       |   4 +-
 gcc/gcc.c                   |   8 +-
 gcc/gcov-dump.c             |   2 +-
 gcc/gcov-tool.c             |   2 +-
 gcc/gcov.c                  |   2 +-
 gcc/input.c                 |  18 +-
 gcc/jit/dummy-frontend.c    |   4 +-
 gcc/jit/jit-playback.c      |   2 +-
 gcc/langhooks.c             |  28 +--
 gcc/lto-wrapper.c           |   2 +-
 gcc/opts-common.c           |   4 +-
 gcc/opts-global.c           |   2 +-
 gcc/opts.c                  |  26 +--
 gcc/rtl-error.c             |   2 +-
 gcc/selftest-diagnostic.c   |  10 +-
 gcc/substring-locations.c   |   2 +-
 gcc/toplev.c                |  36 ++--
 gcc/tree-diagnostic.c       |   6 +-
 32 files changed, 562 insertions(+), 538 deletions(-)

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 858ed68..325d9aa 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -6088,7 +6088,7 @@ c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
 {
   diagnostic_info diagnostic;
   diagnostic_t dlevel;
-  bool save_warn_system_headers = global_dc->dc_warn_system_headers;
+  bool save_warn_system_headers = global_dc->m_warn_system_headers;
   bool ret;
 
   switch (level)
@@ -6096,7 +6096,7 @@ c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
     case CPP_DL_WARNING_SYSHDR:
       if (flag_no_output)
 	return false;
-      global_dc->dc_warn_system_headers = 1;
+      global_dc->m_warn_system_headers = 1;
       /* Fall through.  */
     case CPP_DL_WARNING:
       if (flag_no_output)
@@ -6129,9 +6129,9 @@ c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
 				  richloc, dlevel);
   diagnostic_override_option_index (&diagnostic,
                                     c_option_controlling_cpp_error (reason));
-  ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
+  ret = global_dc->report_diagnostic (&diagnostic);
   if (level == CPP_DL_WARNING_SYSHDR)
-    global_dc->dc_warn_system_headers = save_warn_system_headers;
+    global_dc->m_warn_system_headers = save_warn_system_headers;
   return ret;
 }
 
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 3db01d4..cb92b95 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -170,8 +170,8 @@ c_diagnostic_finalizer (diagnostic_context *context,
   /* By default print macro expansion contexts in the diagnostic
      finalizer -- for tokens resulting from macro expansion.  */
   virt_loc_aware_diagnostic_finalizer (context, diagnostic);
-  pp_destroy_prefix (context->printer);
-  pp_flush (context->printer);
+  pp_destroy_prefix (context->m_printer);
+  pp_flush (context->m_printer);
 }
 
 /* Common default settings for diagnostics.  */
@@ -179,7 +179,7 @@ void
 c_common_diagnostics_set_defaults (diagnostic_context *context)
 {
   diagnostic_finalizer (context) = c_diagnostic_finalizer;
-  context->opt_permissive = OPT_fpermissive;
+  context->m_opt_permissive = OPT_fpermissive;
 }
 
 /* Whether options from all C-family languages should be accepted
@@ -255,7 +255,7 @@ c_common_init_options (unsigned int decoded_options_count,
   if (c_dialect_cxx ())
     set_std_cxx14 (/*ISO*/false);
 
-  global_dc->colorize_source_p = true;
+  global_dc->m_colorize_source_p = true;
 }
 
 /* Handle switch SCODE with argument ARG.  VALUE is true, unless no-
@@ -483,7 +483,7 @@ c_common_handle_option (size_t scode, const char *arg, int value,
 
     case OPT_fpermissive:
       flag_permissive = value;
-      global_dc->permissive = value;
+      global_dc->m_permissive = value;
       break;
 
     case OPT_fpreprocessed:
diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c
index 84e4341..2592ca4 100644
--- a/gcc/c-family/c-pragma.c
+++ b/gcc/c-family/c-pragma.c
@@ -774,12 +774,12 @@ handle_pragma_diagnostic(cpp_reader *ARG_UNUSED(dummy))
     kind = DK_IGNORED;
   else if (strcmp (kind_string, "push") == 0)
     {
-      diagnostic_push_diagnostics (global_dc, input_location);
+      global_dc->push_diagnostics (input_location);
       return;
     }
   else if (strcmp (kind_string, "pop") == 0)
     {
-      diagnostic_pop_diagnostics (global_dc, input_location);
+      global_dc->pop_diagnostics (input_location);
       return;
     }
   else
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index f800464..3b171b9 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -5539,7 +5539,7 @@ warn_defaults_to (location_t location, int opt, const char *gmsgid, ...)
   diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
                        flag_isoc99 ? DK_PEDWARN : DK_WARNING);
   diagnostic.option_index = opt;
-  diagnostic_report_diagnostic (global_dc, &diagnostic);
+  global_dc->report_diagnostic (&diagnostic);
   va_end (ap);
 }
 
diff --git a/gcc/c/c-errors.c b/gcc/c/c-errors.c
index 2d50710..79fb5e5 100644
--- a/gcc/c/c-errors.c
+++ b/gcc/c/c-errors.c
@@ -48,7 +48,7 @@ pedwarn_c99 (location_t location, int opt, const char *gmsgid, ...)
 			   (pedantic && !flag_isoc11)
 			   ? DK_PEDWARN : DK_WARNING);
       diagnostic.option_index = OPT_Wc99_c11_compat;
-      warned = diagnostic_report_diagnostic (global_dc, &diagnostic);
+      warned = global_dc->report_diagnostic (&diagnostic);
     }
   /* -Wno-c99-c11-compat suppresses even the pedwarns.  */
   else if (warn_c99_c11_compat == 0)
@@ -58,7 +58,7 @@ pedwarn_c99 (location_t location, int opt, const char *gmsgid, ...)
     {
       diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, DK_PEDWARN);
       diagnostic.option_index = opt;
-      warned = diagnostic_report_diagnostic (global_dc, &diagnostic);
+      warned = global_dc->report_diagnostic (&diagnostic);
     }
   va_end (ap);
   return warned;
@@ -92,7 +92,7 @@ pedwarn_c90 (location_t location, int opt, const char *gmsgid, ...)
 			       (pedantic && !flag_isoc99)
 			       ? DK_PEDWARN : DK_WARNING);
 	  diagnostic.option_index = opt;
-	  diagnostic_report_diagnostic (global_dc, &diagnostic);
+	  global_dc->report_diagnostic (&diagnostic);
 	  warned = true;
 	  goto out;
 	}
@@ -105,7 +105,7 @@ pedwarn_c90 (location_t location, int opt, const char *gmsgid, ...)
 			   (pedantic && !flag_isoc99)
 			   ? DK_PEDWARN : DK_WARNING);
       diagnostic.option_index = OPT_Wc90_c99_compat;
-      diagnostic_report_diagnostic (global_dc, &diagnostic);
+      global_dc->report_diagnostic (&diagnostic);
     }
   /* -Wno-c90-c99-compat suppresses the pedwarns.  */
   else if (warn_c90_c99_compat == 0)
@@ -115,7 +115,7 @@ pedwarn_c90 (location_t location, int opt, const char *gmsgid, ...)
     {
       diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, DK_PEDWARN);
       diagnostic.option_index = opt;
-      diagnostic_report_diagnostic (global_dc, &diagnostic);
+      global_dc->report_diagnostic (&diagnostic);
       warned = true;
     }
 out:
diff --git a/gcc/c/c-objc-common.c b/gcc/c/c-objc-common.c
index a841bc1..43d361b 100644
--- a/gcc/c/c-objc-common.c
+++ b/gcc/c/c-objc-common.c
@@ -217,9 +217,9 @@ has_c_linkage (const_tree decl ATTRIBUTE_UNUSED)
 void
 c_initialize_diagnostics (diagnostic_context *context)
 {
-  pretty_printer *base = context->printer;
+  pretty_printer *base = context->m_printer;
   c_pretty_printer *pp = XNEW (c_pretty_printer);
-  context->printer = new (pp) c_pretty_printer ();
+  context->m_printer = new (pp) c_pretty_printer ();
 
   /* It is safe to free this object because it was previously XNEW()'d.  */
   base->~pretty_printer ();
diff --git a/gcc/collect2.c b/gcc/collect2.c
index f26bc59..1859c57 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -960,7 +960,7 @@ main (int argc, char **argv)
 
   gcc_init_libintl ();
 
-  diagnostic_initialize (global_dc, 0);
+  global_dc->initialize (0);
 
   if (atexit (collect_atexit) != 0)
     fatal_error (input_location, "atexit failed");
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index cb1dcf3..d953a08 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -154,9 +154,9 @@ class cxx_format_postprocessor : public format_postprocessor
 void
 cxx_initialize_diagnostics (diagnostic_context *context)
 {
-  pretty_printer *base = context->printer;
+  pretty_printer *base = context->m_printer;
   cxx_pretty_printer *pp = XNEW (cxx_pretty_printer);
-  context->printer = new (pp) cxx_pretty_printer ();
+  context->m_printer = new (pp) cxx_pretty_printer ();
 
   /* It is safe to free this object because it was previously XNEW()'d.  */
   base->~pretty_printer ();
@@ -3286,7 +3286,7 @@ cxx_print_error_function (diagnostic_context *context, const char *file,
 			  diagnostic_info *diagnostic)
 {
   lhd_print_error_function (context, file, diagnostic);
-  pp_set_prefix (context->printer, file);
+  pp_set_prefix (context->m_printer, file);
   maybe_print_instantiation_context (context);
 }
 
@@ -3294,11 +3294,11 @@ static void
 cp_diagnostic_starter (diagnostic_context *context,
 		       diagnostic_info *diagnostic)
 {
-  diagnostic_report_current_module (context, diagnostic_location (diagnostic));
+  context->report_current_module (diagnostic_location (diagnostic));
   cp_print_error_function (context, diagnostic);
   maybe_print_instantiation_context (context);
   maybe_print_constexpr_context (context);
-  pp_set_prefix (context->printer, diagnostic_build_prefix (context,
+  pp_set_prefix (context->m_printer, diagnostic_build_prefix (context,
 								 diagnostic));
 }
 
@@ -3314,16 +3314,16 @@ cp_print_error_function (diagnostic_context *context,
     return;
   if (diagnostic_last_function_changed (context, diagnostic))
     {
-      const char *old_prefix = context->printer->prefix;
+      const char *old_prefix = context->m_printer->prefix;
       const char *file = LOCATION_FILE (diagnostic_location (diagnostic));
       tree abstract_origin = diagnostic_abstract_origin (diagnostic);
       char *new_prefix = (file && abstract_origin == NULL)
 			 ? file_name_as_prefix (context, file) : NULL;
 
-      pp_set_prefix (context->printer, new_prefix);
+      pp_set_prefix (context->m_printer, new_prefix);
 
       if (current_function_decl == NULL)
-	pp_string (context->printer, _("At global scope:"));
+	pp_string (context->m_printer, _("At global scope:"));
       else
 	{
 	  tree fndecl, ao;
@@ -3341,7 +3341,7 @@ cp_print_error_function (diagnostic_context *context,
 	  else
 	    fndecl = current_function_decl;
 
-	  pp_printf (context->printer, function_category (fndecl),
+	  pp_printf (context->m_printer, function_category (fndecl),
 		     cxx_printable_name_translate (fndecl, 2));
 
 	  while (abstract_origin)
@@ -3386,34 +3386,34 @@ cp_print_error_function (diagnostic_context *context,
 	      if (fndecl)
 		{
 		  expanded_location s = expand_location (*locus);
-		  pp_character (context->printer, ',');
-		  pp_newline (context->printer);
+		  pp_character (context->m_printer, ',');
+		  pp_newline (context->m_printer);
 		  if (s.file != NULL)
 		    {
-		      if (context->show_column && s.column != 0)
-			pp_printf (context->printer,
+		      if (context->m_show_column && s.column != 0)
+			pp_printf (context->m_printer,
 				   _("    inlined from %qs at %r%s:%d:%d%R"),
 				   cxx_printable_name_translate (fndecl, 2),
 				   "locus", s.file, s.line, s.column);
 		      else
-			pp_printf (context->printer,
+			pp_printf (context->m_printer,
 				   _("    inlined from %qs at %r%s:%d%R"),
 				   cxx_printable_name_translate (fndecl, 2),
 				   "locus", s.file, s.line);
 
 		    }
 		  else
-		    pp_printf (context->printer, _("    inlined from %qs"),
+		    pp_printf (context->m_printer, _("    inlined from %qs"),
 			       cxx_printable_name_translate (fndecl, 2));
 		}
 	    }
-	  pp_character (context->printer, ':');
+	  pp_character (context->m_printer, ':');
 	}
-      pp_newline (context->printer);
+      pp_newline (context->m_printer);
 
       diagnostic_set_last_function (context, diagnostic);
-      pp_destroy_prefix (context->printer);
-      context->printer->prefix = old_prefix;
+      pp_destroy_prefix (context->m_printer);
+      context->m_printer->prefix = old_prefix;
     }
 }
 
@@ -3455,7 +3455,7 @@ print_instantiation_full_context (diagnostic_context *context)
 
   if (p)
     {
-      pp_verbatim (context->printer,
+      pp_verbatim (context->m_printer,
 		   TREE_CODE (p->decl) == TREE_LIST
 		   ? _("%s: In substitution of %qS:\n")
 		   : _("%s: In instantiation of %q#D:\n"),
@@ -3482,23 +3482,23 @@ print_instantiation_partial_context_line (diagnostic_context *context,
 
   expanded_location xloc = expand_location (loc);
 
-  if (context->show_column)
-    pp_verbatim (context->printer, _("%r%s:%d:%d:%R   "),
+  if (context->m_show_column)
+    pp_verbatim (context->m_printer, _("%r%s:%d:%d:%R   "),
 		 "locus", xloc.file, xloc.line, xloc.column);
   else
-    pp_verbatim (context->printer, _("%r%s:%d:%R   "),
+    pp_verbatim (context->m_printer, _("%r%s:%d:%R   "),
 		 "locus", xloc.file, xloc.line);
 
   if (t != NULL)
     {
       if (TREE_CODE (t->decl) == TREE_LIST)
-	pp_verbatim (context->printer,
+	pp_verbatim (context->m_printer,
 		     recursive_p
 		     ? _("recursively required by substitution of %qS\n")
 		     : _("required by substitution of %qS\n"),
 		     t->decl);
       else
-	pp_verbatim (context->printer,
+	pp_verbatim (context->m_printer,
 		     recursive_p
 		     ? _("recursively required from %q#D\n")
 		     : _("required from %q#D\n"),
@@ -3506,7 +3506,7 @@ print_instantiation_partial_context_line (diagnostic_context *context,
     }
   else
     {
-      pp_verbatim (context->printer,
+      pp_verbatim (context->m_printer,
 		   recursive_p
 		   ? _("recursively required from here\n")
 		   : _("required from here\n"));
@@ -3559,14 +3559,14 @@ print_instantiation_partial_context (diagnostic_context *context,
 	{
 	  expanded_location xloc;
 	  xloc = expand_location (loc);
-	  if (context->show_column)
-	    pp_verbatim (context->printer,
+	  if (context->m_show_column)
+	    pp_verbatim (context->m_printer,
 			 _("%r%s:%d:%d:%R   [ skipping %d instantiation "
 			   "contexts, use -ftemplate-backtrace-limit=0 to "
 			   "disable ]\n"),
 			 "locus", xloc.file, xloc.line, xloc.column, skip);
 	  else
-	    pp_verbatim (context->printer,
+	    pp_verbatim (context->m_printer,
 			 _("%r%s:%d:%R   [ skipping %d instantiation "
 			   "contexts, use -ftemplate-backtrace-limit=0 to "
 			   "disable ]\n"),
@@ -3619,15 +3619,15 @@ maybe_print_constexpr_context (diagnostic_context *context)
     {
       expanded_location xloc = expand_location (EXPR_LOCATION (t));
       const char *s = expr_as_string (t, 0);
-      if (context->show_column)
-	pp_verbatim (context->printer,
+      if (context->m_show_column)
+	pp_verbatim (context->m_printer,
 		     _("%r%s:%d:%d:%R   in %<constexpr%> expansion of %qs"),
 		     "locus", xloc.file, xloc.line, xloc.column, s);
       else
-	pp_verbatim (context->printer,
+	pp_verbatim (context->m_printer,
 		     _("%r%s:%d:%R   in %<constexpr%> expansion of %qs"),
 		     "locus", xloc.file, xloc.line, s);
-      pp_newline (context->printer);
+      pp_newline (context->m_printer);
     }
 }
 
@@ -4237,7 +4237,7 @@ pedwarn_cxx98 (location_t location, int opt, const char *gmsgid, ...)
   diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc,
 		       (cxx_dialect == cxx98) ? DK_PEDWARN : DK_WARNING);
   diagnostic.option_index = opt;
-  ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
+  ret = global_dc->report_diagnostic (&diagnostic);
   va_end (ap);
   return ret;
 }
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 8d93325..7796505 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -977,13 +977,13 @@ check_narrowing (tree type, tree init, tsubst_flags_t complain)
       else if (complain & tf_error)
 	{
 	  int savederrorcount = errorcount;
-	  global_dc->pedantic_errors = 1;
+	  global_dc->m_pedantic_errors = 1;
 	  pedwarn (loc, OPT_Wnarrowing,
 		   "narrowing conversion of %qE from %qH to %qI "
 		   "inside { }", init, ftype, type);
 	  if (errorcount == savederrorcount)
 	    ok = true;
-	  global_dc->pedantic_errors = flag_pedantic_errors;
+	  global_dc->m_pedantic_errors = flag_pedantic_errors;
 	}
     }
 
diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c
index 54e2b1c..6b2111c 100644
--- a/gcc/diagnostic-show-locus.c
+++ b/gcc/diagnostic-show-locus.c
@@ -271,7 +271,7 @@ colorizer::colorizer (diagnostic_context *context,
   m_range2 = get_color_by_name ("range2");
   m_fixit_insert = get_color_by_name ("fixit-insert");
   m_fixit_delete = get_color_by_name ("fixit-delete");
-  m_stop_color = colorize_stop (pp_show_color (context->printer));
+  m_stop_color = colorize_stop (pp_show_color (context->m_printer));
 }
 
 /* The destructor for "colorize".  If colorization is on, print a code to
@@ -307,35 +307,35 @@ colorizer::begin_state (int state)
       break;
 
     case STATE_FIXIT_INSERT:
-      pp_string (m_context->printer, m_fixit_insert);
+      pp_string (m_context->m_printer, m_fixit_insert);
       break;
 
     case STATE_FIXIT_DELETE:
-      pp_string (m_context->printer, m_fixit_delete);
+      pp_string (m_context->m_printer, m_fixit_delete);
       break;
 
     case 0:
       /* Make range 0 be the same color as the "kind" text
 	 (error vs warning vs note).  */
       pp_string
-	(m_context->printer,
-	 colorize_start (pp_show_color (m_context->printer),
+	(m_context->m_printer,
+	 colorize_start (pp_show_color (m_context->m_printer),
 			 diagnostic_get_color_for_kind (m_diagnostic_kind)));
       break;
 
     case 1:
-      pp_string (m_context->printer, m_range1);
+      pp_string (m_context->m_printer, m_range1);
       break;
 
     case 2:
-      pp_string (m_context->printer, m_range2);
+      pp_string (m_context->m_printer, m_range2);
       break;
 
     default:
       /* For ranges beyond 2, alternate between color 1 and color 2.  */
       {
 	gcc_assert (state > 2);
-	pp_string (m_context->printer,
+	pp_string (m_context->m_printer,
 		   state % 2 ? m_range1 : m_range2);
       }
       break;
@@ -348,7 +348,7 @@ void
 colorizer::finish_state (int state)
 {
   if (state != STATE_NORMAL_TEXT)
-    pp_string (m_context->printer, m_stop_color);
+    pp_string (m_context->m_printer, m_stop_color);
 }
 
 /* Get the color code for NAME (or the empty string if
@@ -357,7 +357,7 @@ colorizer::finish_state (int state)
 const char *
 colorizer::get_color_by_name (const char *name)
 {
-  return colorize_start (pp_show_color (m_context->printer), name);
+  return colorize_start (pp_show_color (m_context->m_printer), name);
 }
 
 /* Implementation of class layout_range.  */
@@ -781,12 +781,12 @@ layout::layout (diagnostic_context * context,
 		rich_location *richloc,
 		diagnostic_t diagnostic_kind)
 : m_context (context),
-  m_pp (context->printer),
+  m_pp (context->m_printer),
   m_diagnostic_kind (diagnostic_kind),
   m_primary_loc (richloc->get_range (0)->m_loc),
   m_exploc (richloc->get_expanded_location (0)),
   m_colorizer (context, diagnostic_kind),
-  m_colorize_source_p (context->colorize_source_p),
+  m_colorize_source_p (context->m_colorize_source_p),
   m_layout_ranges (richloc->get_num_locations ()),
   m_fixit_hints (richloc->get_num_fixit_hints ()),
   m_line_spans (1 + richloc->get_num_locations ()),
@@ -818,7 +818,7 @@ layout::layout (diagnostic_context * context,
   /* Adjust m_x_offset.
      Center the primary caret to fit in max_width; all columns
      will be adjusted accordingly.  */
-  size_t max_width = m_context->caret_max_width;
+  size_t max_width = m_context->m_caret_max_width;
   char_span line = location_get_source_line (m_exploc.file, m_exploc.line);
   if (line && (size_t)m_exploc.column <= line.length ())
     {
@@ -831,7 +831,7 @@ layout::layout (diagnostic_context * context,
       gcc_assert (m_x_offset >= 0);
     }
 
-  if (context->show_ruler_p)
+  if (context->m_show_ruler_p)
     show_ruler (m_x_offset + max_width);
 }
 
@@ -1233,7 +1233,7 @@ layout::print_annotation_line (int row, const line_bounds lbounds)
 	      /* Draw the caret.  */
 	      char caret_char;
 	      if (state.range_idx < rich_location::STATICALLY_ALLOCATED_RANGES)
-		caret_char = m_context->caret_chars[state.range_idx];
+		caret_char = m_context->get_caret_char (state.range_idx);
 	      else
 		caret_char = '^';
 	      pp_character (m_pp, caret_char);
@@ -1920,11 +1920,11 @@ diagnostic_show_locus (diagnostic_context * context,
 		       rich_location *richloc,
 		       diagnostic_t diagnostic_kind)
 {
-  pp_newline (context->printer);
+  pp_newline (context->m_printer);
 
   location_t loc = richloc->get_loc ();
   /* Do nothing if source-printing has been disabled.  */
-  if (!context->show_caret)
+  if (!context->m_show_caret)
     return;
 
   /* Don't attempt to print source for UNKNOWN_LOCATION and for builtins.  */
@@ -1933,14 +1933,14 @@ diagnostic_show_locus (diagnostic_context * context,
 
   /* Don't print the same source location twice in a row, unless we have
      fix-it hints.  */
-  if (loc == context->last_location
+  if (loc == context->m_last_location
       && richloc->get_num_fixit_hints () == 0)
     return;
 
-  context->last_location = loc;
+  context->m_last_location = loc;
 
-  const char *saved_prefix = pp_get_prefix (context->printer);
-  pp_set_prefix (context->printer, NULL);
+  const char *saved_prefix = pp_get_prefix (context->m_printer);
+  pp_set_prefix (context->m_printer, NULL);
 
   layout layout (context, richloc, diagnostic_kind);
   for (int line_span_idx = 0; line_span_idx < layout.get_num_line_spans ();
@@ -1950,14 +1950,14 @@ diagnostic_show_locus (diagnostic_context * context,
       if (layout.print_heading_for_line_span_index_p (line_span_idx))
 	{
 	  expanded_location exploc = layout.get_expanded_location (line_span);
-	  context->start_span (context, exploc);
+	  context->m_start_span (context, exploc);
 	}
       int last_line = line_span->get_last_line ();
       for (int row = line_span->get_first_line (); row <= last_line; row++)
 	layout.print_line (row);
     }
 
-  pp_set_prefix (context->printer, saved_prefix);
+  pp_set_prefix (context->m_printer, saved_prefix);
 }
 
 #if CHECKING_P
@@ -1974,7 +1974,7 @@ test_diagnostic_show_locus_unknown_location ()
   test_diagnostic_context dc;
   rich_location richloc (line_table, UNKNOWN_LOCATION);
   diagnostic_show_locus (&dc, &richloc, DK_ERROR);
-  ASSERT_STREQ ("\n", pp_formatted_text (dc.printer));
+  ASSERT_STREQ ("\n", pp_formatted_text (dc.m_printer));
 }
 
 /* Verify that diagnostic_show_locus works sanely for various
@@ -1999,7 +1999,7 @@ test_one_liner_simple_caret ()
   ASSERT_STREQ ("\n"
 		" foo = bar.field;\n"
 		"          ^\n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Caret and range.  */
@@ -2017,7 +2017,7 @@ test_one_liner_caret_and_range ()
   ASSERT_STREQ ("\n"
 		" foo = bar.field;\n"
 		"       ~~~^~~~~~\n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Multiple ranges and carets.  */
@@ -2030,19 +2030,19 @@ test_one_liner_multiple_carets_and_ranges ()
     = make_location (linemap_position_for_column (line_table, 2),
 		     linemap_position_for_column (line_table, 1),
 		     linemap_position_for_column (line_table, 3));
-  dc.caret_chars[0] = 'A';
+  dc.set_caret_char (0, 'A');
 
   location_t bar
     = make_location (linemap_position_for_column (line_table, 8),
 		     linemap_position_for_column (line_table, 7),
 		     linemap_position_for_column (line_table, 9));
-  dc.caret_chars[1] = 'B';
+  dc.set_caret_char (1, 'B');
 
   location_t field
     = make_location (linemap_position_for_column (line_table, 13),
 		     linemap_position_for_column (line_table, 11),
 		     linemap_position_for_column (line_table, 15));
-  dc.caret_chars[2] = 'C';
+  dc.set_caret_char (2, 'C');
 
   rich_location richloc (line_table, foo);
   richloc.add_range (bar, true);
@@ -2051,7 +2051,7 @@ test_one_liner_multiple_carets_and_ranges ()
   ASSERT_STREQ ("\n"
 		" foo = bar.field;\n"
 		" ~A~   ~B~ ~~C~~\n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Insertion fix-it hint: adding an "&" to the front of "bar.field". */
@@ -2068,7 +2068,7 @@ test_one_liner_fixit_insert_before ()
 		" foo = bar.field;\n"
 		"       ^\n"
 		"       &\n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Insertion fix-it hint: adding a "[0]" after "foo". */
@@ -2087,7 +2087,7 @@ test_one_liner_fixit_insert_after ()
 		" foo = bar.field;\n"
 		" ^~~\n"
 		"    [0]\n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Removal fix-it hint: removal of the ".field". */
@@ -2106,7 +2106,7 @@ test_one_liner_fixit_remove ()
 		" foo = bar.field;\n"
 		"          ^~~~~~\n"
 		"          ------\n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Replace fix-it hint: replacing "field" with "m_field". */
@@ -2125,7 +2125,7 @@ test_one_liner_fixit_replace ()
 		" foo = bar.field;\n"
 		"           ^~~~~\n"
 		"           m_field\n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Replace fix-it hint: replacing "field" with "m_field",
@@ -2151,7 +2151,7 @@ test_one_liner_fixit_replace_non_equal_range ()
 		"     ^\n"
 		"           -----\n"
 		"           m_field\n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Replace fix-it hint: replacing "field" with "m_field",
@@ -2176,7 +2176,7 @@ test_one_liner_fixit_replace_equal_secondary_range ()
 		" foo = bar.field;\n"
 		"     ^     ~~~~~\n"
 		"           m_field\n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Verify that we can use ad-hoc locations when adding fixits to a
@@ -2210,7 +2210,7 @@ test_one_liner_fixit_validation_adhoc_locations ()
 		  " foo = bar.field;\n"
 		  "       ^~~~~~~~~~                               \n"
 		  "       test\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 
   /* Remove.  */
@@ -2227,7 +2227,7 @@ test_one_liner_fixit_validation_adhoc_locations ()
 		  " foo = bar.field;\n"
 		  "       ^~~~~~~~~~                               \n"
 		  "       -----------------------------------------\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 
   /* Replace.  */
@@ -2244,7 +2244,7 @@ test_one_liner_fixit_validation_adhoc_locations ()
 		  " foo = bar.field;\n"
 		  "       ^~~~~~~~~~                               \n"
 		  "       test\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 }
 
@@ -2264,7 +2264,7 @@ test_one_liner_many_fixits_1 ()
 		" foo = bar.field;\n"
 		"     ^\n"
 		"     aaaaaaaaaaaaaaaaaaa\n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Ensure that we can add an arbitrary number of fix-it hints to a
@@ -2287,7 +2287,7 @@ test_one_liner_many_fixits_2 ()
 		" foo = bar.field;\n"
 		"     ^\n"
 		"a a a a a a a a a a a a a a a a a a a\n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Run the various one-liner tests.  */
@@ -2375,7 +2375,7 @@ test_add_location_if_nearby (const line_table_case &case_)
     ASSERT_STREQ ("\n"
 		  " struct same_line { double x; double y; ;\n"
 		  "                  ~                    ^\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 
   /* Test of add_location_if_nearby on a different line to the
@@ -2441,7 +2441,7 @@ test_diagnostic_show_locus_fixit_lines (const line_table_case &case_)
 		  " struct point origin = {x: 0.0,\n"
 		  "                         ^\n"
 		  "                        .=\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 
   /* The multiline case.  The caret for the rich_location is on line 6;
@@ -2466,7 +2466,7 @@ test_diagnostic_show_locus_fixit_lines (const line_table_case &case_)
 		  "                         : 0.0};\n"
 		  "                         ^\n"
 		  "                         =\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 }
 
@@ -2675,7 +2675,7 @@ test_overlapped_fixit_printing (const line_table_case &case_)
 		  "                   ^~~~~~~~~~\n"
 		  "            -----------------\n"
 		  "            const_cast<foo *> (ptr->field)\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
 
     /* Unit-test the line_corrections machinery.  */
     ASSERT_EQ (3, richloc.get_num_fixit_hints ());
@@ -2734,7 +2734,7 @@ test_overlapped_fixit_printing (const line_table_case &case_)
 		  "            -\n"
 		  "            CAST (-\n"
 		  "                  ) (        )\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 
   /* Example where none are consolidated during printing.  */
@@ -2752,7 +2752,7 @@ test_overlapped_fixit_printing (const line_table_case &case_)
 		  "            -\n"
 		  "            CST ( -\n"
 		  "                  ) (        )\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 
   /* Example of deletion fix-it hints.  */
@@ -2773,7 +2773,7 @@ test_overlapped_fixit_printing (const line_table_case &case_)
 		  "                   ^~~~~~~~~~\n"
 		  "            -------\n"
 		  "            (bar *)\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 
   /* Example of deletion fix-it hints that would overlap.  */
@@ -2794,7 +2794,7 @@ test_overlapped_fixit_printing (const line_table_case &case_)
 		  "                   ^~~~~~~~~~\n"
 		  "            -----------------\n"
 		  "            (longer *)(foo *)\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 
   /* Example of insertion fix-it hints that would overlap.  */
@@ -2813,7 +2813,7 @@ test_overlapped_fixit_printing (const line_table_case &case_)
 		  "                   ^~~~~~~~~~\n"
 		  "            -------\n"
 		  "            LONGER THAN THE CAST(foo *)TEST\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 }
 
@@ -2879,7 +2879,7 @@ test_overlapped_fixit_printing_2 (const line_table_case &case_)
 		  " int a5[][0][0] = { 1, 2 };\n"
 		  "                    ^\n"
 		  "                     } {\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 
   /* Various overlapping insertions, some occurring "out of order"
@@ -2903,7 +2903,7 @@ test_overlapped_fixit_printing_2 (const line_table_case &case_)
 		  "                    ^\n"
 		  " {                  -----\n"
 		  "                    {{1}}}}, {{{2 }}\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 }
 
@@ -2943,7 +2943,7 @@ test_fixit_insert_containing_newline (const line_table_case &case_)
 		  "+      break;\n"
 		  "     case 'b':\n"
 		  "     ^~~~~~~~~\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 
   /* Verify that attempts to add text with a newline fail when the
@@ -2957,7 +2957,7 @@ test_fixit_insert_containing_newline (const line_table_case &case_)
     ASSERT_STREQ ("\n"
 		  "     case 'b':\n"
 		  "     ^~~~~~~~~\n",
-		  pp_formatted_text (dc.printer));
+		  pp_formatted_text (dc.m_printer));
   }
 }
 
@@ -3009,7 +3009,7 @@ test_fixit_insert_containing_newline_2 (const line_table_case &case_)
 		"FILENAME:3:2:\n"
 		"  putchar (ch);\n"
 		"  ^~~~~~~\n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Replacement fix-it hint containing a newline.
@@ -3049,7 +3049,7 @@ test_fixit_replace_containing_newline (const line_table_case &case_)
   ASSERT_STREQ ("\n"
 		" foo = bar ();\n"
 		"             ^\n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Fix-it hint, attempting to delete a newline.
@@ -3096,7 +3096,7 @@ test_fixit_deletion_affecting_newline (const line_table_case &case_)
 		"          ~^\n"
 		"       );\n"
 		"       ~    \n",
-		pp_formatted_text (dc.printer));
+		pp_formatted_text (dc.m_printer));
 }
 
 /* Run all of the selftests within this file.  */
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index acc44b1..0083eda 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -44,9 +44,9 @@ along with GCC; see the file COPYING3.  If not see
 #endif
 
 #define pedantic_warning_kind(DC)			\
-  ((DC)->pedantic_errors ? DK_ERROR : DK_WARNING)
-#define permissive_error_kind(DC) ((DC)->permissive ? DK_WARNING : DK_ERROR)
-#define permissive_error_option(DC) ((DC)->opt_permissive)
+  ((DC)->m_pedantic_errors ? DK_ERROR : DK_WARNING)
+#define permissive_error_kind(DC) ((DC)->m_permissive ? DK_WARNING : DK_ERROR)
+#define permissive_error_option(DC) ((DC)->m_opt_permissive)
 
 /* Prototypes.  */
 static bool diagnostic_impl (rich_location *, int, const char *,
@@ -55,7 +55,6 @@ static bool diagnostic_n_impl (rich_location *, int, int, const char *,
 			       const char *, va_list *,
 			       diagnostic_t) ATTRIBUTE_GCC_DIAG(5,0);
 
-static void error_recursion (diagnostic_context *) ATTRIBUTE_NORETURN;
 static void real_abort (void) ATTRIBUTE_NORETURN;
 
 /* Name of program invoked, sans directories.  */
@@ -86,8 +85,8 @@ char *
 file_name_as_prefix (diagnostic_context *context, const char *f)
 {
   const char *locus_cs
-    = colorize_start (pp_show_color (context->printer), "locus");
-  const char *locus_ce = colorize_stop (pp_show_color (context->printer));
+    = colorize_start (pp_show_color (context->m_printer), "locus");
+  const char *locus_ce = colorize_stop (pp_show_color (context->m_printer));
   return build_message_string ("%s%s:%s ", locus_cs, f, locus_ce);
 }
 
@@ -122,62 +121,62 @@ diagnostic_set_caret_max_width (diagnostic_context *context, int value)
 {
   /* One minus to account for the leading empty space.  */
   value = value ? value - 1 
-    : (isatty (fileno (pp_buffer (context->printer)->stream))
+    : (isatty (fileno (pp_buffer (context->m_printer)->stream))
        ? get_terminal_width () - 1: INT_MAX);
   
   if (value <= 0) 
     value = INT_MAX;
 
-  context->caret_max_width = value;
+  context->m_caret_max_width = value;
 }
 
 /* Initialize the diagnostic message outputting machinery.  */
 void
-diagnostic_initialize (diagnostic_context *context, int n_opts)
+diagnostic_context::initialize (int n_opts)
 {
   int i;
 
   /* Allocate a basic pretty-printer.  Clients will replace this a
      much more elaborated pretty-printer if they wish.  */
-  context->printer = XNEW (pretty_printer);
-  new (context->printer) pretty_printer ();
+  m_printer = XNEW (pretty_printer);
+  new (m_printer) pretty_printer ();
 
-  memset (context->diagnostic_count, 0, sizeof context->diagnostic_count);
-  context->warning_as_error_requested = false;
-  context->n_opts = n_opts;
-  context->classify_diagnostic = XNEWVEC (diagnostic_t, n_opts);
+  memset (m_diagnostic_count, 0, sizeof m_diagnostic_count);
+  m_warning_as_error_requested = false;
+  m_n_opts = n_opts;
+  m_classify_diagnostic = XNEWVEC (diagnostic_t, n_opts);
   for (i = 0; i < n_opts; i++)
-    context->classify_diagnostic[i] = DK_UNSPECIFIED;
-  context->show_caret = false;
-  diagnostic_set_caret_max_width (context, pp_line_cutoff (context->printer));
+    m_classify_diagnostic[i] = DK_UNSPECIFIED;
+  m_show_caret = false;
+  diagnostic_set_caret_max_width (this, pp_line_cutoff (m_printer));
   for (i = 0; i < rich_location::STATICALLY_ALLOCATED_RANGES; i++)
-    context->caret_chars[i] = '^';
-  context->show_option_requested = false;
-  context->abort_on_error = false;
-  context->show_column = false;
-  context->pedantic_errors = false;
-  context->permissive = false;
-  context->opt_permissive = 0;
-  context->fatal_errors = false;
-  context->dc_inhibit_warnings = false;
-  context->dc_warn_system_headers = false;
-  context->max_errors = 0;
-  context->internal_error = NULL;
-  diagnostic_starter (context) = default_diagnostic_starter;
-  context->start_span = default_diagnostic_start_span_fn;
-  diagnostic_finalizer (context) = default_diagnostic_finalizer;
-  context->option_enabled = NULL;
-  context->option_state = NULL;
-  context->option_name = NULL;
-  context->last_location = UNKNOWN_LOCATION;
-  context->last_module = 0;
-  context->x_data = NULL;
-  context->lock = 0;
-  context->inhibit_notes_p = false;
-  context->colorize_source_p = false;
-  context->show_ruler_p = false;
-  context->parseable_fixits_p = false;
-  context->edit_context_ptr = NULL;
+    m_caret_chars[i] = '^';
+  m_show_option_requested = false;
+  m_abort_on_error = false;
+  m_show_column = false;
+  m_pedantic_errors = false;
+  m_permissive = false;
+  m_opt_permissive = 0;
+  m_fatal_errors = false;
+  m_inhibit_warnings = false;
+  m_warn_system_headers = false;
+  m_max_errors = 0;
+  m_internal_error = NULL;
+  diagnostic_starter (this) = default_diagnostic_starter;
+  m_start_span = default_diagnostic_start_span_fn;
+  diagnostic_finalizer (this) = default_diagnostic_finalizer;
+  m_option_enabled = NULL;
+  m_option_state = NULL;
+  m_option_name = NULL;
+  m_last_location = UNKNOWN_LOCATION;
+  m_last_module = 0;
+  m_x_data = NULL;
+  m_lock = 0;
+  m_inhibit_notes_p = false;
+  m_colorize_source_p = false;
+  m_show_ruler_p = false;
+  m_parseable_fixits_p = false;
+  m_edit_context_ptr = NULL;
 }
 
 /* Maybe initialize the color support. We require clients to do this
@@ -185,7 +184,7 @@ diagnostic_initialize (diagnostic_context *context, int n_opts)
    without a VALUE, it initializes with DIAGNOSTICS_COLOR_DEFAULT.  */
 
 void
-diagnostic_color_init (diagnostic_context *context, int value /*= -1 */)
+diagnostic_context::color_init (int value /*= -1 */)
 {
   /* value == -1 is the default value.  */
   if (value < 0)
@@ -204,46 +203,46 @@ diagnostic_color_init (diagnostic_context *context, int value /*= -1 */)
       else
 	value = DIAGNOSTICS_COLOR_DEFAULT;
     }
-  pp_show_color (context->printer)
+  pp_show_color (m_printer)
     = colorize_init ((diagnostic_color_rule_t) value);
 }
 
 /* Do any cleaning up required after the last diagnostic is emitted.  */
 
 void
-diagnostic_finish (diagnostic_context *context)
+diagnostic_context::finish ()
 {
   /* Some of the errors may actually have been warnings.  */
-  if (diagnostic_kind_count (context, DK_WERROR))
+  if (kind_count (DK_WERROR))
     {
       /* -Werror was given.  */
-      if (context->warning_as_error_requested)
-	pp_verbatim (context->printer,
+      if (m_warning_as_error_requested)
+	pp_verbatim (m_printer,
 		     _("%s: all warnings being treated as errors"),
 		     progname);
       /* At least one -Werror= was given.  */
       else
-	pp_verbatim (context->printer,
+	pp_verbatim (m_printer,
 		     _("%s: some warnings being treated as errors"),
 		     progname);
-      pp_newline_and_flush (context->printer);
+      pp_newline_and_flush (m_printer);
     }
 
   diagnostic_file_cache_fini ();
 
-  XDELETEVEC (context->classify_diagnostic);
-  context->classify_diagnostic = NULL;
+  XDELETEVEC (m_classify_diagnostic);
+  m_classify_diagnostic = NULL;
 
-  /* diagnostic_initialize allocates context->printer using XNEW
+  /* diagnostic_context::initialize allocates m_printer using XNEW
      and placement-new.  */
-  context->printer->~pretty_printer ();
-  XDELETE (context->printer);
-  context->printer = NULL;
+  m_printer->~pretty_printer ();
+  XDELETE (m_printer);
+  m_printer = NULL;
 
-  if (context->edit_context_ptr)
+  if (m_edit_context_ptr)
     {
-      delete context->edit_context_ptr;
-      context->edit_context_ptr = NULL;
+      delete m_edit_context_ptr;
+      m_edit_context_ptr = NULL;
     }
 }
 
@@ -317,12 +316,12 @@ static char *
 diagnostic_get_location_text (diagnostic_context *context,
 			      expanded_location s)
 {
-  pretty_printer *pp = context->printer;
+  pretty_printer *pp = context->m_printer;
   const char *locus_cs = colorize_start (pp_show_color (pp), "locus");
   const char *locus_ce = colorize_stop (pp_show_color (pp));
   const char *file = s.file ? s.file : progname;
   int line = strcmp (file, N_("<built-in>")) ? s.line : 0;
-  int col = context->show_column ? s.column : 0;
+  int col = context->m_show_column ? s.column : 0;
 
   const char *line_col = maybe_line_and_column (line, col);
   return build_message_string ("%s%s%s:%s", locus_cs, file,
@@ -346,7 +345,7 @@ diagnostic_build_prefix (diagnostic_context *context,
 
   const char *text = _(diagnostic_kind_text[diagnostic->kind]);
   const char *text_cs = "", *text_ce = "";
-  pretty_printer *pp = context->printer;
+  pretty_printer *pp = context->m_printer;
 
   if (diagnostic_kind_color[diagnostic->kind])
     {
@@ -464,20 +463,20 @@ bt_err_callback (void *data ATTRIBUTE_UNUSED, const char *msg, int errnum)
 void
 diagnostic_check_max_errors (diagnostic_context *context, bool flush)
 {
-  if (!context->max_errors)
+  if (!context->m_max_errors)
     return;
 
-  int count = (diagnostic_kind_count (context, DK_ERROR)
-	       + diagnostic_kind_count (context, DK_SORRY)
-	       + diagnostic_kind_count (context, DK_WERROR));
+  int count = (context->kind_count (DK_ERROR)
+	       + context->kind_count (DK_SORRY)
+	       + context->kind_count (DK_WERROR));
 
-  if (count >= context->max_errors)
+  if (count >= context->m_max_errors)
     {
       fnotice (stderr,
 	       "compilation terminated due to -fmax-errors=%u.\n",
-	       context->max_errors);
+	       context->m_max_errors);
       if (flush)
-	diagnostic_finish (context);
+	context->finish ();
       exit (FATAL_EXIT_CODE);
     }
 }
@@ -485,8 +484,7 @@ diagnostic_check_max_errors (diagnostic_context *context, bool flush)
 /* Take any action which is expected to happen after the diagnostic
    is written out.  This function does not always return.  */
 void
-diagnostic_action_after_output (diagnostic_context *context,
-				diagnostic_t diag_kind)
+diagnostic_context::action_after_output (diagnostic_t diag_kind)
 {
   switch (diag_kind)
     {
@@ -498,12 +496,12 @@ diagnostic_action_after_output (diagnostic_context *context,
 
     case DK_ERROR:
     case DK_SORRY:
-      if (context->abort_on_error)
+      if (m_abort_on_error)
 	real_abort ();
-      if (context->fatal_errors)
+      if (m_fatal_errors)
 	{
 	  fnotice (stderr, "compilation terminated due to -Wfatal-errors.\n");
-	  diagnostic_finish (context);
+	  finish ();
 	  exit (FATAL_EXIT_CODE);
 	}
       break;
@@ -519,7 +517,7 @@ diagnostic_action_after_output (diagnostic_context *context,
 	  backtrace_full (state, 2, bt_callback, bt_err_callback,
 			  (void *) &count);
 
-	if (context->abort_on_error)
+	if (m_abort_on_error)
 	  real_abort ();
 
 	fnotice (stderr, "Please submit a full bug report,\n"
@@ -534,9 +532,9 @@ diagnostic_action_after_output (diagnostic_context *context,
       }
 
     case DK_FATAL:
-      if (context->abort_on_error)
+      if (m_abort_on_error)
 	real_abort ();
-      diagnostic_finish (context);
+      finish ();
       fnotice (stderr, "compilation terminated.\n");
       exit (FATAL_EXIT_CODE);
 
@@ -548,31 +546,30 @@ diagnostic_action_after_output (diagnostic_context *context,
 /* True if the last module or file in which a diagnostic was reported is
    different from the current one.  */
 
-static bool
-last_module_changed_p (diagnostic_context *context,
-		       const line_map_ordinary *map)
+bool
+diagnostic_context::last_module_changed_p (const line_map_ordinary *map)
 {
-  return context->last_module != map;
+  return m_last_module != map;
 }
 
 /* Remember the current module or file as being the last one in which we
    report a diagnostic.  */
 
-static void
-set_last_module (diagnostic_context *context, const line_map_ordinary *map)
+void
+diagnostic_context::set_last_module (const line_map_ordinary *map)
 {
-  context->last_module = map;
+  m_last_module = map;
 }
 
 void
-diagnostic_report_current_module (diagnostic_context *context, location_t where)
+diagnostic_context::report_current_module (location_t where)
 {
   const line_map_ordinary *map = NULL;
 
-  if (pp_needs_newline (context->printer))
+  if (pp_needs_newline (m_printer))
     {
-      pp_newline (context->printer);
-      pp_needs_newline (context->printer) = false;
+      pp_newline (m_printer);
+      pp_needs_newline (m_printer) = false;
     }
 
   if (where <= BUILTINS_LOCATION)
@@ -582,29 +579,29 @@ diagnostic_report_current_module (diagnostic_context *context, location_t where)
 			    LRK_MACRO_DEFINITION_LOCATION,
 			    &map);
 
-  if (map && last_module_changed_p (context, map))
+  if (map && last_module_changed_p (map))
     {
-      set_last_module (context, map);
+      set_last_module (map);
       if (! MAIN_FILE_P (map))
 	{
 	  map = INCLUDED_FROM (line_table, map);
 	  const char *line_col
 	    = maybe_line_and_column (LAST_SOURCE_LINE (map),
-				     context->show_column
+				     m_show_column
 				     ? LAST_SOURCE_COLUMN (map) : 0);
-	  pp_verbatim (context->printer,
+	  pp_verbatim (m_printer,
 		       "In file included from %r%s%s%R", "locus",
 		       LINEMAP_FILE (map), line_col);
 	  while (! MAIN_FILE_P (map))
 	    {
 	      map = INCLUDED_FROM (line_table, map);
 	      line_col = maybe_line_and_column (LAST_SOURCE_LINE (map), 0);
-	      pp_verbatim (context->printer,
+	      pp_verbatim (m_printer,
 			   ",\n                 from %r%s%s%R", "locus",
 			   LINEMAP_FILE (map), line_col);
 	    }
-	  pp_verbatim (context->printer, ":");
-	  pp_newline (context->printer);
+	  pp_verbatim (m_printer, ":");
+	  pp_newline (m_printer);
 	}
     }
 }
@@ -613,8 +610,8 @@ void
 default_diagnostic_starter (diagnostic_context *context,
 			    diagnostic_info *diagnostic)
 {
-  diagnostic_report_current_module (context, diagnostic_location (diagnostic));
-  pp_set_prefix (context->printer, diagnostic_build_prefix (context,
+  context->report_current_module (diagnostic_location (diagnostic));
+  pp_set_prefix (context->m_printer, diagnostic_build_prefix (context,
 							    diagnostic));
 }
 
@@ -622,10 +619,10 @@ void
 default_diagnostic_start_span_fn (diagnostic_context *context,
 				  expanded_location exploc)
 {
-  pp_set_prefix (context->printer,
+  pp_set_prefix (context->m_printer,
 		 diagnostic_get_location_text (context, exploc));
-  pp_string (context->printer, "");
-  pp_newline (context->printer);
+  pp_string (context->m_printer, "");
+  pp_newline (context->m_printer);
 }
 
 void
@@ -633,8 +630,8 @@ default_diagnostic_finalizer (diagnostic_context *context,
 			      diagnostic_info *diagnostic)
 {
   diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind);
-  pp_destroy_prefix (context->printer);
-  pp_flush (context->printer);
+  pp_destroy_prefix (context->m_printer);
+  pp_flush (context->m_printer);
 }
 
 /* Interface to specify diagnostic kind overrides.  Returns the
@@ -642,19 +639,18 @@ default_diagnostic_finalizer (diagnostic_context *context,
    range.  If OPTION_INDEX is zero, the new setting is for all the
    diagnostics.  */
 diagnostic_t
-diagnostic_classify_diagnostic (diagnostic_context *context,
-				int option_index,
-				diagnostic_t new_kind,
-				location_t where)
+diagnostic_context::classify_diagnostic (int option_index,
+					 diagnostic_t new_kind,
+					 location_t where)
 {
   diagnostic_t old_kind;
 
   if (option_index < 0
-      || option_index >= context->n_opts
+      || option_index >= m_n_opts
       || new_kind >= DK_LAST_DIAGNOSTIC_KIND)
     return DK_UNSPECIFIED;
 
-  old_kind = context->classify_diagnostic[option_index];
+  old_kind = m_classify_diagnostic[option_index];
 
   /* Handle pragmas separately, since we need to keep track of *where*
      the pragmas were.  */
@@ -665,64 +661,63 @@ diagnostic_classify_diagnostic (diagnostic_context *context,
       /* Record the command-line status, so we can reset it back on DK_POP. */
       if (old_kind == DK_UNSPECIFIED)
 	{
-	  old_kind = !context->option_enabled (option_index,
-					       context->option_state)
-	    ? DK_IGNORED : (context->warning_as_error_requested
+	  old_kind = !m_option_enabled (option_index, m_option_state)
+	    ? DK_IGNORED : (m_warning_as_error_requested
 			    ? DK_ERROR : DK_WARNING);
-	  context->classify_diagnostic[option_index] = old_kind;
+	  m_classify_diagnostic[option_index] = old_kind;
 	}
 
-      for (i = context->n_classification_history - 1; i >= 0; i --)
-	if (context->classification_history[i].option == option_index)
+      for (i = m_n_classification_history - 1; i >= 0; i --)
+	if (m_classification_history[i].option == option_index)
 	  {
-	    old_kind = context->classification_history[i].kind;
+	    old_kind = m_classification_history[i].kind;
 	    break;
 	  }
 
-      i = context->n_classification_history;
-      context->classification_history =
-	(diagnostic_classification_change_t *) xrealloc (context->classification_history, (i + 1)
+      i = m_n_classification_history;
+      m_classification_history =
+	(diagnostic_classification_change_t *) xrealloc (m_classification_history, (i + 1)
 							 * sizeof (diagnostic_classification_change_t));
-      context->classification_history[i].location = where;
-      context->classification_history[i].option = option_index;
-      context->classification_history[i].kind = new_kind;
-      context->n_classification_history ++;
+      m_classification_history[i].location = where;
+      m_classification_history[i].option = option_index;
+      m_classification_history[i].kind = new_kind;
+      m_n_classification_history ++;
     }
   else
-    context->classify_diagnostic[option_index] = new_kind;
+    m_classify_diagnostic[option_index] = new_kind;
 
   return old_kind;
 }
 
 /* Save all diagnostic classifications in a stack.  */
 void
-diagnostic_push_diagnostics (diagnostic_context *context, location_t where ATTRIBUTE_UNUSED)
+diagnostic_context::push_diagnostics (location_t where ATTRIBUTE_UNUSED)
 {
-  context->push_list = (int *) xrealloc (context->push_list, (context->n_push + 1) * sizeof (int));
-  context->push_list[context->n_push ++] = context->n_classification_history;
+  m_push_list = (int *) xrealloc (m_push_list, (m_n_push + 1) * sizeof (int));
+  m_push_list[m_n_push ++] = m_n_classification_history;
 }
 
 /* Restore the topmost classification set off the stack.  If the stack
    is empty, revert to the state based on command line parameters.  */
 void
-diagnostic_pop_diagnostics (diagnostic_context *context, location_t where)
+diagnostic_context::pop_diagnostics (location_t where)
 {
   int jump_to;
   int i;
 
-  if (context->n_push)
-    jump_to = context->push_list [-- context->n_push];
+  if (m_n_push)
+    jump_to = m_push_list [-- m_n_push];
   else
     jump_to = 0;
 
-  i = context->n_classification_history;
-  context->classification_history =
-    (diagnostic_classification_change_t *) xrealloc (context->classification_history, (i + 1)
+  i = m_n_classification_history;
+  m_classification_history =
+    (diagnostic_classification_change_t *) xrealloc (m_classification_history, (i + 1)
 						     * sizeof (diagnostic_classification_change_t));
-  context->classification_history[i].location = where;
-  context->classification_history[i].option = jump_to;
-  context->classification_history[i].kind = DK_POP;
-  context->n_classification_history ++;
+  m_classification_history[i].location = where;
+  m_classification_history[i].option = jump_to;
+  m_classification_history[i].kind = DK_POP;
+  m_n_classification_history ++;
 }
 
 /* Helper function for print_parseable_fixits.  Print TEXT to PP, obeying the
@@ -800,39 +795,38 @@ print_parseable_fixits (pretty_printer *pp, rich_location *richloc)
 /* Update the diag_class of DIAGNOSTIC based on its location
    relative to any
      #pragma GCC diagnostic
-   directives recorded within CONTEXT.
+   directives recorded within this context.
 
    Return the new diag_class of DIAGNOSTIC if it was updated, or
    DK_UNSPECIFIED otherwise.  */
 
-static diagnostic_t
-update_effective_level_from_pragmas (diagnostic_context *context,
-				     diagnostic_info *diagnostic)
+diagnostic_t
+diagnostic_context::
+update_effective_level_from_pragmas (diagnostic_info *diagnostic) const
 {
   diagnostic_t diag_class = DK_UNSPECIFIED;
 
-  if (context->n_classification_history > 0)
+  if (m_n_classification_history > 0)
     {
       location_t location = diagnostic_location (diagnostic);
 
       /* FIXME: Stupid search.  Optimize later. */
-      for (int i = context->n_classification_history - 1; i >= 0; i --)
+      for (int i = m_n_classification_history - 1; i >= 0; i --)
 	{
-	  if (linemap_location_before_p
-	      (line_table,
-	       context->classification_history[i].location,
-	       location))
+	  if (linemap_location_before_p (line_table,
+					 m_classification_history[i].location,
+					 location))
 	    {
-	      if (context->classification_history[i].kind == (int) DK_POP)
+	      if (m_classification_history[i].kind == (int) DK_POP)
 		{
-		  i = context->classification_history[i].option;
+		  i = m_classification_history[i].option;
 		  continue;
 		}
-	      int option = context->classification_history[i].option;
+	      int option = m_classification_history[i].option;
 	      /* The option 0 is for all the diagnostics.  */
 	      if (option == 0 || option == diagnostic->option_index)
 		{
-		  diag_class = context->classification_history[i].kind;
+		  diag_class = m_classification_history[i].kind;
 		  if (diag_class != DK_UNSPECIFIED)
 		    diagnostic->kind = diag_class;
 		  break;
@@ -846,7 +840,7 @@ update_effective_level_from_pragmas (diagnostic_context *context,
 
 /* Print any metadata about the option used to control DIAGNOSTIC to CONTEXT's
    printer, e.g. " [-Werror=uninitialized]".
-   Subroutine of diagnostic_report_diagnostic.  */
+   Subroutine of diagnostic_context::report_diagnostic.  */
 
 static void
 print_option_information (diagnostic_context *context,
@@ -855,12 +849,12 @@ print_option_information (diagnostic_context *context,
 {
   char *option_text;
 
-  option_text = context->option_name (context, diagnostic->option_index,
+  option_text = context->m_option_name (context, diagnostic->option_index,
 				      orig_diag_kind, diagnostic->kind);
 
   if (option_text)
     {
-      pretty_printer *pp = context->printer;
+      pretty_printer *pp = context->m_printer;
       pp_string (pp, " [");
       pp_string (pp, colorize_start (pp_show_color (pp),
 				     diagnostic_kind_color[diagnostic->kind]));
@@ -879,8 +873,7 @@ print_option_information (diagnostic_context *context,
    Return true if a diagnostic was printed, false otherwise.  */
 
 bool
-diagnostic_report_diagnostic (diagnostic_context *context,
-			      diagnostic_info *diagnostic)
+diagnostic_context::report_diagnostic (diagnostic_info *diagnostic)
 {
   location_t location = diagnostic_location (diagnostic);
   diagnostic_t orig_diag_kind = diagnostic->kind;
@@ -888,59 +881,59 @@ diagnostic_report_diagnostic (diagnostic_context *context,
   /* Give preference to being able to inhibit warnings, before they
      get reclassified to something else.  */
   if ((diagnostic->kind == DK_WARNING || diagnostic->kind == DK_PEDWARN)
-      && !diagnostic_report_warnings_p (context, location))
+      && !diagnostic_report_warnings_p (this, location))
     return false;
 
   if (diagnostic->kind == DK_PEDWARN)
     {
-      diagnostic->kind = pedantic_warning_kind (context);
+      diagnostic->kind = pedantic_warning_kind (this);
       /* We do this to avoid giving the message for -pedantic-errors.  */
       orig_diag_kind = diagnostic->kind;
     }
  
-  if (diagnostic->kind == DK_NOTE && context->inhibit_notes_p)
+  if (diagnostic->kind == DK_NOTE && m_inhibit_notes_p)
     return false;
 
-  if (context->lock > 0)
+  if (m_lock > 0)
     {
       /* If we're reporting an ICE in the middle of some other error,
 	 try to flush out the previous error, then let this one
 	 through.  Don't do this more than once.  */
       if ((diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
-	  && context->lock == 1)
-	pp_newline_and_flush (context->printer);
+	  && m_lock == 1)
+	pp_newline_and_flush (m_printer);
       else
-	error_recursion (context);
+	error_recursion ();
     }
 
   /* If the user requested that warnings be treated as errors, so be
      it.  Note that we do this before the next block so that
      individual warnings can be overridden back to warnings with
      -Wno-error=*.  */
-  if (context->warning_as_error_requested
+  if (m_warning_as_error_requested
       && diagnostic->kind == DK_WARNING)
     diagnostic->kind = DK_ERROR;
 
   if (diagnostic->option_index
-      && diagnostic->option_index != permissive_error_option (context))
+      && diagnostic->option_index != permissive_error_option (this))
     {
       /* This tests if the user provided the appropriate -Wfoo or
 	 -Wno-foo option.  */
-      if (! context->option_enabled (diagnostic->option_index,
-				     context->option_state))
+      if (! m_option_enabled (diagnostic->option_index,
+				     m_option_state))
 	return false;
 
       /* This tests for #pragma diagnostic changes.  */
       diagnostic_t diag_class
-	= update_effective_level_from_pragmas (context, diagnostic);
+	= update_effective_level_from_pragmas (diagnostic);
 
       /* This tests if the user provided the appropriate -Werror=foo
 	 option.  */
       if (diag_class == DK_UNSPECIFIED
-	  && (context->classify_diagnostic[diagnostic->option_index]
+	  && (m_classify_diagnostic[diagnostic->option_index]
 	      != DK_UNSPECIFIED))
 	diagnostic->kind
-	  = context->classify_diagnostic[diagnostic->option_index];
+	  = m_classify_diagnostic[diagnostic->option_index];
 
       /* This allows for future extensions, like temporarily disabling
 	 warnings for ranges of source code.  */
@@ -949,9 +942,9 @@ diagnostic_report_diagnostic (diagnostic_context *context,
     }
 
   if (diagnostic->kind != DK_NOTE)
-    diagnostic_check_max_errors (context);
+    diagnostic_check_max_errors (this);
 
-  context->lock++;
+  m_lock++;
 
   if (diagnostic->kind == DK_ICE || diagnostic->kind == DK_ICE_NOBT)
     {
@@ -959,9 +952,9 @@ diagnostic_report_diagnostic (diagnostic_context *context,
 	 error has already occurred.  This is counteracted by
 	 abort_on_error.  */
       if (!CHECKING_P
-	  && (diagnostic_kind_count (context, DK_ERROR) > 0
-	      || diagnostic_kind_count (context, DK_SORRY) > 0)
-	  && !context->abort_on_error)
+	  && (kind_count (DK_ERROR) > 0
+	      || kind_count (DK_SORRY) > 0)
+	  && !m_abort_on_error)
 	{
 	  expanded_location s 
 	    = expand_location (diagnostic_location (diagnostic));
@@ -969,37 +962,37 @@ diagnostic_report_diagnostic (diagnostic_context *context,
 		   s.file, s.line);
 	  exit (ICE_EXIT_CODE);
 	}
-      if (context->internal_error)
-	(*context->internal_error) (context,
-				    diagnostic->message.format_spec,
-				    diagnostic->message.args_ptr);
+      if (m_internal_error)
+	(*m_internal_error) (this,
+			     diagnostic->message.format_spec,
+			     diagnostic->message.args_ptr);
     }
   if (diagnostic->kind == DK_ERROR && orig_diag_kind == DK_WARNING)
-    ++diagnostic_kind_count (context, DK_WERROR);
+    ++kind_count (DK_WERROR);
   else
-    ++diagnostic_kind_count (context, diagnostic->kind);
+    ++kind_count (diagnostic->kind);
 
   diagnostic->message.x_data = &diagnostic->x_data;
   diagnostic->x_data = NULL;
-  pp_format (context->printer, &diagnostic->message);
-  (*diagnostic_starter (context)) (context, diagnostic);
-  pp_output_formatted_text (context->printer);
-  if (context->show_option_requested)
-    print_option_information (context, diagnostic, orig_diag_kind);
-  (*diagnostic_finalizer (context)) (context, diagnostic);
-  if (context->parseable_fixits_p)
+  pp_format (m_printer, &diagnostic->message);
+  (*diagnostic_starter (this)) (this, diagnostic);
+  pp_output_formatted_text (m_printer);
+  if (m_show_option_requested)
+    print_option_information (this, diagnostic, orig_diag_kind);
+  (*diagnostic_finalizer (this)) (this, diagnostic);
+  if (m_parseable_fixits_p)
     {
-      print_parseable_fixits (context->printer, diagnostic->richloc);
-      pp_flush (context->printer);
+      print_parseable_fixits (m_printer, diagnostic->richloc);
+      pp_flush (m_printer);
     }
-  diagnostic_action_after_output (context, diagnostic->kind);
+  action_after_output (diagnostic->kind);
   diagnostic->x_data = NULL;
 
-  if (context->edit_context_ptr)
+  if (m_edit_context_ptr)
     if (diagnostic->richloc->fixits_can_be_auto_applied_p ())
-      context->edit_context_ptr->add_fixits (diagnostic->richloc);
+      m_edit_context_ptr->add_fixits (diagnostic->richloc);
 
-  context->lock--;
+  m_lock--;
 
   return true;
 }
@@ -1050,8 +1043,8 @@ verbatim (const char *gmsgid, ...)
   text.args_ptr = &ap;
   text.format_spec = _(gmsgid);
   text.x_data = NULL;
-  pp_format_verbatim (global_dc->printer, &text);
-  pp_newline_and_flush (global_dc->printer);
+  pp_format_verbatim (global_dc->m_printer, &text);
+  pp_newline_and_flush (global_dc->m_printer);
   va_end (ap);
 }
 
@@ -1068,18 +1061,18 @@ diagnostic_append_note (diagnostic_context *context,
 
   va_start (ap, gmsgid);
   diagnostic_set_info (&diagnostic, gmsgid, &ap, &richloc, DK_NOTE);
-  if (context->inhibit_notes_p)
+  if (context->m_inhibit_notes_p)
     {
       va_end (ap);
       return;
     }
-  saved_prefix = pp_get_prefix (context->printer);
-  pp_set_prefix (context->printer,
+  saved_prefix = pp_get_prefix (context->m_printer);
+  pp_set_prefix (context->m_printer,
                  diagnostic_build_prefix (context, &diagnostic));
-  pp_format (context->printer, &diagnostic.message);
-  pp_output_formatted_text (context->printer);
-  pp_destroy_prefix (context->printer);
-  pp_set_prefix (context->printer, saved_prefix);
+  pp_format (context->m_printer, &diagnostic.message);
+  pp_output_formatted_text (context->m_printer);
+  pp_destroy_prefix (context->m_printer);
+  pp_set_prefix (context->m_printer, saved_prefix);
   diagnostic_show_locus (context, &richloc, DK_NOTE);
   va_end (ap);
 }
@@ -1105,7 +1098,7 @@ diagnostic_impl (rich_location *richloc, int opt,
       if (kind == DK_WARNING || kind == DK_PEDWARN)
 	diagnostic.option_index = opt;
     }
-  return diagnostic_report_diagnostic (global_dc, &diagnostic);
+  return global_dc->report_diagnostic (&diagnostic);
 }
 
 /* Implement inform_n, warning_n, and error_n, as documented and
@@ -1122,7 +1115,7 @@ diagnostic_n_impl (rich_location *richloc, int opt, int n,
                                   ap, richloc, kind);
   if (kind == DK_WARNING)
     diagnostic.option_index = opt;
-  return diagnostic_report_diagnostic (global_dc, &diagnostic);
+  return global_dc->report_diagnostic (&diagnostic);
 }
 
 /* Wrapper around diagnostic_impl taking a variable argument list.  */
@@ -1472,18 +1465,18 @@ fnotice (FILE *file, const char *cmsgid, ...)
    so give up now.  But do try to flush out the previous error.
    This mustn't use internal_error, that will cause infinite recursion.  */
 
-static void
-error_recursion (diagnostic_context *context)
+void
+diagnostic_context::error_recursion ()
 {
-  if (context->lock < 3)
-    pp_newline_and_flush (context->printer);
+  if (m_lock < 3)
+    pp_newline_and_flush (m_printer);
 
   fnotice (stderr,
 	   "Internal compiler error: Error reporting routines re-entered.\n");
 
-  /* Call diagnostic_action_after_output to get the "please submit a bug
+  /* Call action_after_output to get the "please submit a bug
      report" message.  */
-  diagnostic_action_after_output (context, DK_ICE);
+  action_after_output (DK_ICE);
 
   /* Do not use gcc_unreachable here; that goes through internal_error
      and therefore would cause infinite recursion.  */
@@ -1651,7 +1644,7 @@ assert_location_text (const char *expected_loc_text,
 		      bool show_column)
 {
   test_diagnostic_context dc;
-  dc.show_column = show_column;
+  dc.m_show_column = show_column;
 
   expanded_location xloc;
   xloc.file = filename;
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
index bdcbc62..0e57d2b 100644
--- a/gcc/diagnostic.h
+++ b/gcc/diagnostic.h
@@ -66,20 +66,67 @@ class edit_context;
 
 /* This data structure bundles altogether any information relevant to
    the context of a diagnostic message.  */
-struct diagnostic_context
+class diagnostic_context
 {
+public:
+  void initialize (int);
+  void color_init (int value = -1);
+  void finish ();
+
+  bool report_diagnostic (diagnostic_info *);
+  void report_current_module (location_t);
+
+  /* Force diagnostics controlled by OPTIDX to be kind KIND.  */
+  diagnostic_t classify_diagnostic (int /* optidx */,
+				    diagnostic_t /* kind */,
+				    location_t);
+  void push_diagnostics (location_t);
+  void pop_diagnostics (location_t);
+
+  void inhibit_notes () { m_inhibit_notes_p = true; }
+
+  /* The total count of a KIND of diagnostics emitted so far.  */
+  int& kind_count (diagnostic_t kind) { return m_diagnostic_count[kind]; }
+
+  void action_after_output (diagnostic_t);
+
+  void set_caret_char (int idx, char ch)
+  {
+    gcc_assert (idx < rich_location::STATICALLY_ALLOCATED_RANGES);
+    m_caret_chars[idx] = ch;
+  }
+  char get_caret_char (int idx) const
+  {
+    gcc_assert (idx < rich_location::STATICALLY_ALLOCATED_RANGES);
+    return m_caret_chars[idx];
+  }
+
+ private:
+  void error_recursion () ATTRIBUTE_NORETURN;
+  diagnostic_t update_effective_level_from_pragmas (diagnostic_info *) const;
+
+  bool last_module_changed_p (const line_map_ordinary *map);
+  void set_last_module (const line_map_ordinary *map);
+
+  //private:
+ public:
   /* Where most of the diagnostic formatting work is done.  */
-  pretty_printer *printer;
+  pretty_printer *m_printer;
 
+ private:
   /* The number of times we have issued diagnostics.  */
-  int diagnostic_count[DK_LAST_DIAGNOSTIC_KIND];
+  int m_diagnostic_count[DK_LAST_DIAGNOSTIC_KIND];
 
+ public:
   /* True if it has been requested that warnings be treated as errors.  */
-  bool warning_as_error_requested;
+  bool m_warning_as_error_requested;
 
+ private:
   /* The number of option indexes that can be passed to warning() et
      al.  */
-  int n_opts;
+  int m_n_opts;
+
+ public: // FIXME: read from in a couple of places:
 
   /* For each option index that can be passed to warning() et al
      (OPT_* from options.h when using this code with the core GCC
@@ -87,63 +134,69 @@ struct diagnostic_context
      should be changed to before reporting, or DK_UNSPECIFIED to leave
      it as the reported kind, or DK_IGNORED to not report it at
      all.  */
-  diagnostic_t *classify_diagnostic;
+  diagnostic_t *m_classify_diagnostic;
 
+ private:
   /* History of all changes to the classifications above.  This list
      is stored in location-order, so we can search it, either
      binary-wise or end-to-front, to find the most recent
      classification for a given diagnostic, given the location of the
      diagnostic.  */
-  diagnostic_classification_change_t *classification_history;
+  diagnostic_classification_change_t *m_classification_history;
 
   /* The size of the above array.  */
-  int n_classification_history;
+  int m_n_classification_history;
 
   /* For pragma push/pop.  */
-  int *push_list;
-  int n_push;
+  int *m_push_list;
+  int m_n_push;
+
+ public: // FIXME: modified in a few places
 
   /* True if we should print the source line with a caret indicating
      the location.  */
-  bool show_caret;
+  bool m_show_caret;
 
+ public:
   /* Maximum width of the source line printed.  */
-  int caret_max_width;
+  int m_caret_max_width;
 
+ private:
   /* Character used for caret diagnostics.  */
-  char caret_chars[rich_location::STATICALLY_ALLOCATED_RANGES];
+  char m_caret_chars[rich_location::STATICALLY_ALLOCATED_RANGES];
 
+ public:
   /* True if we should print the command line option which controls
      each diagnostic, if known.  */
-  bool show_option_requested;
+  bool m_show_option_requested;
 
   /* True if we should raise a SIGABRT on errors.  */
-  bool abort_on_error;
+  bool m_abort_on_error;
 
   /* True if we should show the column number on diagnostics.  */
-  bool show_column;
+  bool m_show_column;
 
   /* True if pedwarns are errors.  */
-  bool pedantic_errors;
+  bool m_pedantic_errors;
 
   /* True if permerrors are warnings.  */
-  bool permissive;
+  bool m_permissive;
 
   /* The index of the option to associate with turning permerrors into
      warnings.  */
-  int opt_permissive;
+  int m_opt_permissive;
 
   /* True if errors are fatal.  */
-  bool fatal_errors;
+  bool m_fatal_errors;
 
   /* True if all warnings should be disabled.  */
-  bool dc_inhibit_warnings;
+  bool m_inhibit_warnings;
 
   /* True if warnings should be given in system headers.  */
-  bool dc_warn_system_headers;
+  bool m_warn_system_headers;
 
   /* Maximum number of errors to report.  */
-  int max_errors;
+  int m_max_errors;
 
   /* This function is called before any message is printed out.  It is
      responsible for preparing message prefix and such.  For example, it
@@ -152,26 +205,26 @@ struct diagnostic_context
                       from "/home/gdr/src/nifty_printer.h:56:
                       ...
   */
-  diagnostic_starter_fn begin_diagnostic;
+  diagnostic_starter_fn m_begin_diagnostic;
 
   /* This function is called by diagnostic_show_locus in between
      disjoint spans of source code, so that the context can print
      something to indicate that a new span of source code has begun.  */
-  diagnostic_start_span_fn start_span;
+  diagnostic_start_span_fn m_start_span;
 
   /* This function is called after the diagnostic message is printed.  */
-  diagnostic_finalizer_fn end_diagnostic;
+  diagnostic_finalizer_fn m_end_diagnostic;
 
   /* Client hook to report an internal error.  */
-  void (*internal_error) (diagnostic_context *, const char *, va_list *);
+  void (*m_internal_error) (diagnostic_context *, const char *, va_list *);
 
   /* Client hook to say whether the option controlling a diagnostic is
      enabled.  Returns nonzero if enabled, zero if disabled.  */
-  int (*option_enabled) (int, void *);
+  int (*m_option_enabled) (int, void *);
 
   /* Client information to pass as second argument to
      option_enabled.  */
-  void *option_state;
+  void *m_option_state;
 
   /* Client hook to return the name of an option that controls a
      diagnostic.  Returns malloced memory.  The first diagnostic_t
@@ -179,21 +232,24 @@ struct diagnostic_context
      (of warnings as errors, etc.); the second is the kind after any
      reclassification.  May return NULL if no name is to be printed.
      May be passed 0 as well as the index of a particular option.  */
-  char *(*option_name) (diagnostic_context *, int, diagnostic_t, diagnostic_t);
+  char *(*m_option_name) (diagnostic_context *, int, diagnostic_t, diagnostic_t);
 
   /* Auxiliary data for client.  */
-  void *x_data;
+  void *m_x_data;
 
+  //private:
   /* Used to detect that the last caret was printed at the same location.  */
-  location_t last_location;
+  location_t m_last_location;
 
   /* Used to detect when the input file stack has changed since last
      described.  */
-  const line_map_ordinary *last_module;
+  const line_map_ordinary *m_last_module;
 
-  int lock;
+ private:
+  int m_lock;
 
-  bool inhibit_notes_p;
+ public:
+  bool m_inhibit_notes_p;
 
   /* When printing source code, should the characters at carets and ranges
      be colorized? (assuming colorization is on at all).
@@ -202,74 +258,64 @@ struct diagnostic_context
      and false for frontends that merely specify points within the
      source code (to avoid e.g. colorizing just the first character in
      a token, which would look strange).  */
-  bool colorize_source_p;
+  bool m_colorize_source_p;
 
   /* Usable by plugins; if true, print a debugging ruler above the
      source output.  */
-  bool show_ruler_p;
+  bool m_show_ruler_p;
 
   /* If true, print fixits in machine-parseable form after the
      rest of the diagnostic.  */
-  bool parseable_fixits_p;
+  bool m_parseable_fixits_p;
 
   /* If non-NULL, an edit_context to which fix-it hints should be
      applied, for generating patches.  */
-  edit_context *edit_context_ptr;
+  edit_context *m_edit_context_ptr;
 
   /* FIXME.  */
-  source_manager *src_manager;
+  source_manager *m_src_manager;
 };
 
-static inline void
-diagnostic_inhibit_notes (diagnostic_context * context)
-{
-  context->inhibit_notes_p = true;
-}
-
-
 /* Client supplied function to announce a diagnostic.  */
-#define diagnostic_starter(DC) (DC)->begin_diagnostic
+#define diagnostic_starter(DC) (DC)->m_begin_diagnostic
 
 /* Client supplied function called after a diagnostic message is
    displayed.  */
-#define diagnostic_finalizer(DC) (DC)->end_diagnostic
+#define diagnostic_finalizer(DC) (DC)->m_end_diagnostic
 
 /* Extension hooks for client.  */
-#define diagnostic_context_auxiliary_data(DC) (DC)->x_data
+#define diagnostic_context_auxiliary_data(DC) (DC)->m_x_data
 #define diagnostic_info_auxiliary_data(DI) (DI)->x_data
 
 /* Same as pp_format_decoder.  Works on 'diagnostic_context *'.  */
-#define diagnostic_format_decoder(DC) ((DC)->printer->format_decoder)
+#define diagnostic_format_decoder(DC) ((DC)->m_printer->format_decoder)
 
 /* Same as output_prefixing_rule.  Works on 'diagnostic_context *'.  */
-#define diagnostic_prefixing_rule(DC) ((DC)->printer->wrapping.rule)
+#define diagnostic_prefixing_rule(DC) ((DC)->m_printer->wrapping.rule)
 
 /* Raise SIGABRT on any diagnostic of severity DK_ERROR or higher.  */
 #define diagnostic_abort_on_error(DC) \
-  (DC)->abort_on_error = true
+  (DC)->m_abort_on_error = true
 
 /* This diagnostic_context is used by front-ends that directly output
    diagnostic messages without going through `error', `warning',
    and similar functions.  */
 extern diagnostic_context *global_dc;
 
-/* The total count of a KIND of diagnostics emitted so far.  */
-#define diagnostic_kind_count(DC, DK) (DC)->diagnostic_count[(int) (DK)]
-
 /* The number of errors that have been issued so far.  Ideally, these
    would take a diagnostic_context as an argument.  */
-#define errorcount diagnostic_kind_count (global_dc, DK_ERROR)
+#define errorcount global_dc->kind_count (DK_ERROR)
 /* Similarly, but for warnings.  */
-#define warningcount diagnostic_kind_count (global_dc, DK_WARNING)
+#define warningcount global_dc->kind_count (DK_WARNING)
 /* Similarly, but for warnings promoted to errors.  */
-#define werrorcount diagnostic_kind_count (global_dc, DK_WERROR)
+#define werrorcount global_dc->kind_count (DK_WERROR)
 /* Similarly, but for sorrys.  */
-#define sorrycount diagnostic_kind_count (global_dc, DK_SORRY)
+#define sorrycount global_dc->kind_count (DK_SORRY)
 
 /* Returns nonzero if warnings should be emitted.  */
 #define diagnostic_report_warnings_p(DC, LOC)				\
-  (!(DC)->dc_inhibit_warnings						\
-   && !(in_system_header_at (LOC) && !(DC)->dc_warn_system_headers))
+  (!(DC)->m_inhibit_warnings						\
+   && !(in_system_header_at (LOC) && !(DC)->m_warn_system_headers))
 
 /* Override the option index to be used for reporting a
    diagnostic.  */
@@ -281,23 +327,10 @@ diagnostic_override_option_index (diagnostic_info *info, int optidx)
 }
 
 /* Diagnostic related functions.  */
-extern void diagnostic_initialize (diagnostic_context *, int);
-extern void diagnostic_color_init (diagnostic_context *, int value = -1);
-extern void diagnostic_finish (diagnostic_context *);
-extern void diagnostic_report_current_module (diagnostic_context *, location_t);
 extern void diagnostic_show_locus (diagnostic_context *,
 				   rich_location *richloc,
 				   diagnostic_t diagnostic_kind);
 
-/* Force diagnostics controlled by OPTIDX to be kind KIND.  */
-extern diagnostic_t diagnostic_classify_diagnostic (diagnostic_context *,
-						    int /* optidx */,
-						    diagnostic_t /* kind */,
-						    location_t);
-extern void diagnostic_push_diagnostics (diagnostic_context *, location_t);
-extern void diagnostic_pop_diagnostics (diagnostic_context *, location_t);
-extern bool diagnostic_report_diagnostic (diagnostic_context *,
-					  diagnostic_info *);
 #ifdef ATTRIBUTE_GCC_DIAG
 extern void diagnostic_set_info (diagnostic_info *, const char *, va_list *,
 				 rich_location *, diagnostic_t) ATTRIBUTE_GCC_DIAG(2,0);
@@ -314,7 +347,6 @@ void default_diagnostic_start_span_fn (diagnostic_context *,
 				       expanded_location);
 void default_diagnostic_finalizer (diagnostic_context *, diagnostic_info *);
 void diagnostic_set_caret_max_width (diagnostic_context *context, int value);
-void diagnostic_action_after_output (diagnostic_context *, diagnostic_t);
 void diagnostic_check_max_errors (diagnostic_context *, bool flush = false);
 
 void diagnostic_file_cache_fini (void);
@@ -362,7 +394,7 @@ diagnostic_same_line (const diagnostic_context *context,
 		       expanded_location s1, expanded_location s2)
 {
   return s2.column && s1.line == s2.line 
-    && context->caret_max_width - CARET_LINE_MARGIN > abs (s1.column - s2.column);
+    && context->m_caret_max_width - CARET_LINE_MARGIN > abs (s1.column - s2.column);
 }
 
 extern const char *diagnostic_get_color_for_kind (diagnostic_t kind);
diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c
index 82e890f..c99d6b0 100644
--- a/gcc/fortran/cpp.c
+++ b/gcc/fortran/cpp.c
@@ -1029,13 +1029,13 @@ cb_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
 {
   diagnostic_info diagnostic;
   diagnostic_t dlevel;
-  bool save_warn_system_headers = global_dc->dc_warn_system_headers;
+  bool save_warn_system_headers = global_dc->m_warn_system_headers;
   bool ret;
 
   switch (level)
     {
     case CPP_DL_WARNING_SYSHDR:
-      global_dc->dc_warn_system_headers = 1;
+      global_dc->m_warn_system_headers = 1;
       /* Fall through.  */
     case CPP_DL_WARNING:
       dlevel = DK_WARNING;
@@ -1062,9 +1062,9 @@ cb_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
 				  richloc, dlevel);
   if (reason == CPP_W_WARNING_DIRECTIVE)
     diagnostic_override_option_index (&diagnostic, OPT_Wcpp);
-  ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
+  ret = global_dc->report_diagnostic (&diagnostic);
   if (level == CPP_DL_WARNING_SYSHDR)
-    global_dc->dc_warn_system_headers = save_warn_system_headers;
+    global_dc->m_warn_system_headers = save_warn_system_headers;
   return ret;
 }
 
diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c
index cf9e57b..17e2df0 100644
--- a/gcc/fortran/error.c
+++ b/gcc/fortran/error.c
@@ -750,14 +750,14 @@ error_printf (const char *gmsgid, ...)
 static void
 gfc_clear_pp_buffer (output_buffer *this_buffer)
 {
-  pretty_printer *pp = global_dc->printer;
+  pretty_printer *pp = global_dc->m_printer;
   output_buffer *tmp_buffer = pp->buffer;
   pp->buffer = this_buffer;
   pp_clear_output_area (pp);
   pp->buffer = tmp_buffer;
   /* We need to reset last_location, otherwise we may skip caret lines
      when we actually give a diagnostic.  */
-  global_dc->last_location = UNKNOWN_LOCATION;
+  global_dc->m_last_location = UNKNOWN_LOCATION;
 }
 
 
@@ -772,8 +772,8 @@ gfc_warning (int opt, const char *gmsgid, va_list ap)
 
   diagnostic_info diagnostic;
   rich_location rich_loc (line_table, UNKNOWN_LOCATION);
-  bool fatal_errors = global_dc->fatal_errors;
-  pretty_printer *pp = global_dc->printer;
+  bool fatal_errors = global_dc->m_fatal_errors;
+  pretty_printer *pp = global_dc->m_printer;
   output_buffer *tmp_buffer = pp->buffer;
 
   gfc_clear_pp_buffer (pp_warning_buffer);
@@ -781,7 +781,7 @@ gfc_warning (int opt, const char *gmsgid, va_list ap)
   if (buffered_p)
     {
       pp->buffer = pp_warning_buffer;
-      global_dc->fatal_errors = false;
+      global_dc->m_fatal_errors = false;
       /* To prevent -fmax-errors= triggering.  */
       --werrorcount;
     }
@@ -789,12 +789,12 @@ gfc_warning (int opt, const char *gmsgid, va_list ap)
   diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc,
 		       DK_WARNING);
   diagnostic.option_index = opt;
-  bool ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
+  bool ret = global_dc->report_diagnostic (&diagnostic);
 
   if (buffered_p)
     {
       pp->buffer = tmp_buffer;
-      global_dc->fatal_errors = fatal_errors;
+      global_dc->m_fatal_errors = fatal_errors;
 
       warningcount_buffered = 0;
       werrorcount_buffered = 0;
@@ -983,7 +983,7 @@ gfc_diagnostic_build_kind_prefix (diagnostic_context *context,
   gcc_assert (diagnostic->kind < DK_LAST_DIAGNOSTIC_KIND);
   const char *text = _(diagnostic_kind_text[diagnostic->kind]);
   const char *text_cs = "", *text_ce = "";
-  pretty_printer *pp = context->printer;
+  pretty_printer *pp = context->m_printer;
 
   if (diagnostic_kind_color[diagnostic->kind])
     {
@@ -1000,14 +1000,14 @@ static char *
 gfc_diagnostic_build_locus_prefix (diagnostic_context *context,
 				   expanded_location s)
 {
-  pretty_printer *pp = context->printer;
+  pretty_printer *pp = context->m_printer;
   const char *locus_cs = colorize_start (pp_show_color (pp), "locus");
   const char *locus_ce = colorize_stop (pp_show_color (pp));
   return (s.file == NULL
 	  ? build_message_string ("%s%s:%s", locus_cs, progname, locus_ce )
 	  : !strcmp (s.file, N_("<built-in>"))
 	  ? build_message_string ("%s%s:%s", locus_cs, s.file, locus_ce)
-	  : context->show_column
+	  : context->m_show_column
 	  ? build_message_string ("%s%s:%d:%d:%s", locus_cs, s.file, s.line,
 				  s.column, locus_ce)
 	  : build_message_string ("%s%s:%d:%s", locus_cs, s.file, s.line, locus_ce));
@@ -1019,7 +1019,7 @@ static char *
 gfc_diagnostic_build_locus_prefix (diagnostic_context *context,
 				   expanded_location s, expanded_location s2)
 {
-  pretty_printer *pp = context->printer;
+  pretty_printer *pp = context->m_printer;
   const char *locus_cs = colorize_start (pp_show_color (pp), "locus");
   const char *locus_ce = colorize_stop (pp_show_color (pp));
 
@@ -1027,7 +1027,7 @@ gfc_diagnostic_build_locus_prefix (diagnostic_context *context,
 	  ? build_message_string ("%s%s:%s", locus_cs, progname, locus_ce )
 	  : !strcmp (s.file, N_("<built-in>"))
 	  ? build_message_string ("%s%s:%s", locus_cs, s.file, locus_ce)
-	  : context->show_column
+	  : context->m_show_column
 	  ? build_message_string ("%s%s:%d:%d-%d:%s", locus_cs, s.file, s.line,
 				  MIN (s.column, s2.column),
 				  MAX (s.column, s2.column), locus_ce)
@@ -1073,11 +1073,11 @@ gfc_diagnostic_starter (diagnostic_context *context,
     ? gfc_diagnostic_build_locus_prefix (context, s1)
     : gfc_diagnostic_build_locus_prefix (context, s1, s2);
 
-  if (!context->show_caret
+  if (!context->m_show_caret
       || diagnostic_location (diagnostic, 0) <= BUILTINS_LOCATION
-      || diagnostic_location (diagnostic, 0) == context->last_location)
+      || diagnostic_location (diagnostic, 0) == context->m_last_location)
     {
-      pp_set_prefix (context->printer,
+      pp_set_prefix (context->m_printer,
 		     concat (locus_prefix, " ", kind_prefix, NULL));
       free (locus_prefix);
 
@@ -1091,24 +1091,24 @@ gfc_diagnostic_starter (diagnostic_context *context,
 	  [locus]:[prefix]: (1)
 
 	 and we flush with a new line before setting the new prefix.  */
-      pp_string (context->printer, "(1)");
-      pp_newline (context->printer);
+      pp_string (context->m_printer, "(1)");
+      pp_newline (context->m_printer);
       locus_prefix = gfc_diagnostic_build_locus_prefix (context, s2);
-      pp_set_prefix (context->printer,
+      pp_set_prefix (context->m_printer,
 		     concat (locus_prefix, " ", kind_prefix, NULL));
       free (kind_prefix);
       free (locus_prefix);
     }
   else
     {
-      pp_verbatim (context->printer, "%s", locus_prefix);
+      pp_verbatim (context->m_printer, "%s", locus_prefix);
       free (locus_prefix);
       /* Fortran uses an empty line between locus and caret line.  */
-      pp_newline (context->printer);
+      pp_newline (context->m_printer);
       diagnostic_show_locus (context, diagnostic->richloc, diagnostic->kind);
       /* If the caret line was shown, the prefix does not contain the
 	 locus.  */
-      pp_set_prefix (context->printer, kind_prefix);
+      pp_set_prefix (context->m_printer, kind_prefix);
     }
 }
 
@@ -1118,11 +1118,11 @@ gfc_diagnostic_start_span (diagnostic_context *context,
 {
   char *locus_prefix;
   locus_prefix = gfc_diagnostic_build_locus_prefix (context, exploc);
-  pp_verbatim (context->printer, "%s", locus_prefix);
+  pp_verbatim (context->m_printer, "%s", locus_prefix);
   free (locus_prefix);
-  pp_newline (context->printer);
+  pp_newline (context->m_printer);
   /* Fortran uses an empty line between locus and caret line.  */
-  pp_newline (context->printer);
+  pp_newline (context->m_printer);
 }
 
 
@@ -1130,8 +1130,8 @@ static void
 gfc_diagnostic_finalizer (diagnostic_context *context,
 			  diagnostic_info *diagnostic ATTRIBUTE_UNUSED)
 {
-  pp_destroy_prefix (context->printer);
-  pp_newline_and_flush (context->printer);
+  pp_destroy_prefix (context->m_printer);
+  pp_newline_and_flush (context->m_printer);
 }
 
 /* Immediate warning (i.e. do not buffer the warning) with an explicit
@@ -1148,7 +1148,7 @@ gfc_warning_now_at (location_t loc, int opt, const char *gmsgid, ...)
   va_start (argp, gmsgid);
   diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc, DK_WARNING);
   diagnostic.option_index = opt;
-  ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
+  ret = global_dc->report_diagnostic (&diagnostic);
   va_end (argp);
   return ret;
 }
@@ -1167,7 +1167,7 @@ gfc_warning_now (int opt, const char *gmsgid, ...)
   diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc,
 		       DK_WARNING);
   diagnostic.option_index = opt;
-  ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
+  ret = global_dc->report_diagnostic (&diagnostic);
   va_end (argp);
   return ret;
 }
@@ -1186,7 +1186,7 @@ gfc_warning_internal (int opt, const char *gmsgid, ...)
   diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc,
 		       DK_WARNING);
   diagnostic.option_index = opt;
-  ret = diagnostic_report_diagnostic (global_dc, &diagnostic);
+  ret = global_dc->report_diagnostic (&diagnostic);
   va_end (argp);
   return ret;
 }
@@ -1204,7 +1204,7 @@ gfc_error_now (const char *gmsgid, ...)
 
   va_start (argp, gmsgid);
   diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc, DK_ERROR);
-  diagnostic_report_diagnostic (global_dc, &diagnostic);
+  global_dc->report_diagnostic (&diagnostic);
   va_end (argp);
 }
 
@@ -1220,7 +1220,7 @@ gfc_fatal_error (const char *gmsgid, ...)
 
   va_start (argp, gmsgid);
   diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc, DK_FATAL);
-  diagnostic_report_diagnostic (global_dc, &diagnostic);
+  global_dc->report_diagnostic (&diagnostic);
   va_end (argp);
 
   gcc_unreachable ();
@@ -1245,7 +1245,7 @@ gfc_warning_check (void)
 {
   if (! gfc_output_buffer_empty_p (pp_warning_buffer))
     {
-      pretty_printer *pp = global_dc->printer;
+      pretty_printer *pp = global_dc->m_printer;
       output_buffer *tmp_buffer = pp->buffer;
       pp->buffer = pp_warning_buffer;
       pp_really_flush (pp);
@@ -1253,8 +1253,7 @@ gfc_warning_check (void)
       werrorcount += werrorcount_buffered;
       gcc_assert (warningcount_buffered + werrorcount_buffered == 1);
       pp->buffer = tmp_buffer;
-      diagnostic_action_after_output (global_dc,
-				      warningcount_buffered
+      global_dc->action_after_output (warningcount_buffered
 				      ? DK_WARNING : DK_ERROR);
       diagnostic_check_max_errors (global_dc, true);
     }
@@ -1285,8 +1284,8 @@ gfc_error_opt (int opt, const char *gmsgid, va_list ap)
 
   diagnostic_info diagnostic;
   rich_location richloc (line_table, UNKNOWN_LOCATION);
-  bool fatal_errors = global_dc->fatal_errors;
-  pretty_printer *pp = global_dc->printer;
+  bool fatal_errors = global_dc->m_fatal_errors;
+  pretty_printer *pp = global_dc->m_printer;
   output_buffer *tmp_buffer = pp->buffer;
 
   gfc_clear_pp_buffer (pp_error_buffer);
@@ -1295,23 +1294,23 @@ gfc_error_opt (int opt, const char *gmsgid, va_list ap)
     {
       /* To prevent -dH from triggering an abort on a buffered error,
 	 save abort_on_error and restore it below.  */
-      saved_abort_on_error = global_dc->abort_on_error;
-      global_dc->abort_on_error = false;
+      saved_abort_on_error = global_dc->m_abort_on_error;
+      global_dc->m_abort_on_error = false;
       pp->buffer = pp_error_buffer;
-      global_dc->fatal_errors = false;
+      global_dc->m_fatal_errors = false;
       /* To prevent -fmax-errors= triggering, we decrease it before
 	 report_diagnostic increases it.  */
       --errorcount;
     }
 
   diagnostic_set_info (&diagnostic, gmsgid, &argp, &richloc, DK_ERROR);
-  diagnostic_report_diagnostic (global_dc, &diagnostic);
+  global_dc->report_diagnostic (&diagnostic);
 
   if (buffered_p)
     {
       pp->buffer = tmp_buffer;
-      global_dc->fatal_errors = fatal_errors;
-      global_dc->abort_on_error = saved_abort_on_error;
+      global_dc->m_fatal_errors = fatal_errors;
+      global_dc->m_abort_on_error = saved_abort_on_error;
 
     }
 
@@ -1355,7 +1354,7 @@ gfc_internal_error (const char *gmsgid, ...)
 
   va_start (argp, gmsgid);
   diagnostic_set_info (&diagnostic, gmsgid, &argp, &rich_loc, DK_ICE);
-  diagnostic_report_diagnostic (global_dc, &diagnostic);
+  global_dc->report_diagnostic (&diagnostic);
   va_end (argp);
 
   gcc_unreachable ();
@@ -1393,14 +1392,14 @@ gfc_error_check (void)
       || ! gfc_output_buffer_empty_p (pp_error_buffer))
     {
       error_buffer.flag = false;
-      pretty_printer *pp = global_dc->printer;
+      pretty_printer *pp = global_dc->m_printer;
       output_buffer *tmp_buffer = pp->buffer;
       pp->buffer = pp_error_buffer;
       pp_really_flush (pp);
       ++errorcount;
       gcc_assert (gfc_output_buffer_empty_p (pp_error_buffer));
       pp->buffer = tmp_buffer;
-      diagnostic_action_after_output (global_dc, DK_ERROR);
+      global_dc->action_after_output (DK_ERROR);
       diagnostic_check_max_errors (global_dc, true);
       return true;
     }
@@ -1485,11 +1484,11 @@ void
 gfc_diagnostics_init (void)
 {
   diagnostic_starter (global_dc) = gfc_diagnostic_starter;
-  global_dc->start_span = gfc_diagnostic_start_span;
+  global_dc->m_start_span = gfc_diagnostic_start_span;
   diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer;
   diagnostic_format_decoder (global_dc) = gfc_format_decoder;
-  global_dc->caret_chars[0] = '1';
-  global_dc->caret_chars[1] = '2';
+  global_dc->set_caret_char (0, '1');
+  global_dc->set_caret_char (1, '2');
   pp_warning_buffer = new (XNEW (output_buffer)) output_buffer ();
   pp_warning_buffer->flush_p = false;
   /* pp_error_buffer is statically allocated.  This simplifies memory
@@ -1506,6 +1505,6 @@ gfc_diagnostics_finish (void)
      defaults.  */
   diagnostic_starter (global_dc) = gfc_diagnostic_starter;
   diagnostic_finalizer (global_dc) = gfc_diagnostic_finalizer;
-  global_dc->caret_chars[0] = '^';
-  global_dc->caret_chars[1] = '^';
+  global_dc->set_caret_char (0, '^');
+  global_dc->set_caret_char (1, '^');
 }
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index 1405f1c..82073b1 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -334,9 +334,9 @@ gfc_post_options (const char **pfilename)
       /* Enable -Werror=line-truncation when -Werror and -Wno-error have
 	 not been set.  */
       if (warn_line_truncation && !global_options_set.x_warnings_are_errors
-	  && (global_dc->classify_diagnostic[OPT_Wline_truncation] ==
+	  && (global_dc->m_classify_diagnostic[OPT_Wline_truncation] ==
 	      DK_UNSPECIFIED))
-	diagnostic_classify_diagnostic (global_dc, OPT_Wline_truncation,
+	global_dc->classify_diagnostic (OPT_Wline_truncation,
 					DK_ERROR, UNKNOWN_LOCATION);
     }
   else
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 6db0135..0a76dd3 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -3914,7 +3914,7 @@ driver_handle_option (struct gcc_options *opts,
       return true;
 
     case OPT_fdiagnostics_color_:
-      diagnostic_color_init (dc, value);
+      dc->color_init (value);
       break;
 
     case OPT_Wa_:
@@ -7369,8 +7369,8 @@ driver::global_initializations ()
 
   gcc_init_libintl ();
 
-  diagnostic_initialize (global_dc, 0);
-  diagnostic_color_init (global_dc);
+  global_dc->initialize (0);
+  global_dc->color_init ();
 
 #ifdef GCC_DRIVER_HOST_INITIALIZATION
   /* Perform host dependent initialization when needed.  */
@@ -10045,7 +10045,7 @@ driver::finalize ()
 {
   env.restore ();
   params_c_finalize ();
-  diagnostic_finish (global_dc);
+  global_dc->finish ();
 
   is_cpp_driver = 0;
   at_file_supplied = 0;
diff --git a/gcc/gcov-dump.c b/gcc/gcov-dump.c
index ba432db..c006444 100644
--- a/gcc/gcov-dump.c
+++ b/gcc/gcov-dump.c
@@ -99,7 +99,7 @@ main (int argc ATTRIBUTE_UNUSED, char **argv)
 
   gcc_init_libintl ();
 
-  diagnostic_initialize (global_dc, 0);
+  global_dc->initialize (0);
 
   while ((opt = getopt_long (argc, argv, "hlpvw", options, NULL)) != -1)
     {
diff --git a/gcc/gcov-tool.c b/gcc/gcov-tool.c
index 15fd710..40d465e 100644
--- a/gcc/gcov-tool.c
+++ b/gcc/gcov-tool.c
@@ -590,7 +590,7 @@ main (int argc, char **argv)
 
   gcc_init_libintl ();
 
-  diagnostic_initialize (global_dc, 0);
+  global_dc->initialize (0);
 
   /* Handle response files.  */
   expandargv (&argc, &argv);
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 37f431c..84efc90 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -768,7 +768,7 @@ main (int argc, char **argv)
 
   gcc_init_libintl ();
 
-  diagnostic_initialize (global_dc, 0);
+  global_dc->initialize (0);
 
   /* Handle response files.  */
   expandargv (&argc, &argv);
diff --git a/gcc/input.c b/gcc/input.c
index a4fa0dd..1e30aa4 100644
--- a/gcc/input.c
+++ b/gcc/input.c
@@ -256,8 +256,8 @@ static void
 diagnostic_file_cache_init (void)
 {
   gcc_assert (global_dc);
-  if (global_dc->src_manager == NULL)
-    global_dc->src_manager = new source_manager ();
+  if (global_dc->m_src_manager == NULL)
+    global_dc->m_src_manager = new source_manager ();
 }
 
 /* Free the resources used by the set of cache used for files accessed
@@ -266,10 +266,10 @@ diagnostic_file_cache_init (void)
 void
 diagnostic_file_cache_fini (void)
 {
-  if (global_dc->src_manager)
+  if (global_dc->m_src_manager)
     {
-      delete global_dc->src_manager;
-      global_dc->src_manager = NULL;
+      delete global_dc->m_src_manager;
+      global_dc->m_src_manager = NULL;
     }
 }
 
@@ -328,10 +328,10 @@ diagnostics_file_cache_forcibly_evict_file (const char *file_path)
 {
   gcc_assert (file_path);
 
-  if (!global_dc->src_manager)
+  if (!global_dc->m_src_manager)
     return;
 
-  global_dc->src_manager->forcibly_evict_file (file_path);
+  global_dc->m_src_manager->forcibly_evict_file (file_path);
 }
 
 void
@@ -819,7 +819,7 @@ location_get_source_line (const char *file_path, int line)
 
   diagnostic_file_cache_init ();
 
-  fcache *c = global_dc->src_manager->lookup_or_add_file (file_path);
+  fcache *c = global_dc->m_src_manager->lookup_or_add_file (file_path);
   if (c == NULL)
     return char_span (NULL, 0);
 
@@ -839,7 +839,7 @@ location_missing_trailing_newline (const char *file_path)
 {
   diagnostic_file_cache_init ();
 
-  fcache *c = global_dc->src_manager->lookup_or_add_file (file_path);
+  fcache *c = global_dc->m_src_manager->lookup_or_add_file (file_path);
   if (c == NULL)
     return false;
 
diff --git a/gcc/jit/dummy-frontend.c b/gcc/jit/dummy-frontend.c
index 4c7f960..3d51ec5 100644
--- a/gcc/jit/dummy-frontend.c
+++ b/gcc/jit/dummy-frontend.c
@@ -136,8 +136,8 @@ jit_langhook_init (void)
     }
 
   gcc_assert (global_dc);
-  global_dc->begin_diagnostic = jit_begin_diagnostic;
-  global_dc->end_diagnostic = jit_end_diagnostic;
+  global_dc->m_begin_diagnostic = jit_begin_diagnostic;
+  global_dc->m_end_diagnostic = jit_end_diagnostic;
 
   build_common_tree_nodes (false);
 
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index 258ebe8..5b7e1f5 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -2897,7 +2897,7 @@ add_diagnostic (struct diagnostic_context *diag_context,
 {
   /* At this point the text has been formatted into the pretty-printer's
      output buffer.  */
-  pretty_printer *pp = diag_context->printer;
+  pretty_printer *pp = diag_context->m_printer;
   const char *text = pp_formatted_text (pp);
 
   /* Get location information (if any) from the diagnostic.
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index 3cd7901..b4f26a5 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -368,15 +368,15 @@ lhd_print_error_function (diagnostic_context *context, const char *file,
 {
   if (diagnostic_last_function_changed (context, diagnostic))
     {
-      const char *old_prefix = context->printer->prefix;
+      const char *old_prefix = context->m_printer->prefix;
       tree abstract_origin = diagnostic_abstract_origin (diagnostic);
       char *new_prefix = (file && abstract_origin == NULL)
 			 ? file_name_as_prefix (context, file) : NULL;
 
-      pp_set_prefix (context->printer, new_prefix);
+      pp_set_prefix (context->m_printer, new_prefix);
 
       if (current_function_decl == NULL)
-	pp_printf (context->printer, _("At top level:"));
+	pp_printf (context->m_printer, _("At top level:"));
       else
 	{
 	  tree fndecl, ao;
@@ -396,11 +396,11 @@ lhd_print_error_function (diagnostic_context *context, const char *file,
 
 	  if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
 	    pp_printf
-	      (context->printer, _("In member function %qs"),
+	      (context->m_printer, _("In member function %qs"),
 	       identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
 	  else
 	    pp_printf
-	      (context->printer, _("In function %qs"),
+	      (context->m_printer, _("In function %qs"),
 	       identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
 
 	  while (abstract_origin)
@@ -445,33 +445,33 @@ lhd_print_error_function (diagnostic_context *context, const char *file,
 	      if (fndecl)
 		{
 		  expanded_location s = expand_location (*locus);
-		  pp_comma (context->printer);
-		  pp_newline (context->printer);
+		  pp_comma (context->m_printer);
+		  pp_newline (context->m_printer);
 		  if (s.file != NULL)
 		    {
-		      if (context->show_column)
-			pp_printf (context->printer,
+		      if (context->m_show_column)
+			pp_printf (context->m_printer,
 				   _("    inlined from %qs at %r%s:%d:%d%R"),
 				   identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
 				   "locus", s.file, s.line, s.column);
 		      else
-			pp_printf (context->printer,
+			pp_printf (context->m_printer,
 				   _("    inlined from %qs at %r%s:%d%R"),
 				   identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)),
 				   "locus", s.file, s.line);
 
 		    }
 		  else
-		    pp_printf (context->printer, _("    inlined from %qs"),
+		    pp_printf (context->m_printer, _("    inlined from %qs"),
 			       identifier_to_locale (lang_hooks.decl_printable_name (fndecl, 2)));
 		}
 	    }
-	  pp_colon (context->printer);
+	  pp_colon (context->m_printer);
 	}
 
       diagnostic_set_last_function (context, diagnostic);
-      pp_newline_and_flush (context->printer);
-      context->printer->prefix = old_prefix;
+      pp_newline_and_flush (context->m_printer);
+      context->m_printer->prefix = old_prefix;
       free ((char*) new_prefix);
     }
 }
diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index f7f6f6b..b80e96d 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -1660,7 +1660,7 @@ main (int argc, char *argv[])
 
   gcc_init_libintl ();
 
-  diagnostic_initialize (global_dc, 0);
+  global_dc->initialize (0);
 
   if (atexit (lto_wrapper_cleanup) != 0)
     fatal_error (input_location, "atexit failed");
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index c6b9418..1c53be3 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -1275,7 +1275,7 @@ set_option (struct gcc_options *opts, struct gcc_options *opts_set,
     return;
 
   if ((diagnostic_t) kind != DK_UNSPECIFIED && dc != NULL)
-    diagnostic_classify_diagnostic (dc, opt_index, (diagnostic_t) kind, loc);
+    dc->classify_diagnostic (opt_index, (diagnostic_t) kind, loc);
 
   if (opts_set != NULL)
     set_flag_var = option_flag_var (opt_index, opts_set);
@@ -1487,7 +1487,7 @@ control_warning_option (unsigned int opt_index, int kind, const char *arg,
   if (opt_index == OPT_SPECIAL_ignore)
     return;
   if (dc)
-    diagnostic_classify_diagnostic (dc, opt_index, (diagnostic_t) kind, loc);
+    dc->classify_diagnostic (opt_index, (diagnostic_t) kind, loc);
   if (imply)
     {
       const struct cl_option *option = &cl_options[opt_index];
diff --git a/gcc/opts-global.c b/gcc/opts-global.c
index f33c9da..25df8f9 100644
--- a/gcc/opts-global.c
+++ b/gcc/opts-global.c
@@ -250,7 +250,7 @@ init_options_once (void)
      it if desired (none do it so far).  However, the way the FEs
      construct their pretty-printers means that all previous settings
      are overriden.  */
-  diagnostic_color_init (global_dc);
+  global_dc->color_init ();
 }
 
 /* Decode command-line options to an array, like
diff --git a/gcc/opts.c b/gcc/opts.c
index f2795f9..b98f230 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -2025,7 +2025,7 @@ common_handle_option (struct gcc_options *opts,
       break;
 
     case OPT_Werror:
-      dc->warning_as_error_requested = value;
+      dc->m_warning_as_error_requested = value;
       break;
 
     case OPT_Werror_:
@@ -2042,7 +2042,7 @@ common_handle_option (struct gcc_options *opts,
       break;
 
     case OPT_Wfatal_errors:
-      dc->fatal_errors = value;
+      dc->m_fatal_errors = value;
       break;
 
     case OPT_Wframe_larger_than_:
@@ -2066,7 +2066,7 @@ common_handle_option (struct gcc_options *opts,
       break;
 
     case OPT_Wsystem_headers:
-      dc->dc_warn_system_headers = value;
+      dc->m_warn_system_headers = value;
       break;
 
     case OPT_aux_info:
@@ -2112,19 +2112,19 @@ common_handle_option (struct gcc_options *opts,
       break;
  
     case OPT_fdiagnostics_show_caret:
-      dc->show_caret = value;
+      dc->m_show_caret = value;
       break;
 
     case OPT_fdiagnostics_color_:
-      diagnostic_color_init (dc, value);
+      dc->color_init (value);
       break;
 
     case OPT_fdiagnostics_parseable_fixits:
-      dc->parseable_fixits_p = value;
+      dc->m_parseable_fixits_p = value;
       break;
 
     case OPT_fdiagnostics_show_option:
-      dc->show_option_requested = value;
+      dc->m_show_option_requested = value;
       break;
 
     case OPT_fdump_:
@@ -2161,7 +2161,7 @@ common_handle_option (struct gcc_options *opts,
       break;
 
     case OPT_fmessage_length_:
-      pp_set_line_maximum_length (dc->printer, value);
+      pp_set_line_maximum_length (dc->m_printer, value);
       diagnostic_set_caret_max_width (dc, value);
       break;
 
@@ -2307,7 +2307,7 @@ common_handle_option (struct gcc_options *opts,
 	 -ftree-slp-vectorize.  Nothing more to do here.  */
       break;
     case OPT_fshow_column:
-      dc->show_column = value;
+      dc->m_show_column = value;
       break;
 
     case OPT_frandom_seed:
@@ -2431,7 +2431,7 @@ common_handle_option (struct gcc_options *opts,
       break;
 
     case OPT_pedantic_errors:
-      dc->pedantic_errors = 1;
+      dc->m_pedantic_errors = 1;
       control_warning_option (OPT_Wpedantic, DK_ERROR, NULL, value,
 			      loc, lang_mask,
 			      handlers, opts, opts_set,
@@ -2443,11 +2443,11 @@ common_handle_option (struct gcc_options *opts,
       break;
 
     case OPT_w:
-      dc->dc_inhibit_warnings = true;
+      dc->m_inhibit_warnings = true;
       break;
 
     case OPT_fmax_errors_:
-      dc->max_errors = value;
+      dc->m_max_errors = value;
       break;
 
     case OPT_fuse_ld_bfd:
@@ -2811,7 +2811,7 @@ option_name (diagnostic_context *context, int option_index,
   /* A warning without option classified as an error.  */
   else if ((orig_diag_kind == DK_WARNING || orig_diag_kind == DK_PEDWARN
 	    || diag_kind == DK_WARNING)
-	   && context->warning_as_error_requested)
+	   && context->m_warning_as_error_requested)
     return xstrdup (cl_options[OPT_Werror].opt_text);
   else
     return NULL;
diff --git a/gcc/rtl-error.c b/gcc/rtl-error.c
index fdc474d..14d978c 100644
--- a/gcc/rtl-error.c
+++ b/gcc/rtl-error.c
@@ -71,7 +71,7 @@ diagnostic_for_asm (const rtx_insn *insn, const char *msg, va_list *args_ptr,
 
   diagnostic_set_info (&diagnostic, msg, args_ptr,
 		       &richloc, kind);
-  diagnostic_report_diagnostic (global_dc, &diagnostic);
+  global_dc->report_diagnostic (&diagnostic);
 }
 
 void
diff --git a/gcc/selftest-diagnostic.c b/gcc/selftest-diagnostic.c
index 837488b..a3c7bef 100644
--- a/gcc/selftest-diagnostic.c
+++ b/gcc/selftest-diagnostic.c
@@ -35,15 +35,15 @@ namespace selftest {
 
 test_diagnostic_context::test_diagnostic_context ()
 {
-  diagnostic_initialize (this, 0);
-  show_caret = true;
-  show_column = true;
-  start_span = start_span_cb;
+  initialize (0);
+  m_show_caret = true;
+  m_show_column = true;
+  m_start_span = start_span_cb;
 }
 
 test_diagnostic_context::~test_diagnostic_context ()
 {
-  diagnostic_finish (this);
+  finish ();
 }
 
 /* Implementation of diagnostic_start_span_fn, hiding the
diff --git a/gcc/substring-locations.c b/gcc/substring-locations.c
index cf3ec4f..a8e7f13 100644
--- a/gcc/substring-locations.c
+++ b/gcc/substring-locations.c
@@ -145,7 +145,7 @@ format_warning_va (const substring_loc &fmt_loc,
   diagnostic_info diagnostic;
   diagnostic_set_info (&diagnostic, gmsgid, ap, &richloc, DK_WARNING);
   diagnostic.option_index = opt;
-  bool warned = diagnostic_report_diagnostic (global_dc, &diagnostic);
+  bool warned = global_dc->report_diagnostic (&diagnostic);
 
   if (!err && fmt_substring_loc && !substring_within_range)
     /* Case 2.  */
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 35d7968..00fa1a8 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -233,7 +233,7 @@ announce_function (tree decl)
 	fprintf (stderr, " %s",
 		 identifier_to_locale (lang_hooks.decl_printable_name (decl, 2)));
       fflush (stderr);
-      pp_needs_newline (global_dc->printer) = true;
+      pp_needs_newline (global_dc->m_printer) = true;
       diagnostic_set_last_function (global_dc, (diagnostic_info *) NULL);
     }
 }
@@ -1073,7 +1073,7 @@ internal_error_reentered (diagnostic_context *, const char *, va_list *)
 static void
 internal_error_function (diagnostic_context *, const char *, va_list *)
 {
-  global_dc->internal_error = internal_error_reentered;
+  global_dc->m_internal_error = internal_error_reentered;
   warn_if_plugins ();
   emergency_dump_function ();
 }
@@ -1105,21 +1105,21 @@ general_init (const char *argv0, bool init_signals)
 
   /* Initialize the diagnostics reporting machinery, so option parsing
      can give warnings and errors.  */
-  diagnostic_initialize (global_dc, N_OPTS);
+  global_dc->initialize (N_OPTS);
   /* Set a default printer.  Language specific initializations will
      override it later.  */
   tree_diagnostics_defaults (global_dc);
 
-  global_dc->show_caret
+  global_dc->m_show_caret
     = global_options_init.x_flag_diagnostics_show_caret;
-  global_dc->show_option_requested
+  global_dc->m_show_option_requested
     = global_options_init.x_flag_diagnostics_show_option;
-  global_dc->show_column
+  global_dc->m_show_column
     = global_options_init.x_flag_show_column;
-  global_dc->internal_error = internal_error_function;
-  global_dc->option_enabled = option_enabled;
-  global_dc->option_state = &global_options;
-  global_dc->option_name = option_name;
+  global_dc->m_internal_error = internal_error_function;
+  global_dc->m_option_enabled = option_enabled;
+  global_dc->m_option_state = &global_options;
+  global_dc->m_option_name = option_name;
 
   if (init_signals)
     {
@@ -1248,11 +1248,11 @@ process_options (void)
   input_location = saved_location;
 
   if (flag_diagnostics_generate_patch)
-      global_dc->edit_context_ptr = new edit_context ();
+      global_dc->m_edit_context_ptr = new edit_context ();
 
   /* Avoid any informative notes in the second run of -fcompare-debug.  */
   if (flag_compare_debug) 
-    diagnostic_inhibit_notes (global_dc);
+    global_dc->inhibit_notes ();
 
   if (flag_section_anchors && !target_supports_section_anchors_p ())
     {
@@ -1698,9 +1698,9 @@ process_options (void)
      have not been set.  */
   if (!global_options_set.x_warnings_are_errors
       && warn_coverage_mismatch
-      && (global_dc->classify_diagnostic[OPT_Wcoverage_mismatch] ==
+      && (global_dc->m_classify_diagnostic[OPT_Wcoverage_mismatch] ==
           DK_UNSPECIFIED))
-    diagnostic_classify_diagnostic (global_dc, OPT_Wcoverage_mismatch,
+    global_dc->classify_diagnostic (OPT_Wcoverage_mismatch,
                                     DK_ERROR, UNKNOWN_LOCATION);
 
   /* Save the current optimization options.  */
@@ -2228,15 +2228,15 @@ toplev::main (int argc, char **argv)
 
   if (flag_diagnostics_generate_patch)
     {
-      gcc_assert (global_dc->edit_context_ptr);
+      gcc_assert (global_dc->m_edit_context_ptr);
 
       pretty_printer pp;
-      pp_show_color (&pp) = pp_show_color (global_dc->printer);
-      global_dc->edit_context_ptr->print_diff (&pp, true);
+      pp_show_color (&pp) = pp_show_color (global_dc->m_printer);
+      global_dc->m_edit_context_ptr->print_diff (&pp, true);
       pp_flush (&pp);
     }
 
-  diagnostic_finish (global_dc);
+  global_dc->finish ();
 
   finalize_plugins ();
 
diff --git a/gcc/tree-diagnostic.c b/gcc/tree-diagnostic.c
index 9814d02..9080236 100644
--- a/gcc/tree-diagnostic.c
+++ b/gcc/tree-diagnostic.c
@@ -36,7 +36,7 @@ void
 diagnostic_report_current_function (diagnostic_context *context,
 				    diagnostic_info *diagnostic)
 {
-  diagnostic_report_current_module (context, diagnostic_location (diagnostic));
+  context->report_current_module (diagnostic_location (diagnostic));
   lang_hooks.print_error_function (context, LOCATION_FILE (input_location),
 				   diagnostic);
 }
@@ -46,8 +46,8 @@ default_tree_diagnostic_starter (diagnostic_context *context,
 				 diagnostic_info *diagnostic)
 {
   diagnostic_report_current_function (context, diagnostic);
-  pp_set_prefix (context->printer, diagnostic_build_prefix (context,
-							    diagnostic));
+  pp_set_prefix (context->m_printer, diagnostic_build_prefix (context,
+							      diagnostic));
 }
 
 /* This is a pair made of a location and the line map it originated
-- 
1.8.5.3

