public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1804] cp: add support for per-location warning groups.
@ 2021-06-25 1:32 Martin Sebor
0 siblings, 0 replies; only message in thread
From: Martin Sebor @ 2021-06-25 1:32 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:65870e75616ee4359d1c13b99be794e6a577bc65
commit r12-1804-g65870e75616ee4359d1c13b99be794e6a577bc65
Author: Martin Sebor <msebor@redhat.com>
Date: Thu Jun 24 17:29:34 2021 -0600
cp: add support for per-location warning groups.
gcc/cp/ChangeLog:
* call.c (build_over_call): Replace direct uses of TREE_NO_WARNING
with warning_suppressed_p, suppress_warning, and copy_no_warning, or
nothing if not necessary.
(set_up_extended_ref_temp): Same.
* class.c (layout_class_type): Same.
* constraint.cc (constraint_satisfaction_value): Same.
* coroutines.cc (finish_co_await_expr): Same.
(finish_co_yield_expr): Same.
(finish_co_return_stmt): Same.
(build_actor_fn): Same.
(coro_rewrite_function_body): Same.
(morph_fn_to_coro): Same.
* cp-gimplify.c (genericize_eh_spec_block): Same.
(gimplify_expr_stmt): Same.
(cp_genericize_r): Same.
(cp_fold): Same.
* cp-ubsan.c (cp_ubsan_instrument_vptr): Same.
* cvt.c (cp_fold_convert): Same.
(convert_to_void): Same.
* decl.c (wrapup_namespace_globals): Same.
(grokdeclarator): Same.
(finish_function): Same.
(require_deduced_type): Same.
* decl2.c (no_linkage_error): Same.
(c_parse_final_cleanups): Same.
* except.c (expand_end_catch_block): Same.
* init.c (build_new_1): Same.
(build_new): Same.
(build_vec_delete_1): Same.
(build_vec_init): Same.
(build_delete): Same.
* method.c (defaultable_fn_check): Same.
* parser.c (cp_parser_fold_expression): Same.
(cp_parser_primary_expression): Same.
* pt.c (push_tinst_level_loc): Same.
(tsubst_copy): Same.
(tsubst_omp_udr): Same.
(tsubst_copy_and_build): Same.
* rtti.c (build_if_nonnull): Same.
* semantics.c (maybe_convert_cond): Same.
(finish_return_stmt): Same.
(finish_parenthesized_expr): Same.
(cp_check_omp_declare_reduction): Same.
* tree.c (build_cplus_array_type): Same.
* typeck.c (build_ptrmemfunc_access_expr): Same.
(cp_build_indirect_ref_1): Same.
(cp_build_function_call_vec): Same.
(warn_for_null_address): Same.
(cp_build_binary_op): Same.
(unary_complex_lvalue): Same.
(cp_build_modify_expr): Same.
(build_x_modify_expr): Same.
(convert_for_assignment): Same.
Diff:
---
gcc/cp/call.c | 10 +++++-----
gcc/cp/class.c | 2 +-
gcc/cp/constraint.cc | 4 ++--
gcc/cp/coroutines.cc | 22 +++++++++++-----------
gcc/cp/cp-gimplify.c | 20 +++++++++++---------
gcc/cp/cp-ubsan.c | 2 +-
gcc/cp/cvt.c | 12 +++++-------
gcc/cp/decl.c | 15 ++++++---------
gcc/cp/decl2.c | 4 ++--
gcc/cp/except.c | 3 ++-
gcc/cp/init.c | 16 ++++++++--------
gcc/cp/method.c | 2 +-
gcc/cp/parser.c | 6 +++++-
gcc/cp/pt.c | 23 +++++++++++------------
gcc/cp/rtti.c | 4 ++--
gcc/cp/semantics.c | 17 +++++++++--------
gcc/cp/tree.c | 2 +-
gcc/cp/typeck.c | 27 ++++++++++++---------------
18 files changed, 95 insertions(+), 96 deletions(-)
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index aafc7acca24..e4df72ec1a3 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -9499,7 +9499,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
{
/* Avoid copying empty classes. */
val = build2 (COMPOUND_EXPR, type, arg, to);
- TREE_NO_WARNING (val) = 1;
+ suppress_warning (val, OPT_Wunused);
}
else if (tree_int_cst_equal (TYPE_SIZE (type), TYPE_SIZE (as_base)))
{
@@ -9530,7 +9530,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
build2 (MEM_REF, array_type, arg0, alias_set),
build2 (MEM_REF, array_type, arg, alias_set));
val = build2 (COMPOUND_EXPR, TREE_TYPE (to), t, to);
- TREE_NO_WARNING (val) = 1;
+ suppress_warning (val, OPT_Wunused);
}
cp_warn_deprecated_use (fn, complain);
@@ -9604,7 +9604,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
{
tree c = extract_call_expr (call);
if (TREE_CODE (c) == CALL_EXPR)
- TREE_NO_WARNING (c) = 1;
+ suppress_warning (c /* Suppress all warnings. */);
}
if (TREE_CODE (fn) == ADDR_EXPR)
{
@@ -12554,11 +12554,11 @@ set_up_extended_ref_temp (tree decl, tree expr, vec<tree, va_gc> **cleanups,
TREE_ADDRESSABLE (var) = 1;
if (TREE_CODE (decl) == FIELD_DECL
- && extra_warnings && !TREE_NO_WARNING (decl))
+ && extra_warnings && !warning_suppressed_p (decl))
{
warning (OPT_Wextra, "a temporary bound to %qD only persists "
"until the constructor exits", decl);
- TREE_NO_WARNING (decl) = true;
+ suppress_warning (decl);
}
/* Recursively extend temps in this initializer. */
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index b53a4dbdd4e..c89ffadcef8 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -6704,7 +6704,7 @@ layout_class_type (tree t, tree *virtuals_p)
laying out an Objective-C class. The ObjC ABI differs
from the C++ ABI, and so we do not want a warning
here. */
- && !TREE_NO_WARNING (field)
+ && !warning_suppressed_p (field, OPT_Wabi)
&& !last_field_was_bitfield
&& !integer_zerop (size_binop (TRUNC_MOD_EXPR,
DECL_FIELD_BIT_OFFSET (field),
diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 286332ba2a7..6df3ca6ce32 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -3290,14 +3290,14 @@ constraint_satisfaction_value (tree t, tree args, sat_info info)
else
r = satisfy_nondeclaration_constraints (t, args, info);
if (r == error_mark_node && info.quiet ()
- && !(DECL_P (t) && TREE_NO_WARNING (t)))
+ && !(DECL_P (t) && warning_suppressed_p (t)))
{
/* Replay the error noisily. */
sat_info noisy (tf_warning_or_error, info.in_decl);
constraint_satisfaction_value (t, args, noisy);
if (DECL_P (t) && !args)
/* Avoid giving these errors again. */
- TREE_NO_WARNING (t) = true;
+ suppress_warning (t);
}
return r;
}
diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index 1bf1931e7be..a1b0b31f497 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -1078,7 +1078,7 @@ finish_co_await_expr (location_t kw, tree expr)
is declared to return non-void (most likely). This is correct - we
synthesize the return for the ramp in the compiler. So suppress any
extraneous warnings during substitution. */
- TREE_NO_WARNING (current_function_decl) = true;
+ suppress_warning (current_function_decl, OPT_Wreturn_type);
/* If we don't know the promise type, we can't proceed, build the
co_await with the expression unchanged. */
@@ -1154,7 +1154,7 @@ finish_co_yield_expr (location_t kw, tree expr)
is declared to return non-void (most likely). This is correct - we
synthesize the return for the ramp in the compiler. So suppress any
extraneous warnings during substitution. */
- TREE_NO_WARNING (current_function_decl) = true;
+ suppress_warning (current_function_decl, OPT_Wreturn_type);
/* If we don't know the promise type, we can't proceed, build the
co_await with the expression unchanged. */
@@ -1235,7 +1235,7 @@ finish_co_return_stmt (location_t kw, tree expr)
is declared to return non-void (most likely). This is correct - we
synthesize the return for the ramp in the compiler. So suppress any
extraneous warnings during substitution. */
- TREE_NO_WARNING (current_function_decl) = true;
+ suppress_warning (current_function_decl, OPT_Wreturn_type);
if (processing_template_decl
&& check_for_bare_parameter_packs (expr))
@@ -1259,7 +1259,7 @@ finish_co_return_stmt (location_t kw, tree expr)
/* Suppress -Wreturn-type for co_return, we need to check indirectly
whether the promise type has a suitable return_void/return_value. */
- TREE_NO_WARNING (current_function_decl) = true;
+ suppress_warning (current_function_decl, OPT_Wreturn_type);
if (!processing_template_decl && warn_sequence_point)
verify_sequence_points (expr);
@@ -2458,7 +2458,7 @@ build_actor_fn (location_t loc, tree coro_frame_type, tree actor, tree fnbody,
/* done. */
r = build_stmt (loc, RETURN_EXPR, NULL);
- TREE_NO_WARNING (r) |= 1; /* We don't want a warning about this. */
+ suppress_warning (r); /* We don't want a warning about this. */
r = maybe_cleanup_point_expr_void (r);
add_stmt (r);
@@ -2467,7 +2467,7 @@ build_actor_fn (location_t loc, tree coro_frame_type, tree actor, tree fnbody,
add_stmt (r);
r = build_stmt (loc, RETURN_EXPR, NULL);
- TREE_NO_WARNING (r) |= 1; /* We don't want a warning about this. */
+ suppress_warning (r); /* We don't want a warning about this. */
r = maybe_cleanup_point_expr_void (r);
add_stmt (r);
@@ -4142,7 +4142,7 @@ coro_rewrite_function_body (location_t fn_start, tree fnbody, tree orig,
finish_if_stmt_cond (not_iarc, not_iarc_if);
/* If the initial await resume called value is false, rethrow... */
tree rethrow = build_throw (fn_start, NULL_TREE);
- TREE_NO_WARNING (rethrow) = true;
+ suppress_warning (rethrow);
finish_expr_stmt (rethrow);
finish_then_clause (not_iarc_if);
tree iarc_scope = IF_SCOPE (not_iarc_if);
@@ -4243,7 +4243,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
/* For early errors, we do not want a diagnostic about the missing
ramp return value, since the user cannot fix this - a 'return' is
not allowed in a coroutine. */
- TREE_NO_WARNING (orig) = true;
+ suppress_warning (orig, OPT_Wreturn_type);
/* Discard the body, we can't process it further. */
pop_stmt_list (DECL_SAVED_TREE (orig));
DECL_SAVED_TREE (orig) = push_stmt_list ();
@@ -4269,7 +4269,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
DECL_SAVED_TREE (orig) = push_stmt_list ();
append_to_statement_list (fnbody, &DECL_SAVED_TREE (orig));
/* Suppress warnings about the missing return value. */
- TREE_NO_WARNING (orig) = true;
+ suppress_warning (orig, OPT_Wreturn_type);
return false;
}
@@ -4948,7 +4948,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
BIND_EXPR_BODY (ramp_bind) = pop_stmt_list (ramp_body);
DECL_SAVED_TREE (orig) = newbody;
/* Suppress warnings about the missing return value. */
- TREE_NO_WARNING (orig) = true;
+ suppress_warning (orig, OPT_Wreturn_type);
return false;
}
@@ -5159,7 +5159,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree *destroyer)
promise_type, fn_start);
finish_expr_stmt (del_coro_fr);
tree rethrow = build_throw (fn_start, NULL_TREE);
- TREE_NO_WARNING (rethrow) = true;
+ suppress_warning (rethrow);
finish_expr_stmt (rethrow);
finish_handler (handler);
TRY_HANDLERS (ramp_cleanup) = pop_stmt_list (TRY_HANDLERS (ramp_cleanup));
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 33e10556e32..00b7772fe0d 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -101,8 +101,8 @@ genericize_eh_spec_block (tree *stmt_p)
tree failure = build_call_n (call_unexpected_fn, 1, build_exc_ptr ());
*stmt_p = build_gimple_eh_filter_tree (body, allowed, failure);
- TREE_NO_WARNING (*stmt_p) = true;
- TREE_NO_WARNING (TREE_OPERAND (*stmt_p, 1)) = true;
+ suppress_warning (*stmt_p);
+ suppress_warning (TREE_OPERAND (*stmt_p, 1));
}
/* Return the first non-compound statement in STMT. */
@@ -220,7 +220,7 @@ gimplify_expr_stmt (tree *stmt_p)
{
if (!IS_EMPTY_STMT (stmt)
&& !VOID_TYPE_P (TREE_TYPE (stmt))
- && !TREE_NO_WARNING (stmt))
+ && !warning_suppressed_p (stmt, OPT_Wunused_value))
warning (OPT_Wunused_value, "statement with no effect");
}
else
@@ -1328,7 +1328,7 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
case THROW_EXPR:
{
location_t loc = location_of (stmt);
- if (TREE_NO_WARNING (stmt))
+ if (warning_suppressed_p (stmt /* What warning? */))
/* Never mind. */;
else if (wtd->try_block)
{
@@ -2443,8 +2443,9 @@ cp_fold (tree x)
;
else if (COMPARISON_CLASS_P (x))
{
- if (TREE_NO_WARNING (org_x) && warn_nonnull_compare)
- TREE_NO_WARNING (x) = 1;
+ if (warn_nonnull_compare
+ && warning_suppressed_p (org_x, OPT_Wnonnull_compare))
+ suppress_warning (x, OPT_Wnonnull_compare);
}
/* Otherwise give up on optimizing these, let GIMPLE folders
optimize those later on. */
@@ -2452,8 +2453,9 @@ cp_fold (tree x)
|| op1 != TREE_OPERAND (org_x, 1))
{
x = build2_loc (loc, code, TREE_TYPE (org_x), op0, op1);
- if (TREE_NO_WARNING (org_x) && warn_nonnull_compare)
- TREE_NO_WARNING (x) = 1;
+ if (warn_nonnull_compare
+ && warning_suppressed_p (org_x, OPT_Wnonnull_compare))
+ suppress_warning (x, OPT_Wnonnull_compare);
}
else
x = org_x;
@@ -2713,7 +2715,7 @@ cp_fold (tree x)
if (EXPR_P (x) && TREE_CODE (x) == code)
{
TREE_THIS_VOLATILE (x) = TREE_THIS_VOLATILE (org_x);
- TREE_NO_WARNING (x) = TREE_NO_WARNING (org_x);
+ copy_warning (x, org_x);
}
if (!c.evaluation_restricted_p ())
diff --git a/gcc/cp/cp-ubsan.c b/gcc/cp/cp-ubsan.c
index 3dabb6aa18a..78545945d75 100644
--- a/gcc/cp/cp-ubsan.c
+++ b/gcc/cp/cp-ubsan.c
@@ -81,7 +81,7 @@ cp_ubsan_instrument_vptr (location_t loc, tree op, tree type, bool is_addr,
build_zero_cst (TREE_TYPE (op)));
/* This is a compiler generated comparison, don't emit
e.g. -Wnonnull-compare warning for it. */
- TREE_NO_WARNING (cond) = 1;
+ suppress_warning (cond, OPT_Wnonnull_compare);
vptr = build3_loc (loc, COND_EXPR, uint64_type_node, cond,
vptr, build_int_cst (uint64_type_node, 0));
}
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 330d65854b4..d035e611be4 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -605,8 +605,6 @@ ignore_overflows (tree expr, tree orig)
tree
cp_fold_convert (tree type, tree expr)
{
- bool nowarn = TREE_NO_WARNING (expr);
-
tree conv;
if (TREE_TYPE (expr) == type)
conv = expr;
@@ -630,8 +628,8 @@ cp_fold_convert (tree type, tree expr)
conv = ignore_overflows (conv, expr);
}
- if (nowarn && TREE_CODE (expr) == TREE_CODE (conv))
- TREE_NO_WARNING (conv) = nowarn;
+ if (TREE_CODE (expr) == TREE_CODE (conv))
+ copy_warning (conv, expr);
return conv;
}
@@ -1208,7 +1206,7 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain)
/* The second part of a compound expr contains the value. */
tree op1 = TREE_OPERAND (expr,1);
tree new_op1;
- if (implicit != ICV_CAST && !TREE_NO_WARNING (expr))
+ if (implicit != ICV_CAST && !warning_suppressed_p (expr /* What warning? */))
new_op1 = convert_to_void (op1, ICV_RIGHT_OF_COMMA, complain);
else
new_op1 = convert_to_void (op1, ICV_CAST, complain);
@@ -1394,7 +1392,7 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain)
if (warn_unused_value
&& implicit != ICV_CAST
&& (complain & tf_warning)
- && !TREE_NO_WARNING (expr)
+ && !warning_suppressed_p (expr, OPT_Wunused_value)
&& !is_reference)
warning_at (loc, OPT_Wunused_value, "value computed is not used");
expr = TREE_OPERAND (expr, 0);
@@ -1578,7 +1576,7 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain)
{
if (implicit != ICV_CAST
&& warn_unused_value
- && !TREE_NO_WARNING (expr)
+ && !warning_suppressed_p (expr, OPT_Wunused_value)
&& !processing_template_decl
&& !cp_unevaluated_operand
&& (complain & tf_warning))
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 66bcc4be84d..fa6af6fec11 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -850,7 +850,7 @@ wrapup_namespace_globals ()
&& !TREE_PUBLIC (decl)
&& !DECL_ARTIFICIAL (decl)
&& !DECL_FRIEND_PSEUDO_TEMPLATE_INSTANTIATION (decl)
- && !TREE_NO_WARNING (decl))
+ && !warning_suppressed_p (decl, OPT_Wunused_function))
warning_at (DECL_SOURCE_LOCATION (decl),
OPT_Wunused_function,
"%qF declared %<static%> but never defined", decl);
@@ -13906,10 +13906,7 @@ grokdeclarator (const cp_declarator *declarator,
decl = build_decl (id_loc, FIELD_DECL, unqualified_id, type);
DECL_NONADDRESSABLE_P (decl) = bitfield;
if (bitfield && !unqualified_id)
- {
- TREE_NO_WARNING (decl) = 1;
- DECL_PADDING_P (decl) = 1;
- }
+ DECL_PADDING_P (decl) = 1;
if (storage_class == sc_mutable)
{
@@ -17495,7 +17492,7 @@ finish_function (bool inline_p)
/* Don't complain if we are declared noreturn. */
&& !TREE_THIS_VOLATILE (fndecl)
&& !DECL_NAME (DECL_RESULT (fndecl))
- && !TREE_NO_WARNING (fndecl)
+ && !warning_suppressed_p (fndecl, OPT_Wreturn_type)
/* Structor return values (if any) are set by the compiler. */
&& !DECL_CONSTRUCTOR_P (fndecl)
&& !DECL_DESTRUCTOR_P (fndecl)
@@ -17523,7 +17520,7 @@ finish_function (bool inline_p)
else if (warning_at (&richloc, OPT_Wreturn_type,
"no return statement in function returning "
"non-void"))
- TREE_NO_WARNING (fndecl) = 1;
+ suppress_warning (fndecl, OPT_Wreturn_type);
}
/* Lambda closure members are implicitly constexpr if possible. */
@@ -17597,7 +17594,7 @@ finish_function (bool inline_p)
&& !DECL_READ_P (decl)
&& DECL_NAME (decl)
&& !DECL_ARTIFICIAL (decl)
- && !TREE_NO_WARNING (decl)
+ && !warning_suppressed_p (decl,OPT_Wunused_but_set_parameter)
&& !DECL_IN_SYSTEM_HEADER (decl)
&& TREE_TYPE (decl) != error_mark_node
&& !TYPE_REF_P (TREE_TYPE (decl))
@@ -18088,7 +18085,7 @@ require_deduced_type (tree decl, tsubst_flags_t complain)
{
if (undeduced_auto_decl (decl))
{
- if (TREE_NO_WARNING (decl) && seen_error ())
+ if (warning_suppressed_p (decl) && seen_error ())
/* We probably already complained about deduction failure. */;
else if (complain & tf_error)
error ("use of %qD before deduction of %<auto%>", decl);
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index e46fded908a..090a83bd670 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4529,7 +4529,7 @@ no_linkage_error (tree decl)
|| (errorcount + sorrycount > 0
&& DECL_LANG_SPECIFIC (decl)
&& DECL_TEMPLATE_INFO (decl)
- && TREE_NO_WARNING (decl))))
+ && warning_suppressed_p (decl /* What warning? */))))
/* In C++11 it's ok if the decl is defined. */
return;
@@ -5204,7 +5204,7 @@ c_parse_final_cleanups (void)
&& warning_at (DECL_SOURCE_LOCATION (decl), 0,
"inline function %qD used but never defined", decl))
/* Avoid a duplicate warning from check_global_declaration. */
- TREE_NO_WARNING (decl) = 1;
+ suppress_warning (decl, OPT_Wunused);
}
/* So must decls that use a type with no linkage. */
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index cbafc09629b..a8cea53cf91 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -466,7 +466,8 @@ expand_end_catch_block (void)
|| DECL_DESTRUCTOR_P (current_function_decl)))
{
tree rethrow = build_throw (input_location, NULL_TREE);
- TREE_NO_WARNING (rethrow) = true;
+ /* Disable all warnings for the generated rethrow statement. */
+ suppress_warning (rethrow);
finish_expr_stmt (rethrow);
}
}
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 4bd942f3f74..88f6f90a800 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -3536,11 +3536,11 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
the arguments to the constructor call. */
{
/* CLEANUP is compiler-generated, so no diagnostics. */
- TREE_NO_WARNING (cleanup) = true;
+ suppress_warning (cleanup);
init_expr = build2 (TRY_CATCH_EXPR, void_type_node,
init_expr, cleanup);
/* Likewise, this try-catch is compiler-generated. */
- TREE_NO_WARNING (init_expr) = true;
+ suppress_warning (init_expr);
}
else
/* Ack! First we allocate the memory. Then we set our sentry
@@ -3562,7 +3562,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
sentry = TARGET_EXPR_SLOT (begin);
/* CLEANUP is compiler-generated, so no diagnostics. */
- TREE_NO_WARNING (cleanup) = true;
+ suppress_warning (cleanup);
TARGET_EXPR_CLEANUP (begin)
= build3 (COND_EXPR, void_type_node, sentry,
@@ -3576,7 +3576,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts,
build2 (COMPOUND_EXPR, void_type_node, init_expr,
end));
/* Likewise, this is compiler-generated. */
- TREE_NO_WARNING (init_expr) = true;
+ suppress_warning (init_expr);
}
}
}
@@ -3823,7 +3823,7 @@ build_new (location_t loc, vec<tree, va_gc> **placement, tree type,
/* Wrap it in a NOP_EXPR so warn_if_unused_value doesn't complain. */
rval = build1_loc (loc, NOP_EXPR, TREE_TYPE (rval), rval);
- TREE_NO_WARNING (rval) = 1;
+ suppress_warning (rval, OPT_Wunused_value);
return rval;
}
@@ -3995,7 +3995,7 @@ build_vec_delete_1 (location_t loc, tree base, tree maxindex, tree type,
fold_convert (TREE_TYPE (base), nullptr_node));
/* This is a compiler generated comparison, don't emit
e.g. -Wnonnull-compare warning for it. */
- TREE_NO_WARNING (cond) = 1;
+ suppress_warning (cond, OPT_Wnonnull_compare);
body = build3_loc (loc, COND_EXPR, void_type_node,
cond, body, integer_zero_node);
COND_EXPR_IS_VEC_DELETE (body) = true;
@@ -4665,7 +4665,7 @@ build_vec_init (tree base, tree maxindex, tree init,
atype = build_pointer_type (atype);
stmt_expr = build1 (NOP_EXPR, atype, stmt_expr);
stmt_expr = cp_build_fold_indirect_ref (stmt_expr);
- TREE_NO_WARNING (stmt_expr) = 1;
+ suppress_warning (stmt_expr /* What warning? */);
}
return stmt_expr;
@@ -4935,7 +4935,7 @@ build_delete (location_t loc, tree otype, tree addr,
/* This is a compiler generated comparison, don't emit
e.g. -Wnonnull-compare warning for it. */
else if (TREE_CODE (ifexp) == NE_EXPR)
- TREE_NO_WARNING (ifexp) = 1;
+ suppress_warning (ifexp, OPT_Wnonnull_compare);
if (!integer_nonzerop (ifexp))
expr = build3 (COND_EXPR, void_type_node, ifexp, expr, void_node);
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index dd745237f22..f268aab1a79 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -3284,7 +3284,7 @@ defaultable_fn_check (tree fn)
/* Avoid do_warn_unused_parameter warnings. */
for (tree p = FUNCTION_FIRST_USER_PARM (fn); p; p = DECL_CHAIN (p))
if (DECL_NAME (p))
- TREE_NO_WARNING (p) = 1;
+ suppress_warning (p, OPT_Wunused_parameter);
if (current_class_type && TYPE_BEING_DEFINED (current_class_type))
/* Defer checking. */;
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index b7a429843e2..096580e7e50 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -1,3 +1,4 @@
+
/* -*- C++ -*- Parser.
Copyright (C) 2000-2021 Free Software Foundation, Inc.
Written by Mark Mitchell <mark@codesourcery.com>.
@@ -5322,7 +5323,7 @@ cp_parser_fold_expression (cp_parser *parser, tree expr1)
/* The operands of a fold-expression are cast-expressions, so binary or
conditional expressions are not allowed. We check this here to avoid
tentative parsing. */
- if (EXPR_P (expr1) && TREE_NO_WARNING (expr1))
+ if (EXPR_P (expr1) && warning_suppressed_p (expr1, OPT_Wparentheses))
/* OK, the expression was parenthesized. */;
else if (is_binary_op (TREE_CODE (expr1)))
error_at (location_of (expr1),
@@ -5604,7 +5605,10 @@ cp_parser_primary_expression (cp_parser *parser,
/* Consume the `)'. */
token = cp_lexer_peek_token (parser->lexer);
location_t close_paren_loc = token->location;
+ bool no_wparens = warning_suppressed_p (expr, OPT_Wparentheses);
expr.set_range (open_paren_loc, close_paren_loc);
+ if (no_wparens)
+ suppress_warning (expr, OPT_Wparentheses);
if (!parens.require_close (parser)
&& !cp_parser_uncommitted_to_tentative_parse_p (parser))
cp_parser_skip_to_end_of_statement (parser);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f73c7471a33..e5a2a2cd525 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10954,9 +10954,9 @@ push_tinst_level_loc (tree tldcl, tree targs, location_t loc)
constant expressions. */
if (!targs && limit_bad_template_recursion (tldcl))
{
- /* Avoid no_linkage_errors and unused function warnings for this
- decl. */
- TREE_NO_WARNING (tldcl) = 1;
+ /* Avoid no_linkage_errors and unused function (and all other)
+ warnings for this decl. */
+ suppress_warning (tldcl);
return false;
}
@@ -17079,7 +17079,7 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
tree op1 = tsubst_copy (TREE_OPERAND (t, 1), args, complain, in_decl);
tree op2 = tsubst_copy (TREE_OPERAND (t, 2), args, complain, in_decl);
r = build_nt (code, op0, op1, op2);
- TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
+ copy_warning (r, t);
return r;
}
@@ -19172,8 +19172,7 @@ tsubst_omp_udr (tree t, tree args, tsubst_flags_t complain, tree in_decl)
block = finish_omp_structured_block (block);
block = maybe_cleanup_point_expr_void (block);
add_decl_expr (omp_out);
- if (TREE_NO_WARNING (DECL_EXPR_DECL (stmts[0])))
- TREE_NO_WARNING (omp_out) = 1;
+ copy_warning (omp_out, DECL_EXPR_DECL (stmts[0]));
add_decl_expr (omp_in);
finish_expr_stmt (block);
}
@@ -19854,17 +19853,17 @@ tsubst_copy_and_build (tree t,
tree r = build_x_binary_op
(input_location, TREE_CODE (t),
op0,
- (TREE_NO_WARNING (TREE_OPERAND (t, 0))
+ (warning_suppressed_p (TREE_OPERAND (t, 0))
? ERROR_MARK
: TREE_CODE (TREE_OPERAND (t, 0))),
op1,
- (TREE_NO_WARNING (TREE_OPERAND (t, 1))
+ (warning_suppressed_p (TREE_OPERAND (t, 1))
? ERROR_MARK
: TREE_CODE (TREE_OPERAND (t, 1))),
/*overload=*/NULL,
complain|decltype_flag);
- if (EXPR_P (r) && TREE_NO_WARNING (t))
- TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
+ if (EXPR_P (r))
+ copy_warning (r, t);
RETURN (r);
}
@@ -20000,8 +19999,8 @@ tsubst_copy_and_build (tree t,
set and must be copied. In the latter case,
build_x_modify_expr sets it and it must not be reset
here. */
- if (TREE_NO_WARNING (t))
- TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
+ if (warning_suppressed_p (t, OPT_Wparentheses))
+ suppress_warning (r, OPT_Wparentheses);
RETURN (r);
}
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index 82eaa286514..fcb33088a21 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -536,14 +536,14 @@ build_if_nonnull (tree test, tree result, tsubst_flags_t complain)
/* This is a compiler generated comparison, don't emit
e.g. -Wnonnull-compare warning for it. */
- TREE_NO_WARNING (cond) = 1;
+ suppress_warning (cond, OPT_Wnonnull);
null_ptr = cp_convert (TREE_TYPE (result), nullptr_node, complain);
cond = build3 (COND_EXPR, TREE_TYPE (result), cond, result, null_ptr);
/* Likewise, don't emit -Wnonnull for using the result to call
a member function. */
- TREE_NO_WARNING (cond) = 1;
+ suppress_warning (cond, OPT_Wnonnull);
return cond;
}
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index fbaabf62df4..b080259083e 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -835,12 +835,12 @@ maybe_convert_cond (tree cond)
cond = convert_from_reference (cond);
if (TREE_CODE (cond) == MODIFY_EXPR
- && !TREE_NO_WARNING (cond)
&& warn_parentheses
+ && !warning_suppressed_p (cond, OPT_Wparentheses)
&& warning_at (cp_expr_loc_or_input_loc (cond),
OPT_Wparentheses, "suggest parentheses around "
"assignment used as truth value"))
- TREE_NO_WARNING (cond) = 1;
+ suppress_warning (cond, OPT_Wparentheses);
return condition_conversion (cond);
}
@@ -1197,7 +1197,7 @@ finish_return_stmt (tree expr)
{
/* Suppress -Wreturn-type for this function. */
if (warn_return_type)
- TREE_NO_WARNING (current_function_decl) = true;
+ suppress_warning (current_function_decl, OPT_Wreturn_type);
return error_mark_node;
}
@@ -1219,7 +1219,8 @@ finish_return_stmt (tree expr)
}
r = build_stmt (input_location, RETURN_EXPR, expr);
- TREE_NO_WARNING (r) |= no_warning;
+ if (no_warning)
+ suppress_warning (r, OPT_Wreturn_type);
r = maybe_cleanup_point_expr_void (r);
r = add_stmt (r);
@@ -2105,7 +2106,7 @@ finish_parenthesized_expr (cp_expr expr)
{
if (EXPR_P (expr))
/* This inhibits warnings in c_common_truthvalue_conversion. */
- TREE_NO_WARNING (expr) = 1;
+ suppress_warning (expr, OPT_Wparentheses);
if (TREE_CODE (expr) == OFFSET_REF
|| TREE_CODE (expr) == SCOPE_REF)
@@ -5979,12 +5980,12 @@ cp_check_omp_declare_reduction (tree udr)
{
gcc_assert (TREE_CODE (data.stmts[0]) == DECL_EXPR
&& TREE_CODE (data.stmts[1]) == DECL_EXPR);
- if (TREE_NO_WARNING (DECL_EXPR_DECL (data.stmts[0])))
+ if (warning_suppressed_p (DECL_EXPR_DECL (data.stmts[0]) /* What warning? */))
return true;
data.combiner_p = true;
if (cp_walk_tree (&data.stmts[2], cp_check_omp_declare_reduction_r,
&data, NULL))
- TREE_NO_WARNING (DECL_EXPR_DECL (data.stmts[0])) = 1;
+ suppress_warning (DECL_EXPR_DECL (data.stmts[0]) /* What warning? */);
}
if (i >= 6)
{
@@ -5995,7 +5996,7 @@ cp_check_omp_declare_reduction (tree udr)
&data, NULL)
|| cp_walk_tree (&DECL_INITIAL (DECL_EXPR_DECL (data.stmts[3])),
cp_check_omp_declare_reduction_r, &data, NULL))
- TREE_NO_WARNING (DECL_EXPR_DECL (data.stmts[0])) = 1;
+ suppress_warning (DECL_EXPR_DECL (data.stmts[0]) /* Wat warning? */);
if (i == 7)
gcc_assert (TREE_CODE (data.stmts[6]) == DECL_EXPR);
}
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 297da2b1550..2a14fa92ddb 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1127,7 +1127,7 @@ build_cplus_array_type (tree elt_type, tree index_type, int dependent)
/* Avoid spurious warnings with VLAs (c++/54583). */
if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
- TREE_NO_WARNING (TYPE_SIZE (t)) = 1;
+ suppress_warning (TYPE_SIZE (t), OPT_Wunused);
/* Push these needs up to the ARRAY_TYPE so that initialization takes
place more easily. */
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 937581ae83c..a483e1f988d 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3326,10 +3326,7 @@ build_ptrmemfunc_access_expr (tree ptrmem, tree member_name)
member = DECL_CHAIN (member))
if (DECL_NAME (member) == member_name)
break;
- tree res = build_simple_component_ref (ptrmem, member);
-
- TREE_NO_WARNING (res) = 1;
- return res;
+ return build_simple_component_ref (ptrmem, member);
}
/* Given an expression PTR for a pointer, return an expression
@@ -3443,7 +3440,7 @@ cp_build_indirect_ref_1 (location_t loc, tree ptr, ref_operator errorstring,
if (warn_strict_aliasing > 2
&& cp_strict_aliasing_warning (EXPR_LOCATION (ptr),
type, TREE_OPERAND (ptr, 0)))
- TREE_NO_WARNING (ptr) = 1;
+ suppress_warning (ptr, OPT_Wstrict_aliasing);
}
if (VOID_TYPE_P (t))
@@ -4068,7 +4065,7 @@ cp_build_function_call_vec (tree function, vec<tree, va_gc> **params,
{
tree c = extract_call_expr (ret);
if (TREE_CODE (c) == CALL_EXPR)
- TREE_NO_WARNING (c) = 1;
+ suppress_warning (c, OPT_Wnonnull);
}
if (allocated != NULL)
@@ -4450,14 +4447,14 @@ warn_for_null_address (location_t location, tree op, tsubst_flags_t complain)
if (!warn_address
|| (complain & tf_warning) == 0
|| c_inhibit_evaluation_warnings != 0
- || TREE_NO_WARNING (op))
+ || warning_suppressed_p (op, OPT_Waddress))
return;
tree cop = fold_for_warn (op);
if (TREE_CODE (cop) == ADDR_EXPR
&& decl_with_nonnull_addr_p (TREE_OPERAND (cop, 0))
- && !TREE_NO_WARNING (cop))
+ && !warning_suppressed_p (cop, OPT_Waddress))
warning_at (location, OPT_Waddress, "the address of %qD will never "
"be NULL", TREE_OPERAND (cop, 0));
@@ -4878,7 +4875,7 @@ cp_build_binary_op (const op_location_t &location,
else if (TREE_CODE (type0) == ARRAY_TYPE
&& !char_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (type0)))
/* Set by finish_parenthesized_expr. */
- && !TREE_NO_WARNING (op1)
+ && !warning_suppressed_p (op1, OPT_Wsizeof_array_div)
&& (complain & tf_warning))
maybe_warn_sizeof_array_div (location, first_arg, type0,
op1, non_reference (type1));
@@ -5297,7 +5294,7 @@ cp_build_binary_op (const op_location_t &location,
pfn0 = cp_fully_fold (pfn0);
/* Avoid -Waddress warnings (c++/64877). */
if (TREE_CODE (pfn0) == ADDR_EXPR)
- TREE_NO_WARNING (pfn0) = 1;
+ suppress_warning (pfn0, OPT_Waddress);
pfn1 = pfn_from_ptrmemfunc (op1);
pfn1 = cp_fully_fold (pfn1);
delta0 = delta_from_ptrmemfunc (op0);
@@ -7062,7 +7059,7 @@ unary_complex_lvalue (enum tree_code code, tree arg)
tf_warning_or_error);
arg = build2 (COMPOUND_EXPR, TREE_TYPE (real_result),
arg, real_result);
- TREE_NO_WARNING (arg) = 1;
+ suppress_warning (arg /* What warning? */);
return arg;
}
@@ -8978,7 +8975,7 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
TREE_SIDE_EFFECTS (result) = 1;
if (!plain_assign)
- TREE_NO_WARNING (result) = 1;
+ suppress_warning (result, OPT_Wparentheses);
ret:
if (preeval)
@@ -9022,7 +9019,7 @@ build_x_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
{
if (rval == error_mark_node)
return rval;
- TREE_NO_WARNING (rval) = 1;
+ suppress_warning (rval /* What warning? */);
if (processing_template_decl)
{
if (overload != NULL_TREE)
@@ -9629,13 +9626,13 @@ convert_for_assignment (tree type, tree rhs,
if (warn_parentheses
&& TREE_CODE (type) == BOOLEAN_TYPE
&& TREE_CODE (rhs) == MODIFY_EXPR
- && !TREE_NO_WARNING (rhs)
+ && !warning_suppressed_p (rhs, OPT_Wparentheses)
&& TREE_CODE (TREE_TYPE (rhs)) != BOOLEAN_TYPE
&& (complain & tf_warning)
&& warning_at (rhs_loc, OPT_Wparentheses,
"suggest parentheses around assignment used as "
"truth value"))
- TREE_NO_WARNING (rhs) = 1;
+ suppress_warning (rhs, OPT_Wparentheses);
if (complain & tf_warning)
warn_for_address_or_pointer_of_packed_member (type, rhs);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-06-25 1:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-25 1:32 [gcc r12-1804] cp: add support for per-location warning groups Martin Sebor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).