This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Handle POINTER_DIFF_EXPR in chkp


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]