Do not handle VLA in sanitization (PR sanitizer/81460).
authorMartin Liska <mliska@suse.cz>
Fri, 28 Jul 2017 10:36:36 +0000 (12:36 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 28 Jul 2017 10:36:36 +0000 (10:36 +0000)
2017-07-28  Martin Liska  <mliska@suse.cz>

PR sanitizer/81460
* sanopt.c (sanitize_rewrite_addressable_params): Do not rewrite
parameters that are of a variable-length.
2017-07-28  Martin Liska  <mliska@suse.cz>

PR sanitizer/81460
* gcc.dg/asan/pr81460.c: New test.

From-SVN: r250655

gcc/ChangeLog
gcc/sanopt.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/asan/pr81460.c [new file with mode: 0644]

index 6b9a588ec43a1a7c814f1402b17e76f9ef6170b7..e5b2be586f1283fa0f733b17a44f4db8a1a1a41f 100644 (file)
@@ -1,3 +1,9 @@
+2017-07-28  Martin Liska  <mliska@suse.cz>
+
+       PR sanitizer/81460
+       * sanopt.c (sanitize_rewrite_addressable_params): Do not rewrite
+       parameters that are of a variable-length.
+
 2017-07-28  Sebastian Huber  <sebastian.huber@embedded-brains.de>
 
        * config.gcc (powerpc-*-rtems*): Remove rs6000/eabi.h.  Add
index b7740741d43a68d03ffa4f36f886c53c669f7305..f6a3d6eadc7c76d0e99cf38bad946c5fcb4a168d 100644 (file)
@@ -894,11 +894,12 @@ sanitize_rewrite_addressable_params (function *fun)
   for (tree arg = DECL_ARGUMENTS (current_function_decl);
        arg; arg = DECL_CHAIN (arg))
     {
-      if (TREE_ADDRESSABLE (arg) && !TREE_ADDRESSABLE (TREE_TYPE (arg)))
+      tree type = TREE_TYPE (arg);
+      if (TREE_ADDRESSABLE (arg) && !TREE_ADDRESSABLE (type)
+         && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
        {
          TREE_ADDRESSABLE (arg) = 0;
          /* The parameter is no longer addressable.  */
-         tree type = TREE_TYPE (arg);
          has_any_addressable_param = true;
 
          /* Create a new automatic variable.  */
index 19f10701053bbbfa7b981770fcf9a6ea8708fc3e..26c47b21f43c9ec4976d2d9da8721cbd02b025b6 100644 (file)
@@ -1,3 +1,8 @@
+2017-07-28  Martin Liska  <mliska@suse.cz>
+
+       PR sanitizer/81460
+       * gcc.dg/asan/pr81460.c: New test.
+
 2017-07-28  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/81578
diff --git a/gcc/testsuite/gcc.dg/asan/pr81460.c b/gcc/testsuite/gcc.dg/asan/pr81460.c
new file mode 100644 (file)
index 0000000..00c1bb7
--- /dev/null
@@ -0,0 +1,8 @@
+/* PR sanitizer/80460 */
+/* { dg-do compile } */
+
+int
+f (int a, struct { int b[a]; } c) /* { dg-warning "anonymous struct declared inside parameter list will not be visible outside of this definition or declaration" } */
+{
+  return c.b[0];
+}