This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: operator new returns nonzero
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marc Glisse <marc dot glisse at inria dot fr>
- Cc: Mike Stump <mikestump at comcast dot net>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 2 Oct 2013 09:06:30 +0200
- Subject: Re: operator new returns nonzero
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 02 dot 1309071206340 dot 19326 at stedding dot saclay dot inria dot fr> <7209CCD2-9BA5-4CD2-8A2B-9DEF2D2C88D2 at comcast dot net> <alpine dot DEB dot 2 dot 10 dot 1309072117090 dot 3585 at laptop-mg dot saclay dot inria dot fr> <7BED207A-EE03-4C7B-9716-33D76FE3649E at comcast dot net> <alpine dot DEB dot 2 dot 02 dot 1309072256440 dot 4641 at stedding dot saclay dot inria dot fr> <alpine dot DEB dot 2 dot 02 dot 1309092247150 dot 14523 at stedding dot saclay dot inria dot fr>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Mon, Sep 09, 2013 at 10:49:40PM +0200, Marc Glisse wrote:
> --- fold-const.c (revision 202413)
> +++ fold-const.c (working copy)
> @@ -16171,21 +16171,31 @@ tree_expr_nonzero_warnv_p (tree t, bool
> case MODIFY_EXPR:
> case BIND_EXPR:
> return tree_expr_nonzero_warnv_p (TREE_OPERAND (t, 1),
> strict_overflow_p);
>
> case SAVE_EXPR:
> return tree_expr_nonzero_warnv_p (TREE_OPERAND (t, 0),
> strict_overflow_p);
>
> case CALL_EXPR:
> - return alloca_call_p (t);
> + {
> + tree fn = CALL_EXPR_FN (t);
> + if (TREE_CODE (fn) != ADDR_EXPR) return false;
> + tree fndecl = TREE_OPERAND (fn, 0);
> + if (TREE_CODE (fndecl) != FUNCTION_DECL) return false;
> + if (flag_delete_null_pointer_checks && !flag_check_new
> + && DECL_IS_OPERATOR_NEW (fndecl)
> + && !TREE_NOTHROW (fndecl))
> + return true;
> + return alloca_call_p (t);
Not commenting on what this patch does, but how:
why don't you use tree fndecl = get_callee_fndecl (t);
if (fndecl && ...) return true; instead? Perhaps alloca_call_p should use
it too.
Jakub