Do not instrument void variables with MPX (PR tree-opt/79987).
authorMartin Liska <mliska@suse.cz>
Fri, 11 Aug 2017 10:01:13 +0000 (12:01 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 11 Aug 2017 10:01:13 +0000 (10:01 +0000)
2017-08-11  Martin Liska  <mliska@suse.cz>

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  <mliska@suse.cz>

PR tree-opt/79987
* gcc.target/i386/mpx/pr79987.c: New test.

From-SVN: r251049

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/mpx/pr79987.c [new file with mode: 0644]
gcc/tree-chkp.c

index a926516ed778043eba36e86bd4e2a9b5de3f977b..9be7f17931cdbd6ecfaae15e6add508ccddaabea 100644 (file)
@@ -1,3 +1,9 @@
+2017-08-11  Martin Liska  <mliska@suse.cz>
+
+       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  <mliska@suse.cz>
 
        * asan.c (asan_protect_global): Replace ASM_OUTPUT_DEF with
index 76c07405a0de791e48dcb34845d1d70f90c94b5c..80ee13eaaa0f20acdc8c488b13e85944b9ad69f9 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-11  Martin Liska  <mliska@suse.cz>
+
+       PR tree-opt/79987
+       * gcc.target/i386/mpx/pr79987.c: New test.
+
 2017-08-11  Martin Liska  <mliska@suse.cz>
 
        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 (file)
index 0000000..b3ebda9
--- /dev/null
@@ -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." } */
index 12af458fb90d79a0df94125075c1a3db2b98e5f2..951aec10b3ad8ce2e8fa79c3baf769eee92e27ed 100644 (file)
@@ -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)