From: Martin Liska Date: Wed, 22 Mar 2017 12:30:42 +0000 (+0100) Subject: Backport r237353,r245997,r246027 X-Git-Tag: releases/gcc-5.5.0~448 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0e1a6859c9ba166adcc8ac76e9a78666a6f597c3;p=thirdparty%2Fgcc.git Backport r237353,r245997,r246027 2017-03-22 Martin Liska Backport from mainline 2016-06-13 Martin Liska PR target/65705 PR target/69804 PR sanitizer/71458 * toplev.c (process_options): Enable MPX with LSAN and UBSAN. * tree-chkp.c (chkp_walk_pointer_assignments): Verify that FIELD != NULL. 2017-03-22 Martin Liska Backport from mainline 2016-06-13 Martin Liska PR sanitizer/71458 * gcc.target/i386/pr71458.c: New test. From-SVN: r246373 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1fb90dbb7a07..afa1abf4c41f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2017-03-22 Martin Liska + + Backport from mainline + 2016-06-13 Martin Liska + + PR target/65705 + PR target/69804 + PR sanitizer/71458 + + * toplev.c (process_options): Enable MPX with LSAN and UBSAN. + * tree-chkp.c (chkp_walk_pointer_assignments): Verify that + FIELD != NULL. + 2017-03-22 Martin Liska Backport from mainline diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 93c381c7ba73..c32a149b563c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2017-03-22 Martin Liska + + Backport from mainline + 2016-06-13 Martin Liska + + PR sanitizer/71458 + * gcc.target/i386/pr71458.c: New test. + 2017-03-22 Martin Liska Backport from mainline diff --git a/gcc/testsuite/gcc.target/i386/pr71458.c b/gcc/testsuite/gcc.target/i386/pr71458.c new file mode 100644 index 000000000000..d36b61cbe02f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr71458.c @@ -0,0 +1,7 @@ +/* { dg-do compile { target { ! x32 } } } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=bounds" } */ +/* { dg-error "'-fcheck-pointer-bounds' is not supported with '-fsanitize=bounds'" "" { target *-*-* } 0 } */ + +enum {} a[0]; +void fn1(int); +void fn2() { fn1(a[-1]); } diff --git a/gcc/toplev.c b/gcc/toplev.c index cb6c51739ffc..c565ea4797e3 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1367,16 +1367,33 @@ process_options (void) { if (targetm.chkp_bound_mode () == VOIDmode) { - error ("-fcheck-pointer-bounds is not supported for this target"); + error ("%<-fcheck-pointer-bounds%> is not supported for this " + "target"); flag_check_pointer_bounds = 0; } + if (flag_sanitize & SANITIZE_BOUNDS) + { + error ("%<-fcheck-pointer-bounds%> is not supported with " + "%<-fsanitize=bounds%>"); + flag_check_pointer_bounds = 0; + } + if (flag_sanitize & SANITIZE_ADDRESS) { - error ("-fcheck-pointer-bounds is not supported with " + error ("%<-fcheck-pointer-bounds%> is not supported with " "Address Sanitizer"); flag_check_pointer_bounds = 0; } + + if (flag_sanitize & SANITIZE_THREAD) + { + error (UNKNOWN_LOCATION, + "%<-fcheck-pointer-bounds%> is not supported with " + "Thread Sanitizer"); + + flag_check_pointer_bounds = 0; + } } /* One region RA really helps to decrease the code size. */ diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index 237399ecc960..049bafae4e2d 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -3690,7 +3690,7 @@ chkp_walk_pointer_assignments (tree lhs, tree rhs, void *arg, FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (rhs), cnt, field, val) { - if (chkp_type_has_pointer (TREE_TYPE (field))) + if (field && chkp_type_has_pointer (TREE_TYPE (field))) { tree lhs_field = chkp_build_component_ref (lhs, field); chkp_walk_pointer_assignments (lhs_field, val, arg, handler);