From fe8a99d8cdcfacf14b603b99a7730d18ce0ccd1f Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 11 Aug 2017 12:01:13 +0200 Subject: [PATCH] Do not instrument void variables with MPX (PR tree-opt/79987). 2017-08-11 Martin Liska PR tree-opt/79987 * tree-chkp.c (chkp_get_bounds_for_decl_addr): Do not instrument variables of void type. 2017-08-11 Martin Liska PR tree-opt/79987 * gcc.target/i386/mpx/pr79987.c: New test. From-SVN: r251049 --- gcc/ChangeLog | 6 ++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/mpx/pr79987.c | 5 +++++ gcc/tree-chkp.c | 3 +++ 4 files changed, 19 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr79987.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a926516ed778..9be7f17931cd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-08-11 Martin Liska + + PR tree-opt/79987 + * tree-chkp.c (chkp_get_bounds_for_decl_addr): Do not instrument + variables of void type. + 2017-08-11 Martin Liska * asan.c (asan_protect_global): Replace ASM_OUTPUT_DEF with diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 76c07405a0de..80ee13eaaa0f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-08-11 Martin Liska + + PR tree-opt/79987 + * gcc.target/i386/mpx/pr79987.c: New test. + 2017-08-11 Martin Liska PR ipa/81213 diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79987.c b/gcc/testsuite/gcc.target/i386/mpx/pr79987.c new file mode 100644 index 000000000000..b3ebda956945 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/mpx/pr79987.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */ + +extern void foo; +void *bar = &foo; /* { dg-warning "taking address of expression of type .void." } */ diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c index 12af458fb90d..951aec10b3ad 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -3197,6 +3197,9 @@ chkp_get_bounds_for_decl_addr (tree decl) && !flag_chkp_incomplete_type) return chkp_get_zero_bounds (); + if (VOID_TYPE_P (TREE_TYPE (decl))) + return chkp_get_zero_bounds (); + if (flag_chkp_use_static_bounds && VAR_P (decl) && (TREE_STATIC (decl) -- 2.39.5