2026-06-06 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.
--- gcc/cp/call.cc.jj 2026-05-30 17:45:09.361110077 +0200
+++ gcc/cp/call.cc 2026-06-05 22:27:22.964514731 +0200
@@ -8370,9 +8370,9 @@ build_op_delete_call_1 (enum tree_code c
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 d
}
/* 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
{
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
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 *can
{
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 l
const char *suggest = "";
bool warned = false;
+ auto_diagnostic_group d;
switch (DECL_FUNCTION_CODE (fndecl))
{
case BUILT_IN_MEMSET:
--- gcc/cp/constexpr.cc.jj 2026-06-05 10:39:31.000000000 +0200
+++ gcc/cp/constexpr.cc 2026-06-05 22:36:44.656093857 +0200
@@ -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
{
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
{
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");
--- gcc/cp/contracts.cc.jj 2026-05-30 17:45:09.363110052 +0200
+++ gcc/cp/contracts.cc 2026-06-05 22:40:10.350376299 +0200
@@ -560,6 +560,7 @@ check_param_in_postcondition (tree decl,
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 old
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 old
&& !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");
}
}
}
--- gcc/cp/decl.cc.jj 2026-06-05 17:13:02.743085568 +0200
+++ gcc/cp/decl.cc 2026-06-05 22:50:38.174104741 +0200
@@ -4197,6 +4197,7 @@ identify_goto (tree decl, location_t loc
{
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 d
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 d
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);
--- gcc/cp/method.cc.jj 2026-05-30 17:45:09.368109989 +0200
+++ gcc/cp/method.cc 2026-06-05 22:56:23.731557075 +0200
@@ -2777,6 +2777,7 @@ walk_field_subobs (tree fields, special_
{
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_
{
if (diag)
{
+ auto_diagnostic_group d;
error ("uninitialized reference member in %q#T",
current_class_type);
inform (DECL_SOURCE_LOCATION (field),
--- gcc/cp/semantics.cc.jj 2026-05-30 17:45:09.379109850 +0200
+++ gcc/cp/semantics.cc 2026-06-05 23:04:22.026265134 +0200
@@ -10676,6 +10676,7 @@ finish_omp_clauses (tree clauses, enum c
&& (!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");
--- gcc/cp/tree.cc.jj 2026-06-04 08:24:37.615028520 +0200
+++ gcc/cp/tree.cc 2026-06-05 23:06:23.184672012 +0200
@@ -6060,6 +6060,7 @@ validate_trivial_abi_attribute (tree typ
/* 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 typ
/* 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 typ
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 typ
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 typ
/* 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,
--- gcc/cp/typeck2.cc.jj 2026-05-30 09:43:35.000000000 +0200
+++ gcc/cp/typeck2.cc 2026-06-05 23:07:32.538760068 +0200
@@ -1476,6 +1476,7 @@ digest_init_r (tree type, tree init, int
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");
Jakub