From 78188a05d0f423b99edee82bce01fdad35e3c37b Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Wed, 11 Oct 2017 14:24:44 +0200 Subject: [PATCH] Do not handled volatile arguments (PR sanitizer/82484). 2017-10-11 Martin Liska PR sanitizer/82484 * sanopt.c (sanitize_rewrite_addressable_params): Do not handle volatile arguments. 2017-10-11 Martin Liska PR sanitizer/82484 * gcc.dg/asan/pr82484.c: New test. From-SVN: r253637 --- gcc/ChangeLog | 6 ++++++ gcc/sanopt.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/asan/pr82484.c | 5 +++++ 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/asan/pr82484.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 507859b0fcd..6b02c6216bb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-10-11 Martin Liska + + PR sanitizer/82484 + * sanopt.c (sanitize_rewrite_addressable_params): Do not handle + volatile arguments. + 2017-10-11 Adhemerval Zanella * config.gcc (default_gnu_indirect_function): Default to yes for diff --git a/gcc/sanopt.c b/gcc/sanopt.c index 997bcfd3df7..019cf9fa81c 100644 --- a/gcc/sanopt.c +++ b/gcc/sanopt.c @@ -1140,7 +1140,9 @@ sanitize_rewrite_addressable_params (function *fun) arg; arg = DECL_CHAIN (arg)) { tree type = TREE_TYPE (arg); - if (TREE_ADDRESSABLE (arg) && !TREE_ADDRESSABLE (type) + if (TREE_ADDRESSABLE (arg) + && !TREE_ADDRESSABLE (type) + && !TREE_THIS_VOLATILE (arg) && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST) { TREE_ADDRESSABLE (arg) = 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8b60350710d..b6093d079ea 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-10-11 Martin Liska + + PR sanitizer/82484 + * gcc.dg/asan/pr82484.c: New test. + 2017-10-11 Martin Liska * c-c++-common/ubsan/ptr-overflow-sanitization-1.c: Scan diff --git a/gcc/testsuite/gcc.dg/asan/pr82484.c b/gcc/testsuite/gcc.dg/asan/pr82484.c new file mode 100644 index 00000000000..f8051bd300c --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr82484.c @@ -0,0 +1,5 @@ +/* PR sanitizer/82484 */ +/* { dg-do compile } */ + +void foo(volatile int *ptr); +void a (volatile int b) { foo(&b); } -- 2.30.2