One more also for GCC 5 branch. Martin
>From 6853238cc8103fefb8b8acc8f56d444860495714 Mon Sep 17 00:00:00 2001 From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4> Date: Fri, 11 Aug 2017 10:01:13 +0000 Subject: [PATCH] Backport r251049
gcc/ChangeLog: 2017-08-11 Martin Liska <mli...@suse.cz> PR tree-opt/79987 * tree-chkp.c (chkp_get_bounds_for_decl_addr): Do not instrument variables of void type. gcc/testsuite/ChangeLog: 2017-08-11 Martin Liska <mli...@suse.cz> PR tree-opt/79987 * gcc.target/i386/mpx/pr79987.c: New test. --- gcc/testsuite/gcc.target/i386/mpx/pr79987.c | 5 +++++ gcc/tree-chkp.c | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr79987.c 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 00000000000..b3ebda95694 --- /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 2901e8b354d..28dac22add6 100644 --- a/gcc/tree-chkp.c +++ b/gcc/tree-chkp.c @@ -3144,6 +3144,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 && TREE_CODE (decl) == VAR_DECL && (TREE_STATIC (decl) -- 2.14.1