From 55d04cb2f237275d981e6f48452901cdc1e8141a Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Thu, 17 Jul 2025 15:07:26 -0400
Subject: [PATCH 31/41] {needs ChangeLog} move gcc/selftest-diagnostic.{h,cc}
 -> gcc/diagnostics/selftest-context.{h,cc}

---
 gcc/Makefile.in                                             | 3 ++-
 gcc/c-family/c-format.cc                                    | 2 +-
 gcc/cobol/util.cc                                           | 6 ------
 gcc/diagnostic.cc                                           | 2 +-
 gcc/diagnostics/html-sink.cc                                | 2 +-
 gcc/diagnostics/lazy-paths.cc                               | 2 +-
 gcc/diagnostics/output-spec.cc                              | 2 +-
 gcc/diagnostics/paths-output.cc                             | 2 +-
 gcc/diagnostics/sarif-sink.cc                               | 2 +-
 .../selftest-context.cc}                                    | 2 +-
 .../selftest-context.h}                                     | 6 +++---
 gcc/diagnostics/source-printing.cc                          | 2 +-
 gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.cc   | 2 +-
 13 files changed, 15 insertions(+), 20 deletions(-)
 rename gcc/{selftest-diagnostic.cc => diagnostics/selftest-context.cc} (98%)
 rename gcc/{selftest-diagnostic.h => diagnostics/selftest-context.h} (93%)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index e743c94c97c4..f1f71733cbc6 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1867,6 +1867,7 @@ OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \
 	diagnostics/source-printing.o \
 	diagnostics/state-graphs.o \
 	diagnostics/state-graphs-to-dot.o \
+	diagnostics/selftest-context.o \
 	diagnostics/selftest-logical-locations.o \
 	diagnostics/selftest-paths.o \
 	graphviz.o pex.o \
@@ -1875,7 +1876,7 @@ OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \
 	xml.o \
 	sbitmap.o \
 	vec.o input.o hash-table.o ggc-none.o memory-block.o \
-	selftest.o selftest-diagnostic.o sort.o \
+	selftest.o sort.o \
 	selftest-json.o \
 	text-art/box-drawing.o \
 	text-art/canvas.o \
diff --git a/gcc/c-family/c-format.cc b/gcc/c-family/c-format.cc
index a44249a02227..8fd32d40ea89 100644
--- a/gcc/c-family/c-format.cc
+++ b/gcc/c-family/c-format.cc
@@ -32,7 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "substring-locations.h"
 #include "selftest.h"
-#include "selftest-diagnostic.h"
+#include "diagnostics/selftest-context.h"
 #include "builtins.h"
 #include "attribs.h"
 #include "c-family/c-type-mismatch.h"
diff --git a/gcc/cobol/util.cc b/gcc/cobol/util.cc
index 67a2bfa6a196..8bf0d002de27 100644
--- a/gcc/cobol/util.cc
+++ b/gcc/cobol/util.cc
@@ -48,12 +48,6 @@
 #include "backtrace.h"
 #include "diagnostic.h"
 #include "diagnostic-color.h"
-#include "diagnostic-url.h"
-#include "diagnostics/metadata.h"
-#include "diagnostics/paths.h"
-#include "diagnostics/edit-context.h"
-#include "selftest.h"
-#include "selftest-diagnostic.h"
 #include "opts.h"
 #include "util.h"
 #include "cbldiag.h"
diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index ea606e34d2da..4d1b253bbe93 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -42,7 +42,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostics/text-sink.h"
 #include "diagnostics/edit-context.h"
 #include "selftest.h"
-#include "selftest-diagnostic.h"
+#include "diagnostics/selftest-context.h"
 #include "opts.h"
 #include "cpplib.h"
 #include "text-art/theme.h"
diff --git a/gcc/diagnostics/html-sink.cc b/gcc/diagnostics/html-sink.cc
index 0785046b5ae5..260f756edfa8 100644
--- a/gcc/diagnostics/html-sink.cc
+++ b/gcc/diagnostics/html-sink.cc
@@ -35,7 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostics/paths.h"
 #include "diagnostics/client-data-hooks.h"
 #include "selftest.h"
-#include "selftest-diagnostic.h"
+#include "diagnostics/selftest-context.h"
 #include "pretty-print-format-impl.h"
 #include "pretty-print-urlifier.h"
 #include "diagnostics/edit-context.h"
diff --git a/gcc/diagnostics/lazy-paths.cc b/gcc/diagnostics/lazy-paths.cc
index c30386f0b174..322ad786d114 100644
--- a/gcc/diagnostics/lazy-paths.cc
+++ b/gcc/diagnostics/lazy-paths.cc
@@ -29,7 +29,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "diagnostics/lazy-paths.h"
 #include "selftest.h"
-#include "selftest-diagnostic.h"
+#include "diagnostics/selftest-context.h"
 #include "simple-diagnostic-path.h"
 #include "gcc-rich-location.h"
 #include "diagnostics/text-sink.h"
diff --git a/gcc/diagnostics/output-spec.cc b/gcc/diagnostics/output-spec.cc
index ecfa8e7ca610..699b5ac3bae7 100644
--- a/gcc/diagnostics/output-spec.cc
+++ b/gcc/diagnostics/output-spec.cc
@@ -38,7 +38,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostics/text-sink.h"
 #include "diagnostics/sarif-sink.h"
 #include "selftest.h"
-#include "selftest-diagnostic.h"
+#include "diagnostics/selftest-context.h"
 #include "pretty-print-markup.h"
 #include "diagnostics/output-spec.h"
 
diff --git a/gcc/diagnostics/paths-output.cc b/gcc/diagnostics/paths-output.cc
index c409cce14cc8..1815223ee020 100644
--- a/gcc/diagnostics/paths-output.cc
+++ b/gcc/diagnostics/paths-output.cc
@@ -35,7 +35,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostics/source-printing-effects.h"
 #include "pretty-print-markup.h"
 #include "selftest.h"
-#include "selftest-diagnostic.h"
+#include "diagnostics/selftest-context.h"
 #include "diagnostics/selftest-paths.h"
 #include "text-art/theme.h"
 #include "diagnostics/text-sink.h"
diff --git a/gcc/diagnostics/sarif-sink.cc b/gcc/diagnostics/sarif-sink.cc
index 31b6cfe6c677..115351027b47 100644
--- a/gcc/diagnostics/sarif-sink.cc
+++ b/gcc/diagnostics/sarif-sink.cc
@@ -44,7 +44,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "ordered-hash-map.h"
 #include "sbitmap.h"
 #include "selftest.h"
-#include "selftest-diagnostic.h"
+#include "diagnostics/selftest-context.h"
 #include "diagnostics/selftest-source-printing.h"
 #include "selftest-json.h"
 #include "text-range-label.h"
diff --git a/gcc/selftest-diagnostic.cc b/gcc/diagnostics/selftest-context.cc
similarity index 98%
rename from gcc/selftest-diagnostic.cc
rename to gcc/diagnostics/selftest-context.cc
index 321949852384..918bd5e430b1 100644
--- a/gcc/selftest-diagnostic.cc
+++ b/gcc/diagnostics/selftest-context.cc
@@ -23,7 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic.h"
 #include "diagnostics/sink.h"
 #include "selftest.h"
-#include "selftest-diagnostic.h"
+#include "diagnostics/selftest-context.h"
 
 /* The selftest code should entirely disappear in a production
    configuration, hence we guard all of it with #if CHECKING_P.  */
diff --git a/gcc/selftest-diagnostic.h b/gcc/diagnostics/selftest-context.h
similarity index 93%
rename from gcc/selftest-diagnostic.h
rename to gcc/diagnostics/selftest-context.h
index 6a5216650f92..afbc6611ed77 100644
--- a/gcc/selftest-diagnostic.h
+++ b/gcc/diagnostics/selftest-context.h
@@ -17,8 +17,8 @@ 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/>.  */
 
-#ifndef GCC_SELFTEST_DIAGNOSTIC_H
-#define GCC_SELFTEST_DIAGNOSTIC_H
+#ifndef GCC_DIAGNOSTICS_SELFTEST_CONTEXT_H
+#define GCC_DIAGNOSTICS_SELFTEST_CONTEXT_H
 
 /* The selftest code should entirely disappear in a production
    configuration, hence we guard all of it with #if CHECKING_P.  */
@@ -60,4 +60,4 @@ class test_diagnostic_context : public diagnostics::context
 
 #endif /* #if CHECKING_P */
 
-#endif /* GCC_SELFTEST_DIAGNOSTIC_H */
+#endif /* GCC_DIAGNOSTICS_SELFTEST_CONTEXT_H */
diff --git a/gcc/diagnostics/source-printing.cc b/gcc/diagnostics/source-printing.cc
index bb36acae6e15..cd642b96370e 100644
--- a/gcc/diagnostics/source-printing.cc
+++ b/gcc/diagnostics/source-printing.cc
@@ -33,7 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gcc-rich-location.h"
 #include "text-range-label.h"
 #include "selftest.h"
-#include "selftest-diagnostic.h"
+#include "diagnostics/selftest-context.h"
 #include "diagnostics/selftest-source-printing.h"
 #include "cpplib.h"
 #include "text-art/types.h"
diff --git a/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.cc b/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.cc
index 8abed140ac9c..c6fe3016f896 100644
--- a/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.cc
+++ b/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.cc
@@ -8,7 +8,7 @@
 #include "diagnostic.h"
 #include "diagnostics/edit-context.h"
 #include "selftest.h"
-#include "selftest-diagnostic.h"
+#include "diagnostics/selftest-context.h"
 
 int plugin_is_GPL_compatible;
 
-- 
2.26.3

