This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Handle POINTER_DIFF_EXPR in chkp
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Biener <rguenther at suse dot de>, Ilya Enkovich <enkovich dot gnu at gmail dot com>, Kirill Yukhin <kirill dot yukhin at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sat, 2 Dec 2017 01:14:03 +0100
- Subject: [PATCH] Handle POINTER_DIFF_EXPR in chkp
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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?
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