aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-03-08 11:46:39 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-03-08 11:46:39 +0100
commit1db01ff96aa5ce5c4ad78313d342cf70f923b40c (patch)
treefae09df731b30ee508d5a37f95a71ca30d15912d /gcc/cp
parent94ec37a909697bbf29db73278c77621ccdf60693 (diff)
downloadgcc-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/cp')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/decl.c6
-rw-r--r--gcc/cp/decl2.c12
-rw-r--r--gcc/cp/semantics.c11
-rw-r--r--gcc/cp/typeck.c11
5 files changed, 25 insertions, 22 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 5faebe5..43184b0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
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.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 0187db5..081f37c 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -16171,9 +16171,9 @@ finish_function (bool inline_p)
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
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index b60110a..4e4746e 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -5022,13 +5022,11 @@ c_parse_final_cleanups (void)
/* 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. */
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 2573b77..798a2b3 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -657,12 +657,11 @@ maybe_convert_cond (tree cond)
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);
}
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 8d9224b..51f4781 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -9071,12 +9071,11 @@ convert_for_assignment (tree type, tree rhs,
&& 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);