https://gcc.gnu.org/g:d7d0ea918fad92aa6403b3d6998e81b45bc93ba5

commit r16-3089-gd7d0ea918fad92aa6403b3d6998e81b45bc93ba5
Author: David Malcolm <dmalc...@redhat.com>
Date:   Fri Aug 8 16:55:44 2025 -0400

    diagnostics: update signature of some callbacks
    
    No functional change intended.
    
    gcc/cp/ChangeLog:
            * error.cc (cp_adjust_diagnostic_info): Convert "context" arg from
            ptr to const &.
    
    gcc/ChangeLog:
            * diagnostics/context.cc (context::get_any_inlining_info): Convert
            "context" arg of m_set_locations_cb from ptr to const &.
            (context::report_diagnostic): Convert "context" arg of
            m_adjust_diagnostic_info from ptr to const &.
            * diagnostics/context.h (context::set_locations_callback_t):
            Likewise.
            (context::set_adjust_diagnostic_info_callback): Likewise.
            (context::m_adjust_diagnostic_info): Likewise.
            * tree-diagnostic.cc (set_inlining_locations): Likewise.
    
    Signed-off-by: David Malcolm <dmalc...@redhat.com>

Diff:
---
 gcc/cp/error.cc            | 4 ++--
 gcc/diagnostics/context.cc | 4 ++--
 gcc/diagnostics/context.h  | 6 +++---
 gcc/tree-diagnostic.cc     | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index c427163d2834..cd35c7ae0415 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -250,7 +250,7 @@ erroneous_templates_t *erroneous_templates;
    issue an error if we later need to instantiate the template.  */
 
 static void
-cp_adjust_diagnostic_info (diagnostics::context *context,
+cp_adjust_diagnostic_info (const diagnostics::context &context,
                           diagnostics::diagnostic_info *diagnostic)
 {
   if (diagnostic->m_kind == diagnostics::kind::error)
@@ -258,7 +258,7 @@ cp_adjust_diagnostic_info (diagnostics::context *context,
       {
        diagnostic->m_option_id = OPT_Wtemplate_body;
 
-       if (context->m_permissive)
+       if (context.m_permissive)
          diagnostic->m_kind = diagnostics::kind::warning;
 
        bool existed;
diff --git a/gcc/diagnostics/context.cc b/gcc/diagnostics/context.cc
index b05e07879428..a8ccbf60ded2 100644
--- a/gcc/diagnostics/context.cc
+++ b/gcc/diagnostics/context.cc
@@ -1108,7 +1108,7 @@ context::get_any_inlining_info (diagnostic_info 
*diagnostic)
     /* Retrieve the locations into which the expression about to be
        diagnosed has been inlined, including those of all the callers
        all the way down the inlining stack.  */
-    m_set_locations_cb (this, diagnostic);
+    m_set_locations_cb (*this, diagnostic);
   else
     {
       /* When there's no callback use just the one location provided
@@ -1259,7 +1259,7 @@ context::report_diagnostic (diagnostic_info *diagnostic)
     }
 
   if (m_adjust_diagnostic_info)
-    m_adjust_diagnostic_info (this, diagnostic);
+    m_adjust_diagnostic_info (*this, diagnostic);
 
   if (diagnostic->m_kind == kind::pedwarn)
     {
diff --git a/gcc/diagnostics/context.h b/gcc/diagnostics/context.h
index 961a87299e8a..df44a9b0212e 100644
--- a/gcc/diagnostics/context.h
+++ b/gcc/diagnostics/context.h
@@ -264,7 +264,7 @@ public:
   friend class text_sink;
   friend class buffer;
 
-  typedef void (*set_locations_callback_t) (context *,
+  typedef void (*set_locations_callback_t) (const context &,
                                            diagnostic_info *);
 
   void initialize (int n_opts);
@@ -571,7 +571,7 @@ public:
   }
 
   void
-  set_adjust_diagnostic_info_callback (void (*cb) (context *,
+  set_adjust_diagnostic_info_callback (void (*cb) (const context &,
                                                   diagnostic_info *))
   {
     m_adjust_diagnostic_info = cb;
@@ -710,7 +710,7 @@ private:
 
   /* Client hook to adjust properties of the given diagnostic that we're
      about to issue, such as its kind.  */
-  void (*m_adjust_diagnostic_info)(context *, diagnostic_info *);
+  void (*m_adjust_diagnostic_info)(const context &, diagnostic_info *);
 
   /* Owned by the context; this would be a std::unique_ptr if
      context had a proper ctor.  */
diff --git a/gcc/tree-diagnostic.cc b/gcc/tree-diagnostic.cc
index 3761fc099e60..20183c8bceda 100644
--- a/gcc/tree-diagnostic.cc
+++ b/gcc/tree-diagnostic.cc
@@ -110,7 +110,7 @@ default_tree_printer (pretty_printer *pp, text_info *text, 
const char *spec,
    to the DIAGNOSTIC location.  */
 
 static void
-set_inlining_locations (diagnostics::context *,
+set_inlining_locations (const diagnostics::context &,
                        diagnostics::diagnostic_info *diagnostic)
 {
   location_t loc = diagnostic_location (diagnostic);

Reply via email to