mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-28 11:14:11 +08:00
re PR c++/31246 (-Wunreachable-code warnings for compiler-generated code)
2009-07-08 Manuel López-Ibáñez <manu@gcc.gnu.org> PR c++/31246 * gimplify.c (gimplify_expr): Propagate no_warning flag when gimplifying. * gimple (gimple_build_call_from_tree): Likewise. * tree-cfg.c (remove_useless_stmts_warn_notreached): Check no_warning flag before warning. cp/ * init.c (build_new_1): Set TREE_NO_WARNING for compiler-generated code. * cp-gimplify.c (genericize_eh_spec_block): Likewise. testsuite/ * g++.dg/warn/pr31246.C: New. * g++.dg/warn/pr31246-2.C: New. From-SVN: r149354
This commit is contained in:
parent
438c0fa8a0
commit
d665b6e585
@ -1,3 +1,12 @@
|
||||
2009-07-08 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
PR c++/31246
|
||||
* gimplify.c (gimplify_expr): Propagate no_warning flag when
|
||||
gimplifying.
|
||||
* gimple (gimple_build_call_from_tree): Likewise.
|
||||
* tree-cfg.c (remove_useless_stmts_warn_notreached): Check
|
||||
no_warning flag before warning.
|
||||
|
||||
2009-07-07 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
* tree.c (set_expr_locus): Remove.
|
||||
|
@ -1,3 +1,11 @@
|
||||
2009-07-08 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
PR c++/31246
|
||||
* init.c (build_new_1): Set TREE_NO_WARNING for compiler-generated
|
||||
code.
|
||||
* cp-gimplify.c (genericize_eh_spec_block): Likewise.
|
||||
|
||||
|
||||
2009-07-07 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/35828
|
||||
|
@ -153,6 +153,8 @@ genericize_eh_spec_block (tree *stmt_p)
|
||||
tree failure = build_call_n (call_unexpected_node, 1, build_exc_ptr ());
|
||||
|
||||
*stmt_p = build_gimple_eh_filter_tree (body, allowed, failure);
|
||||
TREE_NO_WARNING (*stmt_p) = true;
|
||||
TREE_NO_WARNING (TREE_OPERAND (*stmt_p, 1)) = true;
|
||||
}
|
||||
|
||||
/* Genericize an IF_STMT by turning it into a COND_EXPR. */
|
||||
|
@ -2185,8 +2185,14 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts,
|
||||
else if (stable)
|
||||
/* This is much simpler if we were able to preevaluate all of
|
||||
the arguments to the constructor call. */
|
||||
init_expr = build2 (TRY_CATCH_EXPR, void_type_node,
|
||||
init_expr, cleanup);
|
||||
{
|
||||
/* CLEANUP is compiler-generated, so no diagnostics. */
|
||||
TREE_NO_WARNING (cleanup) = true;
|
||||
init_expr = build2 (TRY_CATCH_EXPR, void_type_node,
|
||||
init_expr, cleanup);
|
||||
/* Likewise, this try-catch is compiler-generated. */
|
||||
TREE_NO_WARNING (init_expr) = true;
|
||||
}
|
||||
else
|
||||
/* Ack! First we allocate the memory. Then we set our sentry
|
||||
variable to true, and expand a cleanup that deletes the
|
||||
@ -2206,6 +2212,9 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts,
|
||||
|
||||
sentry = TARGET_EXPR_SLOT (begin);
|
||||
|
||||
/* CLEANUP is compiler-generated, so no diagnostics. */
|
||||
TREE_NO_WARNING (cleanup) = true;
|
||||
|
||||
TARGET_EXPR_CLEANUP (begin)
|
||||
= build3 (COND_EXPR, void_type_node, sentry,
|
||||
cleanup, void_zero_node);
|
||||
@ -2217,8 +2226,9 @@ build_new_1 (VEC(tree,gc) **placement, tree type, tree nelts,
|
||||
= build2 (COMPOUND_EXPR, void_type_node, begin,
|
||||
build2 (COMPOUND_EXPR, void_type_node, init_expr,
|
||||
end));
|
||||
/* Likewise, this is compiler-generated. */
|
||||
TREE_NO_WARNING (init_expr) = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -357,6 +357,7 @@ gimple_build_call_from_tree (tree t)
|
||||
gimple_call_set_return_slot_opt (call, CALL_EXPR_RETURN_SLOT_OPT (t));
|
||||
gimple_call_set_from_thunk (call, CALL_FROM_THUNK_P (t));
|
||||
gimple_call_set_va_arg_pack (call, CALL_EXPR_VA_ARG_PACK (t));
|
||||
gimple_set_no_warning (call, TREE_NO_WARNING (t));
|
||||
|
||||
return call;
|
||||
}
|
||||
|
@ -6787,6 +6787,7 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
|
||||
|
||||
gimplify_and_add (EH_FILTER_FAILURE (*expr_p), &failure);
|
||||
ehf = gimple_build_eh_filter (EH_FILTER_TYPES (*expr_p), failure);
|
||||
gimple_set_no_warning (ehf, TREE_NO_WARNING (*expr_p));
|
||||
gimple_eh_filter_set_must_not_throw
|
||||
(ehf, EH_FILTER_MUST_NOT_THROW (*expr_p));
|
||||
gimplify_seq_add_stmt (pre_p, ehf);
|
||||
|
@ -1,3 +1,9 @@
|
||||
2009-07-08 Manuel López-Ibáñez <manu@gcc.gnu.org>
|
||||
|
||||
PR c++/31246
|
||||
* g++.dg/warn/pr31246.C: New.
|
||||
* g++.dg/warn/pr31246-2.C: New.
|
||||
|
||||
2009-07-07 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/35828
|
||||
|
9
gcc/testsuite/g++.dg/warn/pr31246-2.C
Normal file
9
gcc/testsuite/g++.dg/warn/pr31246-2.C
Normal file
@ -0,0 +1,9 @@
|
||||
// PR 31246
|
||||
// { dg-do compile }
|
||||
// { dg-options "-Wunreachable-code" }
|
||||
#include <new>
|
||||
|
||||
int* get_ptr(void* ptr)
|
||||
{
|
||||
return new(ptr) int();
|
||||
}
|
9
gcc/testsuite/g++.dg/warn/pr31246.C
Normal file
9
gcc/testsuite/g++.dg/warn/pr31246.C
Normal file
@ -0,0 +1,9 @@
|
||||
// PR 31246
|
||||
// { dg-do compile }
|
||||
// { dg-options "-Wunreachable-code -D_GLIBCXX_DEBUG" }
|
||||
#include <vector>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::vector<int>::iterator a;
|
||||
}
|
@ -1638,6 +1638,8 @@ remove_useless_stmts_warn_notreached (gimple_seq stmts)
|
||||
{
|
||||
gimple stmt = gsi_stmt (gsi);
|
||||
|
||||
if (gimple_no_warning_p (stmt)) return false;
|
||||
|
||||
if (gimple_has_location (stmt))
|
||||
{
|
||||
location_t loc = gimple_location (stmt);
|
||||
|
Loading…
Reference in New Issue
Block a user