tree-chkp.c (chkp_compute_bounds_for_assignment): Handle POINTER_DIFF_EXPR.
authorJakub Jelinek <jakub@redhat.com>
Sat, 2 Dec 2017 07:58:05 +0000 (08:58 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 2 Dec 2017 07:58:05 +0000 (08:58 +0100)
* tree-chkp.c (chkp_compute_bounds_for_assignment): Handle
POINTER_DIFF_EXPR.

* gcc.target/i386/mpx/pointer-diff-1.c: New test.

From-SVN: r255355

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c [new file with mode: 0644]
gcc/tree-chkp.c

index f1ce29112e05d63164d6ea61981db224963130e7..40ef3d03f44aafaa55aa5d6d868f9660896fc772 100644 (file)
@@ -1,5 +1,8 @@
 2017-12-02  Jakub Jelinek  <jakub@redhat.com>
 
+       * tree-chkp.c (chkp_compute_bounds_for_assignment): Handle
+       POINTER_DIFF_EXPR.
+
        PR c++/81212
        * tree-cfg.c (pass_warn_function_return::execute): Handle
        __builtin_ubsan_handle_missing_return like __builtin_unreachable
index eedf1a87960490717fc1ec933e07c01e1b24494d..c66f31483e51222df7d344e929298eb2f9691adb 100644 (file)
@@ -1,5 +1,7 @@
 2017-12-02  Jakub Jelinek  <jakub@redhat.com>
 
+       * gcc.target/i386/mpx/pointer-diff-1.c: New test.
+
        PR c++/81212
        * g++.dg/ubsan/pr81212.C: New test.
        * g++.dg/ubsan/return-1.C: Add -Wno-return-type to dg-options.
diff --git a/gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c b/gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c
new file mode 100644 (file)
index 0000000..6579919
--- /dev/null
@@ -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" } */
+}
index 6d24355aba6f2afe4acb96075bc465ea260f3468..8296786bf2df35f396843f1b43e634d39db985d4 100644 (file)
@@ -2762,6 +2762,7 @@ chkp_compute_bounds_for_assignment (tree node, gimple *assign)
     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;