From: jakub Date: Sat, 2 Dec 2017 07:58:05 +0000 (+0000) Subject: * tree-chkp.c (chkp_compute_bounds_for_assignment): Handle X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d459064af3f79cd9fb1f547b6a7bdd8f84c7942e;p=thirdparty%2Fgcc.git * tree-chkp.c (chkp_compute_bounds_for_assignment): Handle POINTER_DIFF_EXPR. * gcc.target/i386/mpx/pointer-diff-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255355 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f1ce29112e05..40ef3d03f44a 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 eedf1a879604..c66f31483e51 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 000000000000..657991979f69 --- /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 6d24355aba6f..8296786bf2df 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;