On Mon, 2025-06-30 at 15:24 -0400, David Malcolm wrote:
> The "json" output format for diagnostics was deprecated in GCC 15,
> with
> advice to users seeking machine-readable diagnostics from GCC to use
> SARIF instead.
> 
> This patch eliminates it from GCC 16, simplifying the diagnostics
> subsystem somewhat.
> 
> Note that the Ada frontend seems to have its own implementation of
> this
> in errout.adb (Output_JSON_Message), and documented in
> gnat_ugn.texi.  This patch does not touch Ada.
> 
> Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
> Pushed to trunk as r16-1830-g51ce373481e848.

FWIW my testing included the ada frontend.  There don't seem to be any
test coverage for gnat's implementations of json and sarif output, so
if I did break something there, I'm sorry.

Dave

> 
> gcc/ChangeLog:
>       * Makefile.in (OBJS-libcommon): Drop diagnostic-format-
> json.o.
>       * common.opt (fdiagnostics-format=): Drop
>       "json|json-stderr|json-file".
>       (diagnostics_output_format): Drop values "json", "json-
> stderr",
>       and "json-file".
>       * diagnostic-format-json.cc: Delete file.
>       * diagnostic-format.h
>       (diagnostic_output_format_init_json_stderr): Delete.
>       (diagnostic_output_format_init_json_file): Delete.
>       * diagnostic.cc (diagnostic_output_format_init): Delete
> cases for
>       DIAGNOSTICS_OUTPUT_FORMAT_JSON_STDERR and
>       DIAGNOSTICS_OUTPUT_FORMAT_JSON_FILE.
>       * diagnostic.h (DIAGNOSTICS_OUTPUT_FORMAT_JSON_STDERR):
> Delete.
>       (DIAGNOSTICS_OUTPUT_FORMAT_JSON_FILE): Delete.
>       * doc/invoke.texi: Remove references to json output format.
>       * doc/ux.texi: Likewise.
>       * selftest-run-tests.cc (selftest::run_tests): Drop call to
>       deleted selftest::diagnostic_format_json_cc_tests.
>       * selftest.h (selftest::diagnostic_format_json_cc_tests):
> Delete.
> 
> gcc/testsuite/ChangeLog:
>       * c-c++-common/analyzer/out-of-bounds-diagram-1-json.c:
> Deleted test.
>       * c-c++-common/diagnostic-format-json-1.c: Deleted test.
>       * c-c++-common/diagnostic-format-json-2.c: Deleted test.
>       * c-c++-common/diagnostic-format-json-3.c: Deleted test.
>       * c-c++-common/diagnostic-format-json-4.c: Deleted test.
>       * c-c++-common/diagnostic-format-json-5.c: Deleted test.
>       * c-c++-common/diagnostic-format-json-file-1.c: Deleted
> test.
>       * c-c++-common/diagnostic-format-json-stderr-1.c: Deleted
> test.
>       * c-c++-common/pr106133.c: Deleted test.
>       * g++.dg/pr90462.C: Deleted test.
>       * gcc.dg/plugin/diagnostic-test-paths-3.c: Deleted test.
>       * gcc.dg/plugin/plugin.exp (plugin_test_list): Remove
> deleted
>       test.
>       * gfortran.dg/diagnostic-format-json-1.F90: Deleted test.
>       * gfortran.dg/diagnostic-format-json-2.F90: Deleted test.
>       * gfortran.dg/diagnostic-format-json-3.F90: Deleted test.
>       * gfortran.dg/diagnostic-format-json-pr105916.F90: Deleted
> test.
> 
> Signed-off-by: David Malcolm <dmalc...@redhat.com>
> ---
>  gcc/Makefile.in                               |   1 -
>  gcc/common.opt                                |  11 +-
>  gcc/diagnostic-format-json.cc                 | 605 ----------------
> --
>  gcc/diagnostic-format.h                       |   8 -
>  gcc/diagnostic.cc                             |  11 -
>  gcc/diagnostic.h                              |   6 -
>  gcc/doc/invoke.texi                           |  23 +-
>  gcc/doc/ux.texi                               |   2 +-
>  gcc/selftest-run-tests.cc                     |   1 -
>  gcc/selftest.h                                |   1 -
>  .../analyzer/out-of-bounds-diagram-1-json.c   |  13 -
>  .../c-c++-common/diagnostic-format-json-1.c   |  22 -
>  .../c-c++-common/diagnostic-format-json-2.c   |  26 -
>  .../c-c++-common/diagnostic-format-json-3.c   |  26 -
>  .../c-c++-common/diagnostic-format-json-4.c   |  44 --
>  .../c-c++-common/diagnostic-format-json-5.c   |  38 --
>  .../diagnostic-format-json-file-1.c           |   8 -
>  .../diagnostic-format-json-stderr-1.c         |  24 -
>  gcc/testsuite/c-c++-common/pr106133.c         |   3 -
>  gcc/testsuite/g++.dg/pr90462.C                |  49 --
>  .../gcc.dg/plugin/diagnostic-test-paths-3.c   |  75 ---
>  gcc/testsuite/gcc.dg/plugin/plugin.exp        |   1 -
>  .../gfortran.dg/diagnostic-format-json-1.F90  |  24 -
>  .../gfortran.dg/diagnostic-format-json-2.F90  |  26 -
>  .../gfortran.dg/diagnostic-format-json-3.F90  |  26 -
>  .../diagnostic-format-json-pr105916.F90       |  14 -
>  26 files changed, 7 insertions(+), 1081 deletions(-)
>  delete mode 100644 gcc/diagnostic-format-json.cc
>  delete mode 100644 gcc/testsuite/c-c++-common/analyzer/out-of-
> bounds-diagram-1-json.c
>  delete mode 100644 gcc/testsuite/c-c++-common/diagnostic-format-
> json-1.c
>  delete mode 100644 gcc/testsuite/c-c++-common/diagnostic-format-
> json-2.c
>  delete mode 100644 gcc/testsuite/c-c++-common/diagnostic-format-
> json-3.c
>  delete mode 100644 gcc/testsuite/c-c++-common/diagnostic-format-
> json-4.c
>  delete mode 100644 gcc/testsuite/c-c++-common/diagnostic-format-
> json-5.c
>  delete mode 100644 gcc/testsuite/c-c++-common/diagnostic-format-
> json-file-1.c
>  delete mode 100644 gcc/testsuite/c-c++-common/diagnostic-format-
> json-stderr-1.c
>  delete mode 100644 gcc/testsuite/c-c++-common/pr106133.c
>  delete mode 100644 gcc/testsuite/g++.dg/pr90462.C
>  delete mode 100644 gcc/testsuite/gcc.dg/plugin/diagnostic-test-
> paths-3.c
>  delete mode 100644 gcc/testsuite/gfortran.dg/diagnostic-format-json-
> 1.F90
>  delete mode 100644 gcc/testsuite/gfortran.dg/diagnostic-format-json-
> 2.F90
>  delete mode 100644 gcc/testsuite/gfortran.dg/diagnostic-format-json-
> 3.F90
>  delete mode 100644 gcc/testsuite/gfortran.dg/diagnostic-format-json-
> pr105916.F90
> 
> diff --git a/gcc/Makefile.in b/gcc/Makefile.in
> index 9535804f7fb5..d5ceccc424b2 100644
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -1853,7 +1853,6 @@ OBJS = \
>  # no target dependencies.
>  OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \
>       diagnostic-format-html.o \
> -     diagnostic-format-json.o \
>       diagnostic-format-sarif.o \
>       diagnostic-format-text.o \
>       diagnostic-global-context.o \
> diff --git a/gcc/common.opt b/gcc/common.opt
> index 0e50305dde8e..6db0f3a4ac74 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -1481,7 +1481,7 @@ Common Joined RejectNegative UInteger
>  
>  fdiagnostics-format=
>  Common Joined RejectNegative Enum(diagnostics_output_format)
> --fdiagnostics-format=[text|sarif-stderr|sarif-file|json|json-
> stderr|json-file]     Select output format.
> +-fdiagnostics-format=[text|sarif-stderr|sarif-file]  Select
> output format.
>  
>  fdiagnostics-add-output=
>  Common Joined RejectNegative
> @@ -1523,15 +1523,6 @@ Name(diagnostics_output_format) Type(int)
>  EnumValue
>  Enum(diagnostics_output_format) String(text)
> Value(DIAGNOSTICS_OUTPUT_FORMAT_TEXT)
>  
> -EnumValue
> -Enum(diagnostics_output_format) String(json)
> Value(DIAGNOSTICS_OUTPUT_FORMAT_JSON_STDERR)
> -
> -EnumValue
> -Enum(diagnostics_output_format) String(json-stderr)
> Value(DIAGNOSTICS_OUTPUT_FORMAT_JSON_STDERR)
> -
> -EnumValue
> -Enum(diagnostics_output_format) String(json-file)
> Value(DIAGNOSTICS_OUTPUT_FORMAT_JSON_FILE)
> -
>  EnumValue
>  Enum(diagnostics_output_format) String(sarif-stderr)
> Value(DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR)
>  
> diff --git a/gcc/diagnostic-format-json.cc b/gcc/diagnostic-format-
> json.cc
> deleted file mode 100644
> index fb5489778358..000000000000
> --- a/gcc/diagnostic-format-json.cc
> +++ /dev/null
> @@ -1,605 +0,0 @@
> -/* JSON output for diagnostics
> -   Copyright (C) 2018-2025 Free Software Foundation, Inc.
> -   Contributed by David Malcolm <dmalc...@redhat.com>.
> -
> -This file is part of GCC.
> -
> -GCC is free software; you can redistribute it and/or modify it under
> -the terms of the GNU General Public License as published by the Free
> -Software Foundation; either version 3, or (at your option) any later
> -version.
> -
> -GCC is distributed in the hope that it will be useful, but WITHOUT
> ANY
> -WARRANTY; without even the implied warranty of MERCHANTABILITY or
> -FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
> License
> -for more details.
> -
> -You should have received a copy of the GNU General Public License
> -along with GCC; see the file COPYING3.  If not see
> -<http://www.gnu.org/licenses/>.  */
> -
> -
> -#include "config.h"
> -#define INCLUDE_VECTOR
> -#include "system.h"
> -#include "coretypes.h"
> -#include "diagnostic.h"
> -#include "selftest-diagnostic.h"
> -#include "diagnostic-metadata.h"
> -#include "diagnostic-path.h"
> -#include "diagnostic-format.h"
> -#include "diagnostic-buffer.h"
> -#include "json.h"
> -#include "selftest.h"
> -#include "diagnostic-client-data-hooks.h"
> -#include "logical-location.h"
> -
> -class json_output_format;
> -
> -/* Concrete buffering implementation subclass for JSON output.  */
> -
> -class diagnostic_json_format_buffer : public
> diagnostic_per_format_buffer
> -{
> -public:
> -  friend class json_output_format;
> -
> -  diagnostic_json_format_buffer (json_output_format &format)
> -  : m_format (format)
> -  {}
> -
> -  void dump (FILE *out, int indent) const final override;
> -  bool empty_p () const final override;
> -  void move_to (diagnostic_per_format_buffer &dest) final override;
> -  void clear () final override;
> -  void flush () final override;
> -
> -private:
> -  json_output_format &m_format;
> -  std::vector<std::unique_ptr<json::object>> m_results;
> -};
> -
> -/* Subclass of diagnostic_output_format for JSON output.  */
> -
> -class json_output_format : public diagnostic_output_format
> -{
> -public:
> -  friend class diagnostic_json_format_buffer;
> -
> -  void dump (FILE *out, int indent) const override
> -  {
> -    fprintf (out, "%*sjson_output_format\n", indent, "");
> -    diagnostic_output_format::dump (out, indent);
> -  }
> -
> -  std::unique_ptr<diagnostic_per_format_buffer>
> -  make_per_format_buffer () final override
> -  {
> -    return std::make_unique<diagnostic_json_format_buffer> (*this);
> -  }
> -  void set_buffer (diagnostic_per_format_buffer *base_buffer) final
> override
> -  {
> -    diagnostic_json_format_buffer *buffer
> -      = static_cast<diagnostic_json_format_buffer *> (base_buffer);
> -    m_buffer = buffer;
> -  }
> -
> -  void on_begin_group () final override
> -  {
> -    /* No-op.  */
> -  }
> -  void on_end_group () final override
> -  {
> -    m_cur_group = nullptr;
> -    m_cur_children_array = nullptr;
> -  }
> -  void
> -  on_report_diagnostic (const diagnostic_info &diagnostic,
> -                     diagnostic_t orig_diag_kind) final override;
> -  void on_diagram (const diagnostic_diagram &) final override
> -  {
> -    /* No-op.  */
> -  }
> -  void after_diagnostic (const diagnostic_info &) final override
> -  {
> -    /* No-op.  */
> -  }
> -  void update_printer () final override
> -  {
> -    m_printer = m_context.clone_printer ();
> -    pp_show_color (m_printer.get ()) = false;
> -  }
> -  bool follows_reference_printer_p () const final override
> -  {
> -    return false;
> -  }
> -
> -protected:
> -  json_output_format (diagnostic_context &context,
> -                   bool formatted)
> -  : diagnostic_output_format (context),
> -    m_buffer (nullptr),
> -    m_toplevel_array (std::make_unique<json::array> ()),
> -    m_cur_group (nullptr),
> -    m_cur_children_array (nullptr),
> -    m_formatted (formatted)
> -  {
> -  }
> -
> -  /* Flush the top-level array to OUTF.  */
> -  void
> -  flush_to_file (FILE *outf)
> -  {
> -    m_toplevel_array->dump (outf, m_formatted);
> -    fprintf (outf, "\n");
> -    m_toplevel_array = nullptr;
> -  }
> -
> -private:
> -  diagnostic_json_format_buffer *m_buffer;
> -
> -  /* The top-level JSON array of pending diagnostics.  */
> -  std::unique_ptr<json::array> m_toplevel_array;
> -
> -  /* The JSON object for the current diagnostic group.  */
> -  json::object *m_cur_group; // borrowed
> -
> -  /* The JSON array for the "children" array within the current
> diagnostic
> -     group.  */
> -  json::array *m_cur_children_array; // borrowed
> -
> -  bool m_formatted;
> -};
> -
> -/* Generate a JSON object for LOC.  */
> -
> -static std::unique_ptr<json::object>
> -json_from_expanded_location (diagnostic_context &context, location_t
> loc)
> -{
> -  expanded_location exploc = expand_location (loc);
> -  std::unique_ptr<json::object> result = std::make_unique
> <json::object> ();
> -  if (exploc.file)
> -    result->set_string ("file", exploc.file);
> -  result->set_integer ("line", exploc.line);
> -
> -  const enum diagnostics_column_unit orig_unit =
> context.m_column_unit;
> -  struct
> -  {
> -    const char *name;
> -    enum diagnostics_column_unit unit;
> -  } column_fields[] = {
> -    {"display-column", DIAGNOSTICS_COLUMN_UNIT_DISPLAY},
> -    {"byte-column", DIAGNOSTICS_COLUMN_UNIT_BYTE}
> -  };
> -  int the_column = INT_MIN;
> -  for (int i = 0; i != ARRAY_SIZE (column_fields); ++i)
> -    {
> -      context.m_column_unit = column_fields[i].unit;
> -      diagnostic_column_policy col_policy (context);
> -      const int col = col_policy.converted_column (exploc);
> -      result->set_integer (column_fields[i].name, col);
> -      if (column_fields[i].unit == orig_unit)
> -     the_column = col;
> -    }
> -  gcc_assert (the_column != INT_MIN);
> -  result->set_integer ("column", the_column);
> -  context.m_column_unit = orig_unit;
> -  return result;
> -}
> -
> -/* Generate a JSON object for LOC_RANGE.  */
> -
> -static std::unique_ptr<json::object>
> -json_from_location_range (diagnostic_context &context,
> -                       const location_range *loc_range, unsigned
> range_idx)
> -{
> -  location_t caret_loc = get_pure_location (loc_range->m_loc);
> -
> -  if (caret_loc == UNKNOWN_LOCATION)
> -    return nullptr;
> -
> -  location_t start_loc = get_start (loc_range->m_loc);
> -  location_t finish_loc = get_finish (loc_range->m_loc);
> -
> -  std::unique_ptr<json::object> result = std::make_unique
> <json::object> ();
> -  result->set ("caret",
> -            json_from_expanded_location (context, caret_loc));
> -  if (start_loc != caret_loc
> -      && start_loc != UNKNOWN_LOCATION)
> -    result->set ("start",
> -              json_from_expanded_location (context, start_loc));
> -  if (finish_loc != caret_loc
> -      && finish_loc != UNKNOWN_LOCATION)
> -    result->set ("finish",
> -              json_from_expanded_location (context, finish_loc));
> -
> -  if (loc_range->m_label)
> -    {
> -      label_text text (loc_range->m_label->get_text (range_idx));
> -      if (text.get ())
> -     result->set_string ("label", text.get ());
> -    }
> -
> -  return result;
> -}
> -
> -/* Generate a JSON object for HINT.  */
> -
> -static std::unique_ptr<json::object>
> -json_from_fixit_hint (diagnostic_context &context, const fixit_hint
> *hint)
> -{
> -  std::unique_ptr<json::object> fixit_obj = std::make_unique
> <json::object> ();
> -
> -  location_t start_loc = hint->get_start_loc ();
> -  fixit_obj->set ("start",
> -               json_from_expanded_location (context, start_loc));
> -  location_t next_loc = hint->get_next_loc ();
> -  fixit_obj->set ("next",
> -               json_from_expanded_location (context, next_loc).
> release ());
> -  fixit_obj->set_string ("string", hint->get_string ());
> -
> -  return fixit_obj;
> -}
> -
> -/* Generate a JSON object for METADATA.  */
> -
> -static std::unique_ptr<json::object>
> -json_from_metadata (const diagnostic_metadata *metadata)
> -{
> -  std::unique_ptr<json::object> metadata_obj = std::make_unique
> <json::object> ();
> -
> -  if (metadata->get_cwe ())
> -    metadata_obj->set_integer ("cwe", metadata->get_cwe ());
> -
> -  return metadata_obj;
> -}
> -
> -/* Make a JSON value for PATH.  */
> -
> -static std::unique_ptr<json::array>
> -make_json_for_path (diagnostic_context &context,
> -                 pretty_printer *ref_pp,
> -                 const diagnostic_path *path)
> -{
> -  std::unique_ptr<json::array> path_array =
> std::make_unique<json::array> ();
> -  for (unsigned i = 0; i < path->num_events (); i++)
> -    {
> -      const diagnostic_event &event = path->get_event (i);
> -
> -      std::unique_ptr<json::object> event_obj = std::make_unique
> <json::object> ();
> -      if (event.get_location ())
> -     event_obj->set ("location",
> -                     json_from_expanded_location (context,
> -                                                 
> event.get_location ()));
> -      auto pp = ref_pp->clone ();
> -      event.print_desc (*pp.get ());
> -      event_obj->set_string ("description", pp_formatted_text
> (pp.get ()));
> -      if (logical_location logical_loc = event.get_logical_location
> ())
> -     if (auto hooks = context.get_client_data_hooks ())
> -       if (auto mgr = hooks->get_logical_location_manager ())
> -         {
> -           label_text name (mgr->get_name_for_path_output
> (logical_loc));
> -           event_obj->set_string ("function", name.get ());
> -         }
> -      event_obj->set_integer ("depth", event.get_stack_depth ());
> -      path_array->append (std::move (event_obj));
> -    }
> -  return path_array;
> -}
> -
> -/* class diagnostic_json_format_buffer : public
> diagnostic_per_format_buffer.  */
> -
> -void
> -diagnostic_json_format_buffer::dump (FILE *out, int indent) const
> -{
> -  fprintf (out, "%*sdiagnostic_json_format_buffer:\n", indent, "");
> -  int idx = 0;
> -  for (auto &result : m_results)
> -    {
> -      fprintf (out, "%*sresult[%i]:\n", indent + 2, "", idx);
> -      result->dump (out, true);
> -      fprintf (out, "\n");
> -      ++idx;
> -    }
> -}
> -
> -bool
> -diagnostic_json_format_buffer::empty_p () const
> -{
> -  return m_results.empty ();
> -}
> -
> -void
> -diagnostic_json_format_buffer::move_to (diagnostic_per_format_buffer
> &base)
> -{
> -  diagnostic_json_format_buffer &dest
> -    = static_cast<diagnostic_json_format_buffer &> (base);
> -  for (auto &&result : m_results)
> -    dest.m_results.push_back (std::move (result));
> -  m_results.clear ();
> -}
> -
> -void
> -diagnostic_json_format_buffer::clear ()
> -{
> -  m_results.clear ();
> -}
> -
> -void
> -diagnostic_json_format_buffer::flush ()
> -{
> -  for (auto &&result : m_results)
> -    m_format.m_toplevel_array->append (std::move (result));
> -  m_results.clear ();
> -}
> -
> -/* Implementation of "on_report_diagnostic" vfunc for JSON output.
> -   Generate a JSON object for DIAGNOSTIC, and store for output
> -   within current diagnostic group.  */
> -
> -void
> -json_output_format::on_report_diagnostic (const diagnostic_info
> &diagnostic,
> -                                       diagnostic_t
> orig_diag_kind)
> -{
> -  pretty_printer *const pp = get_printer ();
> -  pp_output_formatted_text (pp, m_context.get_urlifier ());
> -
> -  json::object *diag_obj = new json::object ();
> -
> -  /* Get "kind" of diagnostic.  */
> -  {
> -    /* Lose the trailing ": ".  */
> -    const char *kind_text = get_diagnostic_kind_text
> (diagnostic.kind);
> -    size_t len = strlen (kind_text);
> -    gcc_assert (len > 2);
> -    gcc_assert (kind_text[len - 2] == ':');
> -    gcc_assert (kind_text[len - 1] == ' ');
> -    char *rstrip = xstrdup (kind_text);
> -    rstrip[len - 2] = '\0';
> -    diag_obj->set_string ("kind", rstrip);
> -    free (rstrip);
> -  }
> -
> -  // FIXME: encoding of the message (json::string requires UTF-8)
> -  diag_obj->set_string ("message", pp_formatted_text (pp));
> -  pp_clear_output_area (pp);
> -
> -  if (char *option_text = m_context.make_option_name
> (diagnostic.option_id,
> -                                                  
> orig_diag_kind,
> -                                                  
> diagnostic.kind))
> -    {
> -      diag_obj->set_string ("option", option_text);
> -      free (option_text);
> -    }
> -
> -  if (char *option_url = m_context.make_option_url
> (diagnostic.option_id))
> -    {
> -      diag_obj->set_string ("option_url", option_url);
> -      free (option_url);
> -    }
> -
> -  if (m_buffer)
> -    {
> -      gcc_assert (!m_cur_group);
> -      m_buffer->m_results.push_back (std::unique_ptr<json::object>
> (diag_obj));
> -    }
> -  else
> -    {
> -      /* If we've already emitted a diagnostic within this
> auto_diagnostic_group,
> -      then add diag_obj to its "children" array.  */
> -      if (m_cur_group)
> -     {
> -       gcc_assert (m_cur_children_array);
> -       m_cur_children_array->append (diag_obj);
> -     }
> -      else
> -     {
> -       /* Otherwise, make diag_obj be the top-level object within
> the group;
> -          add a "children" array and record the column origin. 
> */
> -       m_cur_group = diag_obj;
> -       std::unique_ptr<json::array> children_array
> -         = std::make_unique<json::array> ();
> -       m_cur_children_array = children_array.get (); // borrowed
> -       diag_obj->set ("children", std::move (children_array));
> -       diag_obj->set_integer ("column-origin",
> m_context.m_column_origin);
> -       m_toplevel_array->append (diag_obj);
> -     }
> -    }
> -
> -  /* diag_obj is now owned by either m_cur_children_array or
> -     m_toplevel_array; further uses of diag_obj are borrowing it. 
> */
> -
> -  const rich_location *richloc = diagnostic.richloc;
> -
> -  {
> -    std::unique_ptr<json::array> loc_array =
> std::make_unique<json::array> ();
> -    for (unsigned int i = 0; i < richloc->get_num_locations (); i++)
> -      {
> -     const location_range *loc_range = richloc->get_range (i);
> -     if (std::unique_ptr<json::object> loc_obj
> -           = json_from_location_range (m_context, loc_range, i))
> -       loc_array->append (std::move (loc_obj));
> -      }
> -    diag_obj->set ("locations", std::move (loc_array));
> -  }
> -
> -  if (richloc->get_num_fixit_hints ())
> -    {
> -      std::unique_ptr<json::array> fixit_array =
> std::make_unique<json::array> ();
> -      for (unsigned int i = 0; i < richloc->get_num_fixit_hints ();
> i++)
> -     {
> -       const fixit_hint *hint = richloc->get_fixit_hint (i);
> -       fixit_array->append (json_from_fixit_hint (m_context,
> hint));
> -     }
> -      diag_obj->set ("fixits", std::move (fixit_array));
> -    }
> -
> -  /* TODO: tree-ish things:
> -     TODO: functions
> -     TODO: inlining information
> -     TODO: macro expansion information.  */
> -
> -  if (diagnostic.metadata)
> -    diag_obj->set ("metadata", json_from_metadata
> (diagnostic.metadata));
> -
> -  const diagnostic_path *path = richloc->get_path ();
> -  if (path)
> -    diag_obj->set ("path", make_json_for_path (m_context,
> get_printer (), path));
> -
> -  diag_obj->set_bool ("escape-source", richloc->escape_on_output_p
> ());
> -}
> -
> -class json_stderr_output_format : public json_output_format
> -{
> -public:
> -  json_stderr_output_format (diagnostic_context &context,
> -                          bool formatted)
> -    : json_output_format (context, formatted)
> -  {
> -  }
> -  ~json_stderr_output_format ()
> -  {
> -    flush_to_file (stderr);
> -  }
> -  bool machine_readable_stderr_p () const final override
> -  {
> -    return true;
> -  }
> -};
> -
> -class json_file_output_format : public json_output_format
> -{
> -public:
> -  json_file_output_format (diagnostic_context &context,
> -                        bool formatted,
> -                        const char *base_file_name)
> -  : json_output_format (context, formatted),
> -    m_base_file_name (xstrdup (base_file_name))
> -  {
> -  }
> -
> -  ~json_file_output_format ()
> -  {
> -    char *filename = concat (m_base_file_name, ".gcc.json",
> nullptr);
> -    free (m_base_file_name);
> -    m_base_file_name = nullptr;
> -    FILE *outf = fopen (filename, "w");
> -    if (!outf)
> -      {
> -     const char *errstr = xstrerror (errno);
> -     fnotice (stderr, "error: unable to open '%s' for writing:
> %s\n",
> -              filename, errstr);
> -     free (filename);
> -     return;
> -      }
> -    flush_to_file (outf);
> -    fclose (outf);
> -    free (filename);
> -  }
> -  bool machine_readable_stderr_p () const final override
> -  {
> -    return false;
> -  }
> -
> -private:
> -  char *m_base_file_name;
> -};
> -
> -/* Populate CONTEXT in preparation for JSON output (either to
> stderr, or
> -   to a file) using FMT.  Return a reference to *FMT.  */
> -
> -static diagnostic_output_format &
> -diagnostic_output_format_init_json (diagnostic_context &context,
> -                                
> std::unique_ptr<json_output_format> fmt)
> -{
> -  gcc_assert (fmt);
> -  diagnostic_output_format &out = *fmt;
> -
> -  /* Don't colorize the text.  */
> -  pp_show_color (fmt->get_printer ()) = false;
> -  context.set_show_highlight_colors (false);
> -
> -  context.set_output_format (std::move (fmt));
> -
> -  return out;
> -}
> -
> -/* Populate CONTEXT in preparation for JSON output to stderr.
> -   Return a reference to the context's new sink.  */
> -
> -diagnostic_output_format &
> -diagnostic_output_format_init_json_stderr (diagnostic_context
> &context,
> -                                        bool formatted)
> -{
> -  return diagnostic_output_format_init_json
> -    (context,
> -     std::make_unique<json_stderr_output_format> (context,
> -                                               formatted));
> -}
> -
> -/* Populate CONTEXT in preparation for JSON output to a file named
> -   BASE_FILE_NAME.gcc.json.
> -   Return a reference to the context's new sink.  */
> -
> -diagnostic_output_format &
> -diagnostic_output_format_init_json_file (diagnostic_context
> &context,
> -                                      bool formatted,
> -                                      const char *base_file_name)
> -{
> -  return diagnostic_output_format_init_json
> -    (context,
> -     std::make_unique<json_file_output_format> (context,
> -                                             formatted,
> -                                             base_file_name));
> -}
> -
> -#if CHECKING_P
> -
> -namespace selftest {
> -
> -/* We shouldn't call json_from_expanded_location on
> UNKNOWN_LOCATION,
> -   but verify that we handle this gracefully.  */
> -
> -static void
> -test_unknown_location ()
> -{
> -  test_diagnostic_context dc;
> -  json_from_expanded_location (dc, UNKNOWN_LOCATION);
> -}
> -
> -/* Verify that we gracefully handle attempts to serialize bad
> -   compound locations.  */
> -
> -static void
> -test_bad_endpoints ()
> -{
> -  location_t bad_endpoints
> -    = make_location (BUILTINS_LOCATION,
> -                  UNKNOWN_LOCATION, UNKNOWN_LOCATION);
> -
> -  location_range loc_range;
> -  loc_range.m_loc = bad_endpoints;
> -  loc_range.m_range_display_kind = SHOW_RANGE_WITH_CARET;
> -  loc_range.m_label = nullptr;
> -
> -  test_diagnostic_context dc;
> -  std::unique_ptr<json::object> obj
> -    = json_from_location_range (dc, &loc_range, 0);
> -  /* We should have a "caret" value, but no "start" or "finish"
> values.  */
> -  ASSERT_TRUE (obj != nullptr);
> -  ASSERT_TRUE (obj->get ("caret") != nullptr);
> -  ASSERT_TRUE (obj->get ("start") == nullptr);
> -  ASSERT_TRUE (obj->get ("finish") == nullptr);
> -}
> -
> -/* Run all of the selftests within this file.  */
> -
> -void
> -diagnostic_format_json_cc_tests ()
> -{
> -  test_unknown_location ();
> -  test_bad_endpoints ();
> -}
> -
> -} // namespace selftest
> -
> -#endif /* #if CHECKING_P */
> diff --git a/gcc/diagnostic-format.h b/gcc/diagnostic-format.h
> index 4de5842ad2c2..07db2cd4daa1 100644
> --- a/gcc/diagnostic-format.h
> +++ b/gcc/diagnostic-format.h
> @@ -100,12 +100,4 @@ diagnostic_output_format_init
> (diagnostic_context &,
>                              enum diagnostics_output_format,
>                              bool json_formatting);
>  
> -extern diagnostic_output_format &
> -diagnostic_output_format_init_json_stderr (diagnostic_context
> &context,
> -                                        bool formatted);
> -extern diagnostic_output_format &
> -diagnostic_output_format_init_json_file (diagnostic_context
> &context,
> -                                      bool formatted,
> -                                      const char
> *base_file_name);
> -
>  #endif /* ! GCC_DIAGNOSTIC_FORMAT_H */
> diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
> index 8547d4882d3e..3c2c9b9fb0f8 100644
> --- a/gcc/diagnostic.cc
> +++ b/gcc/diagnostic.cc
> @@ -1881,17 +1881,6 @@ diagnostic_output_format_init
> (diagnostic_context &context,
>        /* The default; do nothing.  */
>        break;
>  
> -    case DIAGNOSTICS_OUTPUT_FORMAT_JSON_STDERR:
> -      new_sink = &diagnostic_output_format_init_json_stderr
> (context,
> -                                                         
> json_formatting);
> -      break;
> -
> -    case DIAGNOSTICS_OUTPUT_FORMAT_JSON_FILE:
> -      new_sink = &diagnostic_output_format_init_json_file (context,
> -                                                       
> json_formatting,
> -                                                       
> base_file_name);
> -      break;
> -
>      case DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR:
>        new_sink = &diagnostic_output_format_init_sarif_stderr
> (context,
>                                                            
> line_table,
> diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h
> index 9df429275f0b..00f6e352d401 100644
> --- a/gcc/diagnostic.h
> +++ b/gcc/diagnostic.h
> @@ -71,12 +71,6 @@ enum diagnostics_output_format
>    /* The default: textual output.  */
>    DIAGNOSTICS_OUTPUT_FORMAT_TEXT,
>  
> -  /* JSON-based output, to stderr.  */
> -  DIAGNOSTICS_OUTPUT_FORMAT_JSON_STDERR,
> -
> -  /* JSON-based output, to a file.  */
> -  DIAGNOSTICS_OUTPUT_FORMAT_JSON_FILE,
> -
>    /* SARIF-based output, as JSON to stderr.  */
>    DIAGNOSTICS_OUTPUT_FORMAT_SARIF_STDERR,
>  
> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index a0c6d3d082e6..96cdc62b8552 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -312,7 +312,7 @@ Objective-C and Objective-C++ Dialects}.
>  -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}
>  -fdiagnostics-color=@r{[}auto@r{|}never@r{|}always@r{]}
>  -fdiagnostics-urls=@r{[}auto@r{|}never@r{|}always@r{]}
> --fdiagnostics-format=@r{[
> }text@r{|}sarif-stderr@r{|}sarif-file@r{|}json@r{
> |}json-stderr@r{|}json-file@r{]}
> +-fdiagnostics-format=@r{[}text@r{|}sarif-stderr@r{|}sarif-file@r{]}
>  -fdiagnostics-add-output=@var{DIAGNOSTICS-OUTPUT-SPEC}
>  -fdiagnostics-set-output=@var{DIAGNOSTICS-OUTPUT-SPEC}
>  -fno-diagnostics-json-formatting
> @@ -5958,8 +5958,7 @@ column numbers, such as @command{dejagnu}.
>  @opindex fdiagnostics-column-unit
>  @item -fdiagnostics-column-unit=@var{UNIT}
>  Select the units for the column number.  This affects traditional
> diagnostics
> -(in the absence of @option{-fno-show-column}), as well as JSON
> format
> -diagnostics if requested.
> +(in the absence of @option{-fno-show-column}).
>  
>  The default @var{UNIT}, @samp{display}, considers the number of
> display
>  columns occupied by each character.  This may be larger than the
> number
> @@ -6035,8 +6034,7 @@ is set to @samp{C}, in which case the default
> is @samp{ascii}.
>  @opindex fdiagnostics-format
>  @item -fdiagnostics-format=@var{FORMAT}
>  Select a different format for printing diagnostics.
> -@var{FORMAT} is @samp{text}, @samp{sarif-stderr}, @samp{sarif-file},
> -@samp{json}, @samp{json-stderr}, or @samp{json-file}.
> +@var{FORMAT} is @samp{text}, @samp{sarif-stderr} or @samp{sarif-
> file}.
>  
>  Using this option replaces any additional ``output sinks'' added by
>  @option{-fdiagnostics-add-output=}, or that set by
> @@ -6048,14 +6046,6 @@ The @samp{sarif-stderr} and @samp{sarif-file}
> formats both emit
>  diagnostics in SARIF Version 2.1.0 format, either to stderr, or to a
> file
>  named @file{@var{source}.sarif}, respectively.
>  
> -The various @samp{json}, @samp{json-stderr}, and @samp{json-file}
> values
> -are deprecated and refer to a legacy JSON-based output format.
> -The @samp{json} format is a synonym for @samp{json-stderr}.
> -The @samp{json-stderr} and @samp{json-file} formats are identical,
> apart from
> -where the JSON is emitted to.  With @samp{json-stderr}, the JSON is
> emitted
> -to stderr, whereas with @samp{json-file} it is written to
> -@file{@var{source}.gcc.json}.
> -
>  @opindex fdiagnostics-add-output
>  @item -fdiagnostics-add-output=@var{DIAGNOSTICS-OUTPUT-SPEC}
>  Add an additional ``output sink'' for emitting diagnostics.
> @@ -6238,11 +6228,8 @@ replaces all existing output sinks, such as
> from @option{-fdiagnostics-format=},
>  @opindex fdiagnostics-json-formatting
>  @item -fno-diagnostics-json-formatting
>  By default, when JSON is emitted for diagnostics (via
> -@option{-fdiagnostics-format=sarif-stderr},
> -@option{-fdiagnostics-format=sarif-file},
> -@option{-fdiagnostics-format=json},
> -@option{-fdiagnostics-format=json-stderr},
> -@option{-fdiagnostics-format=json-file}),
> +@option{-fdiagnostics-format=sarif-stderr} or
> +@option{-fdiagnostics-format=sarif-file}),
>  GCC will add newlines and indentation to visually emphasize the
>  hierarchical structure of the JSON.
>  
> diff --git a/gcc/doc/ux.texi b/gcc/doc/ux.texi
> index 243b3e08b112..22df88f61cea 100644
> --- a/gcc/doc/ux.texi
> +++ b/gcc/doc/ux.texi
> @@ -407,7 +407,7 @@ Use @code{auto_diagnostic_group} when issuing
> multiple related
>  diagnostics (seen in various examples on this page).  This informs
> the
>  diagnostic subsystem that all diagnostics issued within the lifetime
>  of the @code{auto_diagnostic_group} are related.  For example,
> -@option{-fdiagnostics-format=json} will treat the first diagnostic
> +@option{-fdiagnostics-add-output=sarif} will treat the first
> diagnostic
>  emitted within the group as a top-level diagnostic, and all
> subsequent
>  diagnostics within the group as its children.  Also, if a warning in
> the
>  group is inhibited at nesting depth D, all subsequent notes at that
> depth
> diff --git a/gcc/selftest-run-tests.cc b/gcc/selftest-run-tests.cc
> index 139c7b381b60..324545302f79 100644
> --- a/gcc/selftest-run-tests.cc
> +++ b/gcc/selftest-run-tests.cc
> @@ -101,7 +101,6 @@ selftest::run_tests ()
>    diagnostic_color_cc_tests ();
>    diagnostic_show_locus_cc_tests ();
>    diagnostic_format_html_cc_tests ();
> -  diagnostic_format_json_cc_tests ();
>    diagnostic_format_sarif_cc_tests ();
>    diagnostic_output_spec_cc_tests ();
>    edit_context_cc_tests ();
> diff --git a/gcc/selftest.h b/gcc/selftest.h
> index 4af647cca9e1..eb9e604a321f 100644
> --- a/gcc/selftest.h
> +++ b/gcc/selftest.h
> @@ -223,7 +223,6 @@ extern void convert_cc_tests ();
>  extern void dbgcnt_cc_tests ();
>  extern void diagnostic_color_cc_tests ();
>  extern void diagnostic_format_html_cc_tests ();
> -extern void diagnostic_format_json_cc_tests ();
>  extern void diagnostic_format_sarif_cc_tests ();
>  extern void diagnostic_output_spec_cc_tests ();
>  extern void diagnostic_path_output_cc_tests ();
> diff --git a/gcc/testsuite/c-c++-common/analyzer/out-of-bounds-
> diagram-1-json.c b/gcc/testsuite/c-c++-common/analyzer/out-of-bounds-
> diagram-1-json.c
> deleted file mode 100644
> index 0a2cc3493ab4..000000000000
> --- a/gcc/testsuite/c-c++-common/analyzer/out-of-bounds-diagram-1-
> json.c
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -/* { dg-additional-options "-fdiagnostics-format=json-file" } */
> -
> -/* The custom JSON format doesn't support text art, so this is just
> a simple
> -   smoketext.  */
> -
> -#include <stdint.h>
> -
> -int32_t arr[10];
> -
> -void int_arr_write_element_after_end_off_by_one(int32_t x)
> -{
> -  arr[10] = x;
> -}
> diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c
> b/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c
> deleted file mode 100644
> index c95218c3cfe3..000000000000
> --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-1.c
> +++ /dev/null
> @@ -1,22 +0,0 @@
> -/* { dg-do compile } */
> -/* { dg-options "-fdiagnostics-format=json" } */
> -
> -#error message
> -
> -/* { dg-begin-multiline-output "" }
> -[{"kind": "error",
> -  "message": "#error message",
> -  "children": [],
> -  "column-origin": 1,
> -  "locations": [{"caret": {"file":
> -                           "line": 4,
> -                           "display-column": 2,
> -                           "byte-column": 2,
> -                           "column": 2},
> -                 "finish": {"file":
> -                            "line": 4,
> -                            "display-column": 6,
> -                            "byte-column": 6,
> -                            "column": 6}}],
> -  "escape-source": false}]
> -   { dg-end-multiline-output "" } */
> diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c
> b/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c
> deleted file mode 100644
> index a8828b7b2df7..000000000000
> --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-2.c
> +++ /dev/null
> @@ -1,26 +0,0 @@
> -/* { dg-do compile } */
> -/* { dg-options "-fdiagnostics-format=json" } */
> -
> -#warning message
> -
> -/* { dg-begin-multiline-output "" }
> -[{"kind": "warning",
> -  "message": "#warning message",
> -  "option": "-Wcpp",
> -   { dg-end-multiline-output "" } */
> -/* { dg-regexp "  \"option_url\": \"https:\[^\n\r\"\]*#index-
> Wcpp\",\n" } */
> -/* { dg-begin-multiline-output "" }
> -  "children": [],
> -  "column-origin": 1,
> -  "locations": [{"caret": {"file":
> -                           "line": 4,
> -                           "display-column": 2,
> -                           "byte-column": 2,
> -                           "column": 2},
> -                 "finish": {"file":
> -                            "line": 4,
> -                            "display-column": 8,
> -                            "byte-column": 8,
> -                            "column": 8}}],
> -  "escape-source": false}]
> -   { dg-end-multiline-output "" } */
> diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c
> b/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c
> deleted file mode 100644
> index 178bbf94b5b2..000000000000
> --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-3.c
> +++ /dev/null
> @@ -1,26 +0,0 @@
> -/* { dg-do compile } */
> -/* { dg-options "-fdiagnostics-format=json -Werror" } */
> -
> -#warning message
> -
> -/* { dg-begin-multiline-output "" }
> -[{"kind": "error",
> -  "message": "#warning message",
> -  "option": "-Werror=cpp",
> -   { dg-end-multiline-output "" } */
> -/* { dg-regexp "  \"option_url\": \"https:\[^\n\r\"\]*#index-
> Wcpp\",\n" } */
> -/* { dg-begin-multiline-output "" }
> -  "children": [],
> -  "column-origin": 1,
> -  "locations": [{"caret": {"file":
> -                           "line": 4,
> -                           "display-column": 2,
> -                           "byte-column": 2,
> -                           "column": 2},
> -                 "finish": {"file":
> -                            "line": 4,
> -                            "display-column": 8,
> -                            "byte-column": 8,
> -                            "column": 8}}],
> -  "escape-source": false}]
> -   { dg-end-multiline-output "" } */
> diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c
> b/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c
> deleted file mode 100644
> index 899a03f0e5e5..000000000000
> --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-4.c
> +++ /dev/null
> @@ -1,44 +0,0 @@
> -/* { dg-do compile } */
> -/* { dg-options "-fdiagnostics-format=json -Wmisleading-indentation"
> } */
> -
> -int test (void)
> -{
> -  if (1)
> -    return 3;
> -    return 4;
> -  return 5;
> -}
> -
> -/* { dg-begin-multiline-output "" }
> -[{"kind": "warning",
> -  "message": "this 'if' clause does not guard...",
> -  "option": "-Wmisleading-indentation",
> -   { dg-end-multiline-output "" } */
> -/* { dg-regexp "  \"option_url\": \"https:\[^\n\r\"\]*#index-
> Wmisleading-indentation\",\n" } */
> -/* { dg-begin-multiline-output "" }
> -  "children": [{"kind": "note",
> -                "message": "...this statement, but the latter is
> misleadingly indented as if it were guarded by the 'if'",
> -                "locations": [{"caret": {"file":
> -                                         "line": 8,
> -                                         "display-column": 5,
> -                                         "byte-column": 5,
> -                                         "column": 5},
> -                               "finish": {"file":
> -                                          "line": 8,
> -                                          "display-column": 10,
> -                                          "byte-column": 10,
> -                                          "column": 10}}],
> -                "escape-source": false}],
> -  "column-origin": 1,
> -  "locations": [{"caret": {"file":
> -                           "line": 6,
> -                           "display-column": 3,
> -                           "byte-column": 3,
> -                           "column": 3},
> -                 "finish": {"file":
> -                            "line": 6,
> -                            "display-column": 4,
> -                            "byte-column": 4,
> -                            "column": 4}}],
> -  "escape-source": false}]
> -   { dg-end-multiline-output "" } */
> diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c
> b/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c
> deleted file mode 100644
> index ed3139c7f1b2..000000000000
> --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-5.c
> +++ /dev/null
> @@ -1,38 +0,0 @@
> -/* { dg-do compile } */
> -/* { dg-options "-fdiagnostics-format=json" } */
> -
> -struct s { int color; };
> -
> -int test (struct s *ptr)
> -{
> -  return ptr->colour;
> -}
> -
> -/* { dg-begin-multiline-output "" }
> -[{"kind": "error",
> -  "message": "'struct s' has no member named 'colour'; did you mean
> 'color'?",
> -  "children": [],
> -  "column-origin": 1,
> -  "locations": [{"caret": {"file":
> -                           "line": 8,
> -                           "display-column": 15,
> -                           "byte-column": 15,
> -                           "column": 15},
> -                 "finish": {"file":
> -                            "line": 8,
> -                            "display-column": 20,
> -                            "byte-column": 20,
> -                            "column": 20}}],
> -  "fixits": [{"start": {"file":
> -                        "line": 8,
> -                        "display-column": 15,
> -                        "byte-column": 15,
> -                        "column": 15},
> -              "next": {"file":
> -                       "line": 8,
> -                       "display-column": 21,
> -                       "byte-column": 21,
> -                       "column": 21},
> -              "string": "color"}],
> -  "escape-source": false}]
> -   { dg-end-multiline-output "" } */
> diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-file-
> 1.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-file-1.c
> deleted file mode 100644
> index ddac780f07b1..000000000000
> --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-file-1.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -/* Check that -fdiagnostics-format=json-file works.  */
> -/* { dg-do compile } */
> -/* { dg-options "-fdiagnostics-format=json-file" } */
> -
> -#warning message
> -
> -/* Verify that some JSON was written to a file with the expected
> name.  */
> -/* { dg-final { scan-file "diagnostic-format-json-file-1.c.gcc.json"
> "\"message\": \"#warning message\"" } } */
> diff --git a/gcc/testsuite/c-c++-common/diagnostic-format-json-
> stderr-1.c b/gcc/testsuite/c-c++-common/diagnostic-format-json-
> stderr-1.c
> deleted file mode 100644
> index e798c6b21e1e..000000000000
> --- a/gcc/testsuite/c-c++-common/diagnostic-format-json-stderr-1.c
> +++ /dev/null
> @@ -1,24 +0,0 @@
> -/* Check that "json" and "json-stderr" are synonymous when used as
> -   arguments to "-fdiagnostics-format=".  */
> -/* { dg-do compile } */
> -/* { dg-options "-fdiagnostics-format=json-stderr" } */
> -
> -#error message
> -
> -/* { dg-begin-multiline-output "" }
> -[{"kind": "error",
> -  "message": "#error message",
> -  "children": [],
> -  "column-origin": 1,
> -  "locations": [{"caret": {"file":
> -                           "line": 6,
> -                           "display-column": 2,
> -                           "byte-column": 2,
> -                           "column": 2},
> -                 "finish": {"file":
> -                            "line": 6,
> -                            "display-column": 6,
> -                            "byte-column": 6,
> -                            "column": 6}}],
> -  "escape-source": false}]
> -   { dg-end-multiline-output "" } */
> diff --git a/gcc/testsuite/c-c++-common/pr106133.c b/gcc/testsuite/c-
> c++-common/pr106133.c
> deleted file mode 100644
> index 7d2c5afe4177..000000000000
> --- a/gcc/testsuite/c-c++-common/pr106133.c
> +++ /dev/null
> @@ -1,3 +0,0 @@
> -/* PR middle-end/106133 */
> -/* { dg-do compile } */
> -/* { dg-options "-fdiagnostics-format=json-file -E" } */
> diff --git a/gcc/testsuite/g++.dg/pr90462.C
> b/gcc/testsuite/g++.dg/pr90462.C
> deleted file mode 100644
> index b35e41921a60..000000000000
> --- a/gcc/testsuite/g++.dg/pr90462.C
> +++ /dev/null
> @@ -1,49 +0,0 @@
> -/* { dg-options "-Wdeprecated-copy -fno-diagnostics-json-formatting
> -fdiagnostics-format=json" } */
> -
> -template <class> class b;
> -struct B {
> -  typedef b<char> *c;
> -};
> -class d {
> -public:
> -  B::c operator->();
> -};
> -template <class> struct e;
> -class f {
> -  typedef int g;
> -};
> -template <class, class> class h;
> -template <class i> class b {
> -public:
> -  i j;
> -  i k;
> -  int l;
> -  void assign() {
> -    int m;
> -    h<i, int> n(&m);
> -    n.o(&j, &k, l);
> -  }
> -};
> -template <class i, class> class s : f { s &p(const i *, const i *,
> g); };
> -template <class i, class t> s<i, t> &s<i, t>::p(const i *, const i
> *, g) {
> -  d q;
> -  q->assign();
> -}
> -struct G {
> -  G();
> -  G(int);
> -  G(G &);
> -};
> -template <class i, class> class h {
> -public:
> -  h(int *);
> -  void o(const i *, const i *, unsigned);
> -  i r();
> -};
> -template <class i, class t> void h<i, t>::o(const i *, const i *,
> unsigned) {
> -  G a;
> -  a = r();
> -}
> -template s<char, e<char>> &s<char, e<char>>::p(const char *, const
> char *, g);
> -
> -/* { dg-regexp ".*" } */
> diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-3.c
> b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-3.c
> deleted file mode 100644
> index a315d208cab7..000000000000
> --- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-paths-3.c
> +++ /dev/null
> @@ -1,75 +0,0 @@
> -/* { dg-do compile } */
> -/* { dg-options "-fdiagnostics-format=json" } */
> -
> -#include <stddef.h>
> -#include <stdlib.h>
> -
> -/* Minimal reimplementation of cpython API.  */
> -typedef struct PyObject {} PyObject;
> -extern int PyArg_ParseTuple (PyObject *args, const char *fmt, ...);
> -extern PyObject *PyList_New (int);
> -extern PyObject *PyLong_FromLong(long);
> -extern void PyList_Append(PyObject *list, PyObject *item);
> -
> -PyObject *
> -make_a_list_of_random_ints_badly(PyObject *self,
> -                              PyObject *args)
> -{
> -  PyObject *list, *item;
> -  long count, i;
> -
> -  if (!PyArg_ParseTuple(args, "i", &count)) {
> -    return NULL;
> -  }
> -
> -  list = PyList_New(0);
> -     
> -  for (i = 0; i < count; i++) {
> -    item = PyLong_FromLong(random());
> -    PyList_Append(list, item);
> -  }
> -  
> -  return list;
> -}
> -
> -/* { dg-begin-multiline-output "" }
> -[{"kind": "error",
> -  "message": "passing NULL as argument 1 to 'PyList_Append' which
> requires a non-NULL parameter",
> -  "children": [],
> -  "column-origin": 1,
> -  "locations": [{"caret": {"file": "
> -                           "line": 29,
> -                           "display-column": 5,
> -                           "byte-column": 5,
> -                           "column": 5},
> -                 "finish": {"file": "
> -                            "line": 29,
> -                            "display-column": 29,
> -                            "byte-column": 29,
> -                            "column": 29}}],
> -  "path": [{"location": {"file": "
> -                         "line": 25,
> -                         "display-column": 10,
> -                         "byte-column": 10,
> -                         "column": 10},
> -            "description": "when 'PyList_New' fails, returning
> NULL",
> -            "function": "make_a_list_of_random_ints_badly",
> -            "depth": 0},
> -           {"location": {"file": "
> -                         "line": 27,
> -                         "display-column": 17,
> -                         "byte-column": 17,
> -                         "column": 17},
> -            "description": "when 'i < count'",
> -            "function": "make_a_list_of_random_ints_badly",
> -            "depth": 0},
> -           {"location": {"file": "
> -                         "line": 29,
> -                         "display-column": 5,
> -                         "byte-column": 5,
> -                         "column": 5},
> -            "description": "when calling 'PyList_Append', passing
> NULL from (1) as argument 1",
> -            "function": "make_a_list_of_random_ints_badly",
> -            "depth": 0}],
> -  "escape-source": false}]
> -{ dg-end-multiline-output "" } */
> diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp
> b/gcc/testsuite/gcc.dg/plugin/plugin.exp
> index a066b67bb9a1..d1d7f5dbc037 100644
> --- a/gcc/testsuite/gcc.dg/plugin/plugin.exp
> +++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp
> @@ -116,7 +116,6 @@ set plugin_test_list [list \
>      { diagnostic_plugin_test_paths.cc \
>         diagnostic-test-paths-1.c \
>         diagnostic-test-paths-2.c \
> -       diagnostic-test-paths-3.c \
>         diagnostic-test-paths-4.c \
>         diagnostic-test-paths-5.c \
>         diagnostic-test-paths-multithreaded-inline-events.c \
> diff --git a/gcc/testsuite/gfortran.dg/diagnostic-format-json-1.F90
> b/gcc/testsuite/gfortran.dg/diagnostic-format-json-1.F90
> deleted file mode 100644
> index b8cd61cff23a..000000000000
> --- a/gcc/testsuite/gfortran.dg/diagnostic-format-json-1.F90
> +++ /dev/null
> @@ -1,24 +0,0 @@
> -! { dg-do compile }
> -! { dg-options "-fdiagnostics-format=json" }
> -
> -#error message
> -
> -#if 0
> -{ dg-begin-multiline-output "" }
> -[{"kind": "error",
> -  "message": "#error message",
> -  "children": [],
> -  "column-origin": 1,
> -  "locations": [{"caret": {"file":
> -                           "line": 4,
> -                           "display-column": 2,
> -                           "byte-column": 2,
> -                           "column": 2},
> -                 "finish": {"file":
> -                            "line": 4,
> -                            "display-column": 6,
> -                            "byte-column": 6,
> -                            "column": 6}}],
> -  "escape-source": false}]
> -{ dg-end-multiline-output "" }
> -#endif  
> diff --git a/gcc/testsuite/gfortran.dg/diagnostic-format-json-2.F90
> b/gcc/testsuite/gfortran.dg/diagnostic-format-json-2.F90
> deleted file mode 100644
> index 9ff1ef59b343..000000000000
> --- a/gcc/testsuite/gfortran.dg/diagnostic-format-json-2.F90
> +++ /dev/null
> @@ -1,26 +0,0 @@
> -! { dg-do compile }
> -! { dg-options "-fdiagnostics-format=json" }
> -
> -#warning message
> -
> -#if 0
> -{ dg-begin-multiline-output "" }
> -[{"kind": "warning",
> -  "message": "#warning message",
> -  "option": "-Wcpp",
> -  "option_url":
> -  "children": [],
> -  "column-origin": 1,
> -  "locations": [{"caret": {"file":
> -                           "line": 4,
> -                           "display-column": 2,
> -                           "byte-column": 2,
> -                           "column": 2},
> -                 "finish": {"file":
> -                            "line": 4,
> -                            "display-column": 8,
> -                            "byte-column": 8,
> -                            "column": 8}}],
> -  "escape-source": false}]
> -{ dg-end-multiline-output "" }
> -#endif  
> diff --git a/gcc/testsuite/gfortran.dg/diagnostic-format-json-3.F90
> b/gcc/testsuite/gfortran.dg/diagnostic-format-json-3.F90
> deleted file mode 100644
> index 750e186c8acf..000000000000
> --- a/gcc/testsuite/gfortran.dg/diagnostic-format-json-3.F90
> +++ /dev/null
> @@ -1,26 +0,0 @@
> -! { dg-do compile }
> -! { dg-options "-fdiagnostics-format=json -Werror" }
> -
> -#warning message
> -
> -#if 0
> -{ dg-begin-multiline-output "" }
> -[{"kind": "error",
> -  "message": "#warning message",
> -  "option": "-Werror=cpp",
> -  "option_url":
> -  "children": [],
> -  "column-origin": 1,
> -  "locations": [{"caret": {"file":
> -                           "line": 4,
> -                           "display-column": 2,
> -                           "byte-column": 2,
> -                           "column": 2},
> -                 "finish": {"file":
> -                            "line": 4,
> -                            "display-column": 8,
> -                            "byte-column": 8,
> -                            "column": 8}}],
> -  "escape-source": false}]
> -{ dg-end-multiline-output "" }
> -#endif  
> diff --git a/gcc/testsuite/gfortran.dg/diagnostic-format-json-
> pr105916.F90 b/gcc/testsuite/gfortran.dg/diagnostic-format-json-
> pr105916.F90
> deleted file mode 100644
> index bf22a86867bc..000000000000
> --- a/gcc/testsuite/gfortran.dg/diagnostic-format-json-pr105916.F90
> +++ /dev/null
> @@ -1,14 +0,0 @@
> -! { dg-do compile }
> -! { dg-options "-fdiagnostics-format=json-stderr -fmax-errors=1 -
> Wfatal-errors" }
> -
> -program main
> -    implicit none
> -    print*, "Hello World!"
> -end program main
> -
> -! We expect an empty array as the JSON output.
> -#if 0
> -{ dg-begin-multiline-output "" }
> -[]
> -{ dg-end-multiline-output "" }
> -#endif  


Reply via email to