case VAR_DECL:
/* Warnings for unused variables. */
if ((!TREE_USED (p) || !DECL_READ_P (p))
- && !TREE_NO_WARNING (p)
+ && !warning_suppressed_p (p, OPT_Wunused_but_set_variable)
&& !DECL_IN_SYSTEM_HEADER (p)
&& DECL_NAME (p)
&& !DECL_ARTIFICIAL (p)
if (DECL_IN_SYSTEM_HEADER (newdecl)
|| DECL_IN_SYSTEM_HEADER (olddecl)
- || TREE_NO_WARNING (newdecl)
- || TREE_NO_WARNING (olddecl))
+ || warning_suppressed_p (newdecl, OPT_Wpedantic)
+ || warning_suppressed_p (olddecl, OPT_Wpedantic))
return true; /* Allow OLDDECL to continue in use. */
if (variably_modified_type_p (newtype, NULL))
if (!diagnose_mismatched_decls (newdecl, olddecl, &newtype, &oldtype))
{
/* Avoid `unused variable' and other warnings for OLDDECL. */
- TREE_NO_WARNING (olddecl) = 1;
+ suppress_warning (olddecl, OPT_Wunused);
return false;
}
FIELD_DECL, declarator->u.id.id, type);
DECL_NONADDRESSABLE_P (decl) = bitfield;
if (bitfield && !declarator->u.id.id)
- {
- TREE_NO_WARNING (decl) = 1;
- DECL_PADDING_P (decl) = 1;
- }
+ DECL_PADDING_P (decl) = 1;
if (size_varies)
C_DECL_VARIABLE_SIZE (decl) = 1;
&& targetm.warn_func_return (fndecl)
&& warning (OPT_Wreturn_type,
"no return statement in function returning non-void"))
- TREE_NO_WARNING (fndecl) = 1;
+ suppress_warning (fndecl, OPT_Wreturn_type);
/* Complain about parameters that are only set, but never otherwise used. */
if (warn_unused_but_set_parameter)
&& !DECL_READ_P (decl)
&& DECL_NAME (decl)
&& !DECL_ARTIFICIAL (decl)
- && !TREE_NO_WARNING (decl))
+ && !warning_suppressed_p (decl, OPT_Wunused_but_set_parameter))
warning_at (DECL_SOURCE_LOCATION (decl),
OPT_Wunused_but_set_parameter,
"parameter %qD set but not used", decl);
{
if (C_DECL_USED (decl))
{
+ /* TODO: Add OPT_Wundefined-inline. */
if (pedwarn (input_location, 0, "%q+F used but never defined",
decl))
- TREE_NO_WARNING (decl) = 1;
+ suppress_warning (decl /* OPT_Wundefined-inline. */);
}
/* For -Wunused-function warn about unused static prototypes. */
else if (warn_unused_function
&& ! DECL_ARTIFICIAL (decl)
- && ! TREE_NO_WARNING (decl))
+ && ! warning_suppressed_p (decl, OPT_Wunused_function))
{
if (warning (OPT_Wunused_function,
"%q+F declared %<static%> but never defined",
decl))
- TREE_NO_WARNING (decl) = 1;
+ suppress_warning (decl, OPT_Wunused_function);
}
}
STRIP_TYPE_NOPS (exp);
- if (TREE_NO_WARNING (orig_exp))
- TREE_NO_WARNING (exp) = 1;
+ copy_warning (exp, orig_exp);
ptrtype = build_pointer_type (restype);
STRIP_TYPE_NOPS (exp);
- if (TREE_NO_WARNING (orig_exp))
- TREE_NO_WARNING (exp) = 1;
+ copy_warning (exp, orig_exp);
return build_unary_op (loc, ADDR_EXPR, exp, false);
}
exp.value = TREE_OPERAND (exp.value, 0);
}
- if (TREE_NO_WARNING (orig_exp))
- TREE_NO_WARNING (exp.value) = 1;
+ copy_warning (exp.value, orig_exp);
lvalue_array_p = !not_lvalue && lvalue_p (exp.value);
if (!flag_isoc99 && !lvalue_array_p)
tmp = create_tmp_var_raw (nonatomic_type);
tmp_addr = build_unary_op (loc, ADDR_EXPR, tmp, false);
TREE_ADDRESSABLE (tmp) = 1;
- TREE_NO_WARNING (tmp) = 1;
+ /* Do not disable warnings for TMP even though it's artificial.
+ -Winvalid-memory-model depends on it. */
/* Issue __atomic_load (&expr, &tmp, SEQ_CST); */
fndecl = builtin_decl_explicit (BUILT_IN_ATOMIC_LOAD);
orig_exp = exp;
STRIP_TYPE_NOPS (exp);
- if (TREE_NO_WARNING (orig_exp))
- TREE_NO_WARNING (exp) = 1;
+ copy_warning (exp, orig_exp);
if (code == VOID_TYPE)
{
if (warn_strict_aliasing > 2)
if (strict_aliasing_warning (EXPR_LOCATION (pointer),
type, TREE_OPERAND (pointer, 0)))
- TREE_NO_WARNING (pointer) = 1;
+ suppress_warning (pointer, OPT_Wstrict_aliasing_);
}
if (TREE_CODE (pointer) == ADDR_EXPR
/* If -Wnonnull warning has been diagnosed, avoid diagnosing it again
later. */
if (warned_p && TREE_CODE (result) == CALL_EXPR)
- TREE_NO_WARNING (result) = 1;
+ suppress_warning (result, OPT_Wnonnull);
/* In this improbable scenario, a nested function returns a VM type.
Create a TARGET_EXPR so that the call always has a LHS, much as
TYPE_UNQUALIFIED);
val = create_tmp_var_raw (nonatomic_rhs_type);
TREE_ADDRESSABLE (val) = 1;
- TREE_NO_WARNING (val) = 1;
+ suppress_warning (val);
rhs = build4 (TARGET_EXPR, nonatomic_rhs_type, val, rhs, NULL_TREE,
NULL_TREE);
TREE_SIDE_EFFECTS (rhs) = 1;
newval = create_tmp_var_raw (nonatomic_lhs_type);
TREE_ADDRESSABLE (newval) = 1;
- TREE_NO_WARNING (newval) = 1;
+ suppress_warning (newval);
rhs = build4 (TARGET_EXPR, nonatomic_lhs_type, newval, func_call,
NULL_TREE, NULL_TREE);
SET_EXPR_LOCATION (rhs, loc);
old = create_tmp_var_raw (nonatomic_lhs_type);
old_addr = build_unary_op (loc, ADDR_EXPR, old, false);
TREE_ADDRESSABLE (old) = 1;
- TREE_NO_WARNING (old) = 1;
+ suppress_warning (old);
newval = create_tmp_var_raw (nonatomic_lhs_type);
newval_addr = build_unary_op (loc, ADDR_EXPR, newval, false);
TREE_ADDRESSABLE (newval) = 1;
- TREE_NO_WARNING (newval) = 1;
+ suppress_warning (newval);
loop_decl = create_artificial_label (loc);
loop_label = build1 (LABEL_EXPR, void_type_node, loop_decl);
else
val = build2 (code, TREE_TYPE (arg), arg, inc);
TREE_SIDE_EFFECTS (val) = 1;
- if (TREE_CODE (val) != code)
- TREE_NO_WARNING (val) = 1;
ret = val;
goto return_build_unary_op;
}
}
ret_stmt = build_stmt (loc, RETURN_EXPR, retval);
- TREE_NO_WARNING (ret_stmt) |= no_warning;
+ if (no_warning)
+ suppress_warning (ret_stmt, OPT_Wreturn_type);
return add_stmt (ret_stmt);
}
\f
;
else if (!TREE_SIDE_EFFECTS (expr))
{
- if (!VOID_TYPE_P (TREE_TYPE (expr)) && !TREE_NO_WARNING (expr))
+ if (!VOID_TYPE_P (TREE_TYPE (expr))
+ && !warning_suppressed_p (expr, OPT_Wunused_value))
warning_at (loc, OPT_Wunused_value, "statement with no effect");
}
else if (TREE_CODE (expr) == COMPOUND_EXPR)
if (!TREE_SIDE_EFFECTS (r)
&& !VOID_TYPE_P (TREE_TYPE (r))
&& !CONVERT_EXPR_P (r)
- && !TREE_NO_WARNING (r)
- && !TREE_NO_WARNING (expr))
+ && !warning_suppressed_p (r, OPT_Wunused_value)
+ && !warning_suppressed_p (expr, OPT_Wunused_value))
warning_at (cloc, OPT_Wunused_value,
"right-hand operand of comma expression has no effect");
}
last = c_wrap_maybe_const (last, true);
/* Do not warn if the return value of a statement expression is
unused. */
- TREE_NO_WARNING (last) = 1;
+ suppress_warning (last, OPT_Wunused);
return last;
}
tree tmp = create_tmp_var (nonatomic_type);
tree tmp_addr = build_fold_addr_expr (tmp);
TREE_ADDRESSABLE (tmp) = 1;
- TREE_NO_WARNING (tmp) = 1;
+ suppress_warning (tmp);
tree src_addr = build_fold_addr_expr (src);
tree dst_addr = build_fold_addr_expr (dst);
tree seq_cst = build_int_cst (integer_type_node, MEMMODEL_SEQ_CST);