[PATCH] Handle POINTER_DIFF_EXPR in chkp
Richard Biener
rguenther@suse.de
Sat Dec 2 07:54:00 GMT 2017
On December 2, 2017 1:14:03 AM GMT+01:00, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>The following testcase shows that chkp_compute_bounds_for_assignment
>should know about POINTER_DIFF_EXPR and handle it like it used
>to handle MINUS_EXPR of 2 pointers in the past.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK.
Richard.
>2017-12-01 Jakub Jelinek <jakub@redhat.com>
>
> * tree-chkp.c (chkp_compute_bounds_for_assignment): Handle
> POINTER_DIFF_EXPR.
>
> * gcc.target/i386/mpx/pointer-diff-1.c: New test.
>
>--- gcc/tree-chkp.c.jj 2017-11-13 09:31:29.000000000 +0100
>+++ gcc/tree-chkp.c 2017-12-01 15:11:40.331410514 +0100
>@@ -2762,6 +2762,7 @@ chkp_compute_bounds_for_assignment (tree
> case FLOAT_EXPR:
> case REALPART_EXPR:
> case IMAGPART_EXPR:
>+ case POINTER_DIFF_EXPR:
> /* No valid bounds may be produced by these exprs. */
> bounds = chkp_get_invalid_op_bounds ();
> break;
>--- gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c.jj 2017-12-01
>15:18:52.805002275 +0100
>+++ gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c 2017-12-01
>15:17:35.000000000 +0100
>@@ -0,0 +1,8 @@
>+/* { dg-do compile } */
>+/* { dg-options "-O2 -mmpx -fcheck-pointer-bounds" } */
>+
>+char *
>+foo (char *p, char *q)
>+{
>+ return (char *) (p - q); /* { dg-bogus "pointer bounds were lost due
>to unexpected expression" } */
>+}
>
> Jakub
More information about the Gcc-patches
mailing list