]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Add various missing auto_diagnostic_group sentinels
authorJakub Jelinek <jakub@redhat.com>
Mon, 8 Jun 2026 19:38:17 +0000 (21:38 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 8 Jun 2026 19:38:17 +0000 (21:38 +0200)
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  <jakub@redhat.com>

* 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 <jason@redhat.com>
gcc/cp/call.cc
gcc/cp/constexpr.cc
gcc/cp/contracts.cc
gcc/cp/decl.cc
gcc/cp/method.cc
gcc/cp/semantics.cc
gcc/cp/tree.cc
gcc/cp/typeck2.cc

index 25fe58ffe64c1c96678d2a33bfbfa8b612c25704..a071596085ad2c5cb18aba6eeeb2f0904c9f7f5a 100644 (file)
@@ -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:
index 88947bbb7850eae7dae0bc655d8ad09f41824ad7..8b9392b461bfbd923e1abeefd1312341bc95ec0e 100644 (file)
@@ -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");
index 112bd9daeefa9d51d4a6f82db6ae2134043126e7..bc9f23ba4cfa5029a14b06301fdcf98198831517 100644 (file)
@@ -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");
            }
        }
     }
index 84aa9a72fabf424c0d535829fadca4ceaa5f3142..bec89effd4f965a297ede9fa3cfef56aa3bfacd7 100644 (file)
@@ -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);
index ebc5bef5ceea4c200f6c254e22005b164a395ab2..c511ea9a06428151a655583f7d90d561fc88967b 100644 (file)
@@ -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),
index 42278d336bf06d4d6360e948e8cd6d8e6fdc15b9..5610fd6b678f2be0c74bdadbc8968fe1f283cabe 100644 (file)
@@ -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");
index 360eae8769857fdc880a47d3298093b16ded82e1..c9b299007467c8e0ba166968369c049ed5116401 100644 (file)
@@ -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,
index 664dd0990bf8981a5c868c6ccb533209199d6660..12c34ba6b3a7f2fb2eb70c2a881aee941952cf7b 100644 (file)
@@ -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");