From 70affe6aff39d347a0e2b7f12a27e1cad4cae405 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 28 Jul 2017 12:36:36 +0200 Subject: [PATCH] Do not handle VLA in sanitization (PR sanitizer/81460). 2017-07-28 Martin Liska PR sanitizer/81460 * sanopt.c (sanitize_rewrite_addressable_params): Do not rewrite parameters that are of a variable-length. 2017-07-28 Martin Liska PR sanitizer/81460 * gcc.dg/asan/pr81460.c: New test. From-SVN: r250655 --- gcc/ChangeLog | 6 ++++++ gcc/sanopt.c | 5 +++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/asan/pr81460.c | 8 ++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/asan/pr81460.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6b9a588ec43..e5b2be586f1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-07-28 Martin Liska + + PR sanitizer/81460 + * sanopt.c (sanitize_rewrite_addressable_params): Do not rewrite + parameters that are of a variable-length. + 2017-07-28 Sebastian Huber * config.gcc (powerpc-*-rtems*): Remove rs6000/eabi.h. Add diff --git a/gcc/sanopt.c b/gcc/sanopt.c index b7740741d43..f6a3d6eadc7 100644 --- a/gcc/sanopt.c +++ b/gcc/sanopt.c @@ -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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 19f10701053..26c47b21f43 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-07-28 Martin Liska + + PR sanitizer/81460 + * gcc.dg/asan/pr81460.c: New test. + 2017-07-28 Jakub Jelinek 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 index 00000000000..00c1bb7c9f2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr81460.c @@ -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]; +} -- 2.30.2