https://gcc.gnu.org/g:59103a9ec2a5f0168fb8ba3d08421fac6d111eaa

commit r17-1431-g59103a9ec2a5f0168fb8ba3d08421fac6d111eaa
Author: Jakub Jelinek <[email protected]>
Date:   Mon Jun 8 21:38:17 2026 +0200

    c++: Add various missing auto_diagnostic_group sentinels
    
    I've grepped for inform with larger grep context and looked for missing
    auto_diagnostic_group if the inform was preceded by some related diagnostic
    function (or call which emits that).
    
    2026-06-08  Jakub Jelinek  <[email protected]>
    
            * call.cc (build_op_delete_call_1): Add missing 
auto_diagnostic_group
            sentinel.  Formatting fix.
            (complain_about_access): Add missing auto_diagnostic_group 
sentinels.
            (convert_like_internal): Likewise.
            (build_over_call): Likewise.
            (maybe_warn_class_memaccess): Likewise.
            * constexpr.cc (maybe_warn_about_constant_value): Likewise.
            (cxx_eval_outermost_constant_expr): Likewise.
            * contracts.cc (check_param_in_postcondition): Likewise.
            (check_postconditions_in_redecl): Likewise.  Formatting fixes.
            * decl.cc (identify_goto): Add missing auto_diagnostic_group
            sentinels.
            (omp_declare_variant_finalize_one): Likewise.
            * method.cc (walk_field_subobs): Likewise.
            * semantics.cc (finish_omp_clauses): Likewise.
            * tree.cc (validate_trivial_abi_attribute): Likewise.
            * typeck2.cc (digest_init_r): Likewise.
    
    Reviewed-by: Jason Merrill <[email protected]>

Diff:
---
 gcc/cp/call.cc      | 9 +++++++--
 gcc/cp/constexpr.cc | 3 +++
 gcc/cp/contracts.cc | 9 ++++++---
 gcc/cp/decl.cc      | 3 +++
 gcc/cp/method.cc    | 2 ++
 gcc/cp/semantics.cc | 1 +
 gcc/cp/tree.cc      | 5 +++++
 gcc/cp/typeck2.cc   | 1 +
 8 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 25fe58ffe64c..a071596085ad 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -8370,9 +8370,9 @@ build_op_delete_call_1 (enum tree_code code, tree addr, 
tree size,
      be freed.  */
   if (alloc_fn)
     {
-      if ((complain & tf_warning)
-         && !placement)
+      if ((complain & tf_warning) && !placement)
        {
+         auto_diagnostic_group d;
          bool w = warning (0,
                            "no corresponding deallocation function for %qD",
                            alloc_fn);
@@ -8440,6 +8440,7 @@ complain_about_access (tree decl, tree diag_decl, tree 
diag_location,
     }
 
   /* Now generate an error message depending on calculated access.  */
+  auto_diagnostic_group d;
   if (no_access_reason == ak_private)
     {
       if (issue_error)
@@ -8737,6 +8738,7 @@ convert_like_internal (conversion *convs, tree expr, tree 
fn, int argnum,
     {
       int complained = 0;
       conversion *t = convs;
+      auto_diagnostic_group d;
 
       /* Give a helpful error if this is bad because of excess braces.  */
       if (BRACE_ENCLOSED_INITIALIZER_P (expr)
@@ -8979,6 +8981,7 @@ convert_like_internal (conversion *convs, tree expr, tree 
fn, int argnum,
       if (complain & tf_error)
        {
          /* Call build_user_type_conversion again for the error.  */
+         auto_diagnostic_group d;
          int flags = (convs->need_temporary_p
                       ? LOOKUP_IMPLICIT : LOOKUP_NORMAL);
          build_user_type_conversion (totype, convs->u.expr, flags, complain);
@@ -10848,6 +10851,7 @@ build_over_call (struct z_candidate *cand, int flags, 
tsubst_flags_t complain)
        {
          if (complain & tf_error)
            {
+             auto_diagnostic_group d;
              sorry ("passing arguments to ellipsis of inherited constructor "
                     "%qD", cand->fn);
              inform (DECL_SOURCE_LOCATION (cand->fn), "declared here");
@@ -11346,6 +11350,7 @@ maybe_warn_class_memaccess (location_t loc, tree fndecl,
   const char *suggest = "";
   bool warned = false;
 
+  auto_diagnostic_group d;
   switch (DECL_FUNCTION_CODE (fndecl))
     {
     case BUILT_IN_MEMSET:
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 88947bbb7850..8b9392b461bf 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -9035,6 +9035,7 @@ static void
 maybe_warn_about_constant_value (location_t loc, tree decl)
 {
   static bool explained = false;
+  auto_diagnostic_group d;
   if (cxx_dialect >= cxx17
       && warn_interference_size
       && !OPTION_SET_P (param_destruct_interfere_size)
@@ -11103,6 +11104,7 @@ cxx_eval_outermost_constant_expr (tree t, bool 
allow_non_constant,
        {
          if (!allow_non_constant && !non_constant_p)
            {
+             auto_diagnostic_group d;
              if (DECL_LANG_SPECIFIC (heap_var))
                error ("%qE is not a constant expression because it refers to "
                       "exception object allocated with "
@@ -11121,6 +11123,7 @@ cxx_eval_outermost_constant_expr (tree t, bool 
allow_non_constant,
            {
              if (!allow_non_constant && !non_constant_p)
                {
+                 auto_diagnostic_group d;
                  error ("%qE is not a constant expression because allocated "
                         "storage has not been deallocated", t);
                  inform (DECL_SOURCE_LOCATION (heap_var), "allocated here");
diff --git a/gcc/cp/contracts.cc b/gcc/cp/contracts.cc
index 112bd9daeefa..bc9f23ba4cfa 100644
--- a/gcc/cp/contracts.cc
+++ b/gcc/cp/contracts.cc
@@ -560,6 +560,7 @@ check_param_in_postcondition (tree decl, location_t 
location)
       if (!dependent_type_p (TREE_TYPE (decl))
          && !CP_TYPE_CONST_P (TREE_TYPE (decl)))
        {
+         auto_diagnostic_group d;
          error_at (location,
                    "a value parameter used in a postcondition must be const");
          inform (DECL_SOURCE_LOCATION (decl), "parameter declared here");
@@ -582,7 +583,7 @@ check_postconditions_in_redecl (tree olddecl, tree newdecl)
   tree t2 = FUNCTION_FIRST_USER_PARM (newdecl);
 
   for (; t1 && t1 != void_list_node;
-  t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
+       t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
     {
       if (parm_used_in_post_p (t1))
        {
@@ -591,10 +592,12 @@ check_postconditions_in_redecl (tree olddecl, tree 
newdecl)
              && !CP_TYPE_CONST_P (TREE_TYPE (t2))
              && !TREE_READONLY (t2))
            {
+             auto_diagnostic_group d;
              error_at (DECL_SOURCE_LOCATION (t2),
-             "value parameter %qE used in a postcondition must be const", t2);
+                       "value parameter %qE used in a postcondition must be "
+                       "const", t2);
              inform (DECL_SOURCE_LOCATION (olddecl),
-             "previous declaration here");
+                     "previous declaration here");
            }
        }
     }
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 84aa9a72fabf..bec89effd4f9 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -4197,6 +4197,7 @@ identify_goto (tree decl, location_t loc, const 
location_t *locus,
 {
   if (computed)
     diag_kind = diagnostics::kind::warning;
+  auto_diagnostic_group d;
   bool complained
     = emit_diagnostic (diag_kind, loc, 0,
                       decl ? G_("jump to label %qD")
@@ -9171,6 +9172,7 @@ omp_declare_variant_finalize_one (tree decl, tree attr)
                  loc = EXPR_LOC_OR_LOC (variant,
                                         DECL_SOURCE_LOCATION (variant));
                }
+             auto_diagnostic_group d;
              error_at (loc, "argument %d of %qE must be of %<omp_interop_t%>",
                        args->length () + 1, variant);
              inform (EXPR_LOCATION (TREE_PURPOSE (append_args_list)),
@@ -9308,6 +9310,7 @@ omp_declare_variant_finalize_one (tree decl, tree attr)
                 i++, varg = TREE_CHAIN (varg))
              if (!varg || !c_omp_interop_t_p (TREE_VALUE (varg)))
                {
+                 auto_diagnostic_group d;
                  error_at (DECL_SOURCE_LOCATION (variant),
                            "argument %d of %qD must be of %<omp_interop_t%>",
                            nbase_args + i + 1, variant);
diff --git a/gcc/cp/method.cc b/gcc/cp/method.cc
index ebc5bef5ceea..c511ea9a0642 100644
--- a/gcc/cp/method.cc
+++ b/gcc/cp/method.cc
@@ -2777,6 +2777,7 @@ walk_field_subobs (tree fields, special_function_kind 
sfk, tree fnname,
            {
              if (diag)
                {
+                 auto_diagnostic_group d;
                  error ("uninitialized const member in %q#T",
                         current_class_type);
                  inform (DECL_SOURCE_LOCATION (field),
@@ -2788,6 +2789,7 @@ walk_field_subobs (tree fields, special_function_kind 
sfk, tree fnname,
            {
              if (diag)
                {
+                 auto_diagnostic_group d;
                  error ("uninitialized reference member in %q#T",
                         current_class_type);
                  inform (DECL_SOURCE_LOCATION (field),
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index 42278d336bf0..5610fd6b678f 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -10678,6 +10678,7 @@ finish_omp_clauses (tree clauses, enum 
c_omp_region_type ort)
       && (!init_use_destroy_seen
          || (init_seen && init_no_targetsync_clause)))
     {
+      auto_diagnostic_group d;
       error_at (OMP_CLAUSE_LOCATION (depend_clause),
                "%<depend%> clause requires action clauses with "
                "%<targetsync%> interop-type");
diff --git a/gcc/cp/tree.cc b/gcc/cp/tree.cc
index 360eae876985..c9b299007467 100644
--- a/gcc/cp/tree.cc
+++ b/gcc/cp/tree.cc
@@ -6060,6 +6060,7 @@ validate_trivial_abi_attribute (tree type)
   /* Check for virtual bases.  */
   if (CLASSTYPE_VBASECLASSES (type))
     {
+      auto_diagnostic_group d;
       if (warning (OPT_Wattributes, "%<trivial_abi%> cannot be applied to %qT",
                   type))
        inform (input_location, "has a virtual base");
@@ -6071,6 +6072,7 @@ validate_trivial_abi_attribute (tree type)
   /* Check for virtual member functions.  */
   if (TYPE_POLYMORPHIC_P (type))
     {
+      auto_diagnostic_group d;
       if (warning (OPT_Wattributes, "%<trivial_abi%> cannot be applied to %qT",
                   type))
        inform (input_location, "is polymorphic");
@@ -6090,6 +6092,7 @@ validate_trivial_abi_attribute (tree type)
 
          if (TREE_ADDRESSABLE (base_type))
            {
+             auto_diagnostic_group d;
              if (warning (OPT_Wattributes,
                           "%<trivial_abi%> cannot be applied to %qT", type))
                inform (input_location, "has a non-trivial base class %qT",
@@ -6110,6 +6113,7 @@ validate_trivial_abi_attribute (tree type)
 
          if (CLASS_TYPE_P (field_type) && TREE_ADDRESSABLE (field_type))
            {
+             auto_diagnostic_group d;
              if (warning (OPT_Wattributes,
                           "%<trivial_abi%> cannot be applied to %qT", type))
                inform (input_location, "has a non-static data member "
@@ -6124,6 +6128,7 @@ validate_trivial_abi_attribute (tree type)
   /* Check that not all copy/move constructors are deleted.  */
   if (!classtype_has_non_deleted_copy_or_move_ctor (type))
     {
+      auto_diagnostic_group d;
       if (warning (OPT_Wattributes, "%<trivial_abi%> cannot be applied to %qT",
                   type))
        inform (input_location,
diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index 664dd0990bf8..12c34ba6b3a7 100644
--- a/gcc/cp/typeck2.cc
+++ b/gcc/cp/typeck2.cc
@@ -1476,6 +1476,7 @@ digest_init_r (tree type, tree init, int nested, int 
flags,
          tree field = next_aggregate_field (TYPE_FIELDS (type));
          if (field && DECL_FIELD_IS_BASE (field))
            {
+             auto_diagnostic_group d;
              if (warning_at (loc, 0, "initializing a base class of type %qT "
                              "results in object slicing", TREE_TYPE (field)))
                inform (loc, "remove %<{ }%> around initializer");

Reply via email to