diff options
| author | Jakub Jelinek <jakub@redhat.com> | 2019-03-08 11:46:39 +0100 |
|---|---|---|
| committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-03-08 11:46:39 +0100 |
| commit | 1db01ff96aa5ce5c4ad78313d342cf70f923b40c (patch) | |
| tree | fae09df731b30ee508d5a37f95a71ca30d15912d /gcc/c-family/c-warn.c | |
| parent | 94ec37a909697bbf29db73278c77621ccdf60693 (diff) | |
| download | gcc-1db01ff96aa5ce5c4ad78313d342cf70f923b40c.zip gcc-1db01ff96aa5ce5c4ad78313d342cf70f923b40c.tar.gz gcc-1db01ff96aa5ce5c4ad78313d342cf70f923b40c.tar.bz2 | |
re PR tree-optimization/89550 (Spurious array-bounds warning when using __PRETTY_FUNCTION__ as a string_view)
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.
c-family/
* 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.
c/
* 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.
cp/
* 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.
From-SVN: r269485
Diffstat (limited to 'gcc/c-family/c-warn.c')
| -rw-r--r-- | gcc/c-family/c-warn.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index e2f3449..d775ff8 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -143,12 +143,16 @@ overflow_warning (location_t loc, tree value, tree expr) 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 @@ -216,13 +220,17 @@ warn_logical_operator (location_t location, enum tree_code code, tree type, && !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; } } |
