From: Jakub Jelinek Date: Sat, 2 Dec 2017 07:58:05 +0000 (+0100) Subject: tree-chkp.c (chkp_compute_bounds_for_assignment): Handle POINTER_DIFF_EXPR. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=edb48cdb9f8dcc52b20f12785a1d570084597842;p=gcc.git tree-chkp.c (chkp_compute_bounds_for_assignment): Handle POINTER_DIFF_EXPR. * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f1ce29112e0..40ef3d03f44 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,8 @@ 2017-12-02 Jakub Jelinek + * 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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eedf1a87960..c66f31483e5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2017-12-02 Jakub Jelinek + * 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 index 00000000000..657991979f6 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/pointer-diff-1.c @@ -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" } */ +} diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index 6d24355aba6..8296786bf2d 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -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;