c-family: add support for per-location warning groups.

gcc/c-family/ChangeLog:

	* c-common.c (c_wrap_maybe_const): Remove TREE_NO_WARNING.
	(c_common_truthvalue_conversion): Replace direct uses of
	TREE_NO_WARNING with warning_suppressed_p, suppress_warning, and
	copy_no_warning.
	(check_function_arguments_recurse): Same.
	* c-gimplify.c (c_gimplify_expr): Same.
	* c-warn.c (overflow_warning): Same.
	(warn_logical_operator): Same.
	(warn_if_unused_value): Same.
	(do_warn_unused_parameter): Same.
This commit is contained in:
Martin Sebor 2021-06-24 16:09:20 -06:00
parent 1ebd2b2c94
commit 43c3f96f29
3 changed files with 9 additions and 12 deletions

View File

@ -3375,7 +3375,6 @@ pointer_int_sum (location_t loc, enum tree_code resultcode,
tree
c_wrap_maybe_const (tree expr, bool non_const)
{
bool nowarning = TREE_NO_WARNING (expr);
location_t loc = EXPR_LOCATION (expr);
/* This should never be called for C++. */
@ -3386,8 +3385,6 @@ c_wrap_maybe_const (tree expr, bool non_const)
STRIP_TYPE_NOPS (expr);
expr = build2 (C_MAYBE_CONST_EXPR, TREE_TYPE (expr), NULL, expr);
C_MAYBE_CONST_EXPR_NON_CONST (expr) = non_const;
if (nowarning)
TREE_NO_WARNING (expr) = 1;
protected_set_expr_location (expr, loc);
return expr;
@ -3633,12 +3630,12 @@ c_common_truthvalue_conversion (location_t location, tree expr)
break;
case MODIFY_EXPR:
if (!TREE_NO_WARNING (expr)
if (!warning_suppressed_p (expr, OPT_Wparentheses)
&& warn_parentheses
&& warning_at (location, OPT_Wparentheses,
"suggest parentheses around assignment used as "
"truth value"))
TREE_NO_WARNING (expr) = 1;
suppress_warning (expr, OPT_Wparentheses);
break;
case CONST_DECL:
@ -6019,7 +6016,7 @@ check_function_arguments_recurse (void (*callback)
void *ctx, tree param,
unsigned HOST_WIDE_INT param_num)
{
if (TREE_NO_WARNING (param))
if (warning_suppressed_p (param))
return;
if (CONVERT_EXPR_P (param)

View File

@ -713,7 +713,7 @@ c_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
&& !TREE_STATIC (DECL_EXPR_DECL (*expr_p))
&& (DECL_INITIAL (DECL_EXPR_DECL (*expr_p)) == DECL_EXPR_DECL (*expr_p))
&& !warn_init_self)
TREE_NO_WARNING (DECL_EXPR_DECL (*expr_p)) = 1;
suppress_warning (DECL_EXPR_DECL (*expr_p), OPT_Winit_self);
break;
case PREINCREMENT_EXPR:

View File

@ -155,7 +155,7 @@ overflow_warning (location_t loc, tree value, tree expr)
value);
if (warned)
TREE_NO_WARNING (value) = 1;
suppress_warning (value, OPT_Woverflow);
}
/* Helper function for walk_tree. Unwrap C_MAYBE_CONST_EXPRs in an expression
@ -219,7 +219,7 @@ warn_logical_operator (location_t location, enum tree_code code, tree type,
&& INTEGRAL_TYPE_P (TREE_TYPE (op_left))
&& !CONSTANT_CLASS_P (stripped_op_left)
&& TREE_CODE (stripped_op_left) != CONST_DECL
&& !TREE_NO_WARNING (op_left)
&& !warning_suppressed_p (op_left, OPT_Wlogical_op)
&& TREE_CODE (op_right) == INTEGER_CST
&& !integer_zerop (op_right)
&& !integer_onep (op_right))
@ -234,7 +234,7 @@ warn_logical_operator (location_t location, enum tree_code code, tree type,
= warning_at (location, OPT_Wlogical_op,
"logical %<and%> applied to non-boolean constant");
if (warned)
TREE_NO_WARNING (op_left) = true;
suppress_warning (op_left, OPT_Wlogical_op);
return;
}
@ -588,7 +588,7 @@ bool
warn_if_unused_value (const_tree exp, location_t locus, bool quiet)
{
restart:
if (TREE_USED (exp) || TREE_NO_WARNING (exp))
if (TREE_USED (exp) || warning_suppressed_p (exp, OPT_Wunused_value))
return false;
/* Don't warn about void constructs. This includes casting to void,
@ -2410,7 +2410,7 @@ do_warn_unused_parameter (tree fn)
decl; decl = DECL_CHAIN (decl))
if (!TREE_USED (decl) && TREE_CODE (decl) == PARM_DECL
&& DECL_NAME (decl) && !DECL_ARTIFICIAL (decl)
&& !TREE_NO_WARNING (decl))
&& !warning_suppressed_p (decl, OPT_Wunused_parameter))
warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wunused_parameter,
"unused parameter %qD", decl);
}