+2019-03-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/89550
+ * builtins.c (c_strlen): Only set TREE_NO_WARNING if warning_at
+ returned true. Formatting fixes.
+ (expand_builtin_strnlen): Formatting fixes.
+ * tree-vrp.c (vrp_prop::check_mem_ref): Only set TREE_NO_WARNING
+ if warning_at returned true.
+ * tree-cfg.c (pass_warn_function_return::execute): Likewise.
+
2019-03-08 Richard Biener <rguenther@suse.de>
PR middle-end/89578
runtime. */
if (eltoff < 0 || eltoff >= maxelts)
{
- /* Suppress multiple warnings for propagated constant strings. */
+ /* Suppress multiple warnings for propagated constant strings. */
if (only_value != 2
- && !TREE_NO_WARNING (src))
- {
- warning_at (loc, OPT_Warray_bounds,
- "offset %qwi outside bounds of constant string",
- eltoff);
- TREE_NO_WARNING (src) = 1;
- }
+ && !TREE_NO_WARNING (src)
+ && warning_at (loc, OPT_Warray_bounds,
+ "offset %qwi outside bounds of constant string",
+ eltoff))
+ TREE_NO_WARNING (src) = 1;
return NULL_TREE;
}
"%K%qD specified bound %E "
"exceeds maximum object size %E",
exp, func, bound, maxobjsize))
- TREE_NO_WARNING (exp) = true;
+ TREE_NO_WARNING (exp) = true;
bool exact = true;
if (!len || TREE_CODE (len) != INTEGER_CST)
"%K%qD specified bound [%wu, %wu] "
"exceeds maximum object size %E",
exp, func, min.to_uhwi (), max.to_uhwi (), maxobjsize))
- TREE_NO_WARNING (exp) = true;
+ TREE_NO_WARNING (exp) = true;
bool exact = true;
if (!len || TREE_CODE (len) != INTEGER_CST)
+2019-03-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/89550
+ * c-common.c (c_common_truthvalue_conversion): Only set
+ TREE_NO_WARNING if warning_at returned true.
+ * c-warn.c (overflow_warning, warn_logical_operator): Likewise.
+
2019-02-25 Sandra Loosemore <sandra@codesourcery.com>
Martin Sebor <msebor@gmail.com>
case MODIFY_EXPR:
if (!TREE_NO_WARNING (expr)
- && warn_parentheses)
- {
- warning_at (location, OPT_Wparentheses,
- "suggest parentheses around assignment used as "
- "truth value");
- TREE_NO_WARNING (expr) = 1;
- }
+ && warn_parentheses
+ && warning_at (location, OPT_Wparentheses,
+ "suggest parentheses around assignment used as "
+ "truth value"))
+ TREE_NO_WARNING (expr) = 1;
break;
case CONST_DECL:
return;
}
+ bool warned;
if (expr)
- warning_at (loc, OPT_Woverflow, warnfmt, expr, TREE_TYPE (expr), value);
+ warned = warning_at (loc, OPT_Woverflow, warnfmt, expr, TREE_TYPE (expr),
+ value);
else
- warning_at (loc, OPT_Woverflow, warnfmt, TREE_TYPE (value), value);
+ warned = warning_at (loc, OPT_Woverflow, warnfmt, TREE_TYPE (value),
+ value);
- TREE_NO_WARNING (value) = 1;
+ if (warned)
+ TREE_NO_WARNING (value) = 1;
}
/* Helper function for walk_tree. Unwrap C_MAYBE_CONST_EXPRs in an expression
&& !integer_zerop (folded_op_right)
&& !integer_onep (folded_op_right))
{
+ bool warned;
if (or_op)
- warning_at (location, OPT_Wlogical_op, "logical %<or%>"
- " applied to non-boolean constant");
+ warned
+ = warning_at (location, OPT_Wlogical_op,
+ "logical %<or%> applied to non-boolean constant");
else
- warning_at (location, OPT_Wlogical_op, "logical %<and%>"
- " applied to non-boolean constant");
- TREE_NO_WARNING (op_left) = true;
+ warned
+ = warning_at (location, OPT_Wlogical_op,
+ "logical %<and%> applied to non-boolean constant");
+ if (warned)
+ TREE_NO_WARNING (op_left) = true;
return;
}
}
+2019-03-08 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/89550
+ * c-decl.c (finish_function): Only set TREE_NO_WARNING if warning_at
+ returned true.
+ (c_write_global_declarations_1): Only set TREE_NO_WARNING if pedwarn
+ or warning returned true.
+
2019-02-28 Jakub Jelinek <jakub@redhat.com>
PR c/89525
&& !C_FUNCTION_IMPLICIT_INT (fndecl)
/* Normally, with -Wreturn-type, flow will complain, but we might
optimize out static functions. */
- && !TREE_PUBLIC (fndecl))
- {
- warning (OPT_Wreturn_type,
- "no return statement in function returning non-void");
- TREE_NO_WARNING (fndecl) = 1;
- }
+ && !TREE_PUBLIC (fndecl)
+ && warning (OPT_Wreturn_type,
+ "no return statement in function returning non-void"))
+ TREE_NO_WARNING (fndecl) = 1;
/* Complain about parameters that are only set, but never otherwise used. */
if (warn_unused_but_set_parameter)
{
if (C_DECL_USED (decl))
{
- pedwarn (input_location, 0, "%q+F used but never defined", decl);
- TREE_NO_WARNING (decl) = 1;
+ if (pedwarn (input_location, 0, "%q+F used but never defined",
+ decl))
+ TREE_NO_WARNING (decl) = 1;
}
/* For -Wunused-function warn about unused static prototypes. */
else if (warn_unused_function
&& ! DECL_ARTIFICIAL (decl)
&& ! TREE_NO_WARNING (decl))
{
- warning (OPT_Wunused_function,
- "%q+F declared %<static%> but never defined", decl);
- TREE_NO_WARNING (decl) = 1;
+ if (warning (OPT_Wunused_function,
+ "%q+F declared %<static%> but never defined",
+ decl))
+ TREE_NO_WARNING (decl) = 1;
}
}
2019-03-08 Jakub Jelinek <jakub@redhat.com>
+ PR tree-optimization/89550
+ * semantics.c (maybe_convert_cond): Only set TREE_NO_WARNING if
+ warning_at returned true.
+ * decl2.c (c_parse_final_cleanups): Likewise.
+ * typeck.c (convert_for_assignment): Likewise.
+ * decl.c (finish_function): Likewise.
+
PR c++/89585
* parser.c (cp_parser_asm_definition): Just warn instead of error
on volatile qualifier outside of function body.
global_dc->option_state))
add_return_star_this_fixit (&richloc, fndecl);
}
- warning_at (&richloc, OPT_Wreturn_type,
- "no return statement in function returning non-void");
- TREE_NO_WARNING (fndecl) = 1;
+ if (warning_at (&richloc, OPT_Wreturn_type,
+ "no return statement in function returning non-void"))
+ TREE_NO_WARNING (fndecl) = 1;
}
/* Store the end of the function, so that we get good line number
/* Don't complain if the template was defined. */
&& !(DECL_TEMPLATE_INSTANTIATION (decl)
&& DECL_INITIAL (DECL_TEMPLATE_RESULT
- (template_for_substitution (decl)))))
- {
- 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;
- }
+ (template_for_substitution (decl))))
+ && 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;
}
/* So must decls that use a type with no linkage. */
if (TREE_CODE (cond) == MODIFY_EXPR
&& !TREE_NO_WARNING (cond)
- && warn_parentheses)
- {
- warning_at (cp_expr_loc_or_loc (cond, input_location), OPT_Wparentheses,
- "suggest parentheses around assignment used as truth value");
- TREE_NO_WARNING (cond) = 1;
- }
+ && warn_parentheses
+ && warning_at (cp_expr_loc_or_loc (cond, input_location),
+ OPT_Wparentheses, "suggest parentheses around "
+ "assignment used as truth value"))
+ TREE_NO_WARNING (cond) = 1;
return condition_conversion (cond);
}
&& TREE_CODE (rhs) == MODIFY_EXPR
&& !TREE_NO_WARNING (rhs)
&& 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;
- }
+ && (complain & tf_warning)
+ && warning_at (rhs_loc, OPT_Wparentheses,
+ "suggest parentheses around assignment used as "
+ "truth value"))
+ TREE_NO_WARNING (rhs) = 1;
if (complain & tf_warning)
warn_for_address_or_pointer_of_packed_member (type, rhs);
location = gimple_location (last);
if (LOCATION_LOCUS (location) == UNKNOWN_LOCATION)
location = fun->function_end_locus;
- warning_at (location, OPT_Wreturn_type,
- "control reaches end of non-void function");
- TREE_NO_WARNING (fun->decl) = 1;
+ if (warning_at (location, OPT_Wreturn_type,
+ "control reaches end of non-void function"))
+ TREE_NO_WARNING (fun->decl) = 1;
break;
}
}
location = gimple_location (prev);
if (LOCATION_LOCUS (location) == UNKNOWN_LOCATION)
location = fun->function_end_locus;
- warning_at (location, OPT_Wreturn_type,
- "control reaches end of non-void function");
- TREE_NO_WARNING (fun->decl) = 1;
+ if (warning_at (location, OPT_Wreturn_type,
+ "control reaches end of non-void function"))
+ TREE_NO_WARNING (fun->decl) = 1;
break;
}
}
if (warned && DECL_P (arg))
inform (DECL_SOURCE_LOCATION (arg), "while referencing %qD", arg);
- TREE_NO_WARNING (ref) = 1;
+ if (warned)
+ TREE_NO_WARNING (ref) = 1;
return;
}
{
HOST_WIDE_INT tmpidx = extrema[i].to_shwi () / eltsize.to_shwi ();
- warning_at (location, OPT_Warray_bounds,
- "intermediate array offset %wi is outside array bounds "
- "of %qT",
- tmpidx, reftype);
- TREE_NO_WARNING (ref) = 1;
+ if (warning_at (location, OPT_Warray_bounds,
+ "intermediate array offset %wi is outside array bounds "
+ "of %qT", tmpidx, reftype))
+ TREE_NO_WARNING (ref) = 1;
}
}