This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Do not handle VLA in sanitization (PR sanitizer/81460).
- From: Martin Liška <mliska at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Jakub Jelinek <jakub at redhat dot com>
- Date: Fri, 28 Jul 2017 10:44:36 +0200
- Subject: [PATCH] Do not handle VLA in sanitization (PR sanitizer/81460).
- Authentication-results: sourceware.org; auth=none
Hi.
Simple patch that bails out when having a variable-length parameter of a function.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
Ready to be installed?
Martin
gcc/ChangeLog:
2017-07-17 Martin Liska <mliska@suse.cz>
PR sanitizer/81460
* sanopt.c (sanitize_rewrite_addressable_params): Do not rewrite
parameters that are of a variable-length.
gcc/testsuite/ChangeLog:
2017-07-17 Martin Liska <mliska@suse.cz>
PR sanitizer/81460
* gcc.dg/asan/pr81460.c: New test.
---
gcc/sanopt.c | 5 +++--
gcc/testsuite/gcc.dg/asan/pr81460.c | 8 ++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/asan/pr81460.c
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/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];
+}