aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2013-10-03 18:13:54 +0200
committerMarc Glisse <glisse@gcc.gnu.org>2013-10-03 16:13:54 +0000
commit2284b03444d6845ce6402db37f4ec43f6c755f77 (patch)
tree626a1783dbadedeb04e9dc7b74807b9ad23cc8c7 /gcc/tree-vrp.c
parent0609bdf2114919b570e7a3c4ab273fdf16262a4b (diff)
downloadgcc-2284b03444d6845ce6402db37f4ec43f6c755f77.zip
gcc-2284b03444d6845ce6402db37f4ec43f6c755f77.tar.gz
gcc-2284b03444d6845ce6402db37f4ec43f6c755f77.tar.bz2
re PR c++/19476 (Missed null checking elimination with new)
2013-10-03 Marc Glisse <marc.glisse@inria.fr> PR c++/19476 gcc/c-family/ * c.opt (fcheck-new): Move to common.opt. gcc/ * common.opt (fcheck-new): Moved from c.opt. Make it 'Common'. * calls.c (alloca_call_p): Use get_callee_fndecl. * fold-const.c (tree_expr_nonzero_warnv_p): Handle operator new. * tree-vrp.c (gimple_stmt_nonzero_warnv_p, stmt_interesting_for_vrp): Likewise. (vrp_visit_stmt): Remove duplicated code. gcc/testsuite/ * g++.dg/tree-ssa/pr19476-1.C: New file. * g++.dg/tree-ssa/pr19476-2.C: Likewise. * g++.dg/tree-ssa/pr19476-3.C: Likewise. * g++.dg/tree-ssa/pr19476-4.C: Likewise. From-SVN: r203163
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r--gcc/tree-vrp.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 3464529..cf0f1b1 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -1051,7 +1051,15 @@ gimple_stmt_nonzero_warnv_p (gimple stmt, bool *strict_overflow_p)
case GIMPLE_ASSIGN:
return gimple_assign_nonzero_warnv_p (stmt, strict_overflow_p);
case GIMPLE_CALL:
- return gimple_alloca_call_p (stmt);
+ {
+ tree fndecl = gimple_call_fndecl (stmt);
+ if (!fndecl) return false;
+ if (flag_delete_null_pointer_checks && !flag_check_new
+ && DECL_IS_OPERATOR_NEW (fndecl)
+ && !TREE_NOTHROW (fndecl))
+ return true;
+ return gimple_alloca_call_p (stmt);
+ }
default:
gcc_unreachable ();
}
@@ -6490,7 +6498,8 @@ stmt_interesting_for_vrp (gimple stmt)
|| POINTER_TYPE_P (TREE_TYPE (lhs)))
&& ((is_gimple_call (stmt)
&& gimple_call_fndecl (stmt) != NULL_TREE
- && DECL_BUILT_IN (gimple_call_fndecl (stmt)))
+ && (DECL_BUILT_IN (gimple_call_fndecl (stmt))
+ || DECL_IS_OPERATOR_NEW (gimple_call_fndecl (stmt))))
|| !gimple_vuse (stmt)))
return true;
}
@@ -7411,16 +7420,7 @@ vrp_visit_stmt (gimple stmt, edge *taken_edge_p, tree *output_p)
if (!stmt_interesting_for_vrp (stmt))
gcc_assert (stmt_ends_bb_p (stmt));
else if (is_gimple_assign (stmt) || is_gimple_call (stmt))
- {
- /* In general, assignments with virtual operands are not useful
- for deriving ranges, with the obvious exception of calls to
- builtin functions. */
- if ((is_gimple_call (stmt)
- && gimple_call_fndecl (stmt) != NULL_TREE
- && DECL_BUILT_IN (gimple_call_fndecl (stmt)))
- || !gimple_vuse (stmt))
- return vrp_visit_assignment_or_call (stmt, output_p);
- }
+ return vrp_visit_assignment_or_call (stmt, output_p);
else if (gimple_code (stmt) == GIMPLE_COND)
return vrp_visit_cond_stmt (stmt, taken_edge_p);
else if (gimple_code (stmt) == GIMPLE_SWITCH)