https://gcc.gnu.org/g:0c0cb2f00c0e9e9d46059561c3ae8c0cc12be41b
commit r16-2533-g0c0cb2f00c0e9e9d46059561c3ae8c0cc12be41b Author: David Malcolm <dmalc...@redhat.com> Date: Fri Jul 25 15:13:38 2025 -0400 diagnostics: move diagnostic_info to its own header No functional change intended. gcc/ChangeLog: * diagnostic.h (struct diagnostic_info): Move to diagnostics/diagnostic-info.h as diagnostics::diagnostic_info. Add typedef bringing it back into root namespace, for now. * diagnostics/diagnostic-info.h: New file, based on the above. * langhooks-def.h: Update for diagnostic_info moving into namespace diagnostics. * langhooks.h: Likewise. gcc/jit/ChangeLog: * jit-playback.cc: Update for diagnostic_info moving into namespace diagnostics. * jit-playback.h: Likewise. Signed-off-by: David Malcolm <dmalc...@redhat.com> Diff: --- gcc/diagnostic.h | 46 ++---------------------- gcc/diagnostics/diagnostic-info.h | 75 +++++++++++++++++++++++++++++++++++++++ gcc/jit/jit-playback.cc | 2 +- gcc/jit/jit-playback.h | 4 +-- gcc/langhooks-def.h | 4 +-- gcc/langhooks.h | 4 +-- 6 files changed, 84 insertions(+), 51 deletions(-) diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 3bf51aab7ce5..4388655e83d7 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -152,50 +152,8 @@ enum diagnostic_text_art_charset DIAGNOSTICS_TEXT_ART_CHARSET_EMOJI }; -/* A diagnostic is described by the MESSAGE to send, the FILE and LINE of - its context and its KIND (ice, error, warning, note, ...) See complete - list in diagnostic.def. */ -struct diagnostic_info -{ - diagnostic_info () - : m_message (), - m_richloc (), - m_metadata (), - m_x_data (), - m_kind (), - m_option_id (), - m_iinfo () - { } - - /* Text to be formatted. */ - text_info m_message; - - /* The location at which the diagnostic is to be reported. */ - rich_location *m_richloc; - - /* An optional bundle of metadata associated with the diagnostic - (or NULL). */ - const diagnostics::metadata *m_metadata; - - /* Auxiliary data for client. */ - void *m_x_data; - /* The kind of diagnostic it is about. */ - diagnostic_t m_kind; - /* Which OPT_* directly controls this diagnostic. */ - diagnostic_option_id m_option_id; - - /* Inlining context containing locations for each call site along - the inlining stack. */ - struct inlining_info - { - /* Locations along the inlining stack. */ - auto_vec<location_t, 8> m_ilocs; - /* The abstract origin of the location. */ - void *m_ao; - /* Set if every M_ILOCS element is in a system header. */ - bool m_allsyslocs; - } m_iinfo; -}; +#include "diagnostics/diagnostic-info.h" +typedef diagnostics::diagnostic_info diagnostic_info; /* Forward declarations. */ class diagnostic_location_print_policy; diff --git a/gcc/diagnostics/diagnostic-info.h b/gcc/diagnostics/diagnostic-info.h new file mode 100644 index 000000000000..f8107b1b2029 --- /dev/null +++ b/gcc/diagnostics/diagnostic-info.h @@ -0,0 +1,75 @@ +/* Various declarations for language-independent diagnostics subroutines. + Copyright (C) 2000-2025 Free Software Foundation, Inc. + +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/>. */ + +#ifndef GCC_DIAGNOSTICS_DIAGNOSTIC_INFO_H +#define GCC_DIAGNOSTICS_DIAGNOSTIC_INFO_H + +namespace diagnostics { + +class metadata; + +/* A diagnostic is described by the MESSAGE to send, the FILE and LINE of + its context and its KIND (ice, error, warning, note, ...) See complete + list in diagnostic.def. */ + +struct diagnostic_info +{ + diagnostic_info () + : m_message (), + m_richloc (), + m_metadata (), + m_x_data (), + m_kind (), + m_option_id (), + m_iinfo () + { } + + /* Text to be formatted. */ + text_info m_message; + + /* The location at which the diagnostic is to be reported. */ + rich_location *m_richloc; + + /* An optional bundle of metadata associated with the diagnostic + (or NULL). */ + const metadata *m_metadata; + + /* Auxiliary data for client. */ + void *m_x_data; + /* The kind of diagnostic it is about. */ + diagnostic_t m_kind; + /* Which OPT_* directly controls this diagnostic. */ + diagnostic_option_id m_option_id; + + /* Inlining context containing locations for each call site along + the inlining stack. */ + struct inlining_info + { + /* Locations along the inlining stack. */ + auto_vec<location_t, 8> m_ilocs; + /* The abstract origin of the location. */ + void *m_ao; + /* Set if every M_ILOCS element is in a system header. */ + bool m_allsyslocs; + } m_iinfo; +}; + +} // namespace diagnostics + +#endif /* ! GCC_DIAGNOSTICS_DIAGNOSTIC_INFO_H */ diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc index 6946f100d5cc..4473d8b55521 100644 --- a/gcc/jit/jit-playback.cc +++ b/gcc/jit/jit-playback.cc @@ -3892,7 +3892,7 @@ add_error_va (location *loc, const char *fmt, va_list ap) void playback::context:: add_diagnostic (const char *text, - const diagnostic_info &diagnostic) + const diagnostics::diagnostic_info &diagnostic) { /* Get location information (if any) from the diagnostic. The recording::context::add_error[_va] methods require a diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h index e9a5c381959b..1d11502747b5 100644 --- a/gcc/jit/jit-playback.h +++ b/gcc/jit/jit-playback.h @@ -31,7 +31,7 @@ along with GCC; see the file COPYING3. If not see #include "jit-recording.h" class diagnostic_context; -struct diagnostic_info; +namespace diagnostics { struct diagnostic_info; } namespace gcc { @@ -298,7 +298,7 @@ public: void add_diagnostic (const char *text, - const diagnostic_info &diagnostic); + const diagnostics::diagnostic_info &diagnostic); void set_tree_location (tree t, location *loc); diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index e03f00aa0302..c8a7a62648e7 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -23,7 +23,7 @@ along with GCC; see the file COPYING3. If not see #include "hooks.h" -struct diagnostic_info; +namespace diagnostics { struct diagnostic_info; } class substring_loc; /* Note to creators of new hooks: @@ -51,7 +51,7 @@ extern const char *lhd_dwarf_name (tree, int); extern int lhd_types_compatible_p (tree, tree); extern void lhd_print_error_function (diagnostics::text_sink &, const char *, - const struct diagnostic_info *); + const diagnostics::diagnostic_info *); extern void lhd_set_decl_assembler_name (tree decl); extern void lhd_overwrite_decl_assembler_name (tree decl, tree name); extern bool lhd_warn_unused_global_decl (const_tree); diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 7433170e997d..93df485d35f0 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see /* FIXME: This file should be #include-d after tree.h (for enum tree_code). */ -struct diagnostic_info; +namespace diagnostics { struct diagnostic_info; } struct gimplify_omp_ctx; @@ -549,7 +549,7 @@ struct lang_hooks for textual diagnostic output. */ void (*print_error_function) (diagnostics::text_sink &, const char *, - const struct diagnostic_info *); + const diagnostics::diagnostic_info *); /* Convert a character from the host's to the target's character set. The character should be in what C calls the "basic source