Do not handled volatile arguments (PR sanitizer/82484).
authorMartin Liska <mliska@suse.cz>
Thu, 1 Mar 2018 14:54:10 +0000 (15:54 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Thu, 1 Mar 2018 14:54:10 +0000 (14:54 +0000)
2018-03-01  Martin Liska  <mliska@suse.cz>

PR sanitizer/82484
* sanopt.c (sanitize_rewrite_addressable_params): Do not handle
volatile arguments.
2018-03-01  Martin Liska  <mliska@suse.cz>

PR sanitizer/82484
* gcc.dg/asan/pr82484.c: New test.

From-SVN: r258101

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

index 879694331189394ab2ab6f86a03720b85b37c532..ff97b4bb6063b3b1c5c7645a400aba4352873537 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-01  Martin Liska  <mliska@suse.cz>
+
+       PR sanitizer/82484
+       * sanopt.c (sanitize_rewrite_addressable_params): Do not handle
+       volatile arguments.
+
 2018-03-01  Richard Biener  <rguenther@suse.de>
 
        PR debug/84645
index cd94638c869230c96ee63b78394658161430748b..43743130a35a76ca47f36ef4f8494cab807b4bd2 100644 (file)
@@ -1143,7 +1143,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;
index a9e12bef2b48813b1dc5f23872351137fe8efda9..d1acff64fb9839352b5ca288e2ae1dbbcc58b051 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-01  Martin Liska  <mliska@suse.cz>
+
+       PR sanitizer/82484
+       * gcc.dg/asan/pr82484.c: New test.
+
 2018-03-01  Richard Biener  <rguenther@suse.de>
 
        PR debug/84645
diff --git a/gcc/testsuite/gcc.dg/asan/pr82484.c b/gcc/testsuite/gcc.dg/asan/pr82484.c
new file mode 100644 (file)
index 0000000..f8051bd
--- /dev/null
@@ -0,0 +1,5 @@
+/* PR sanitizer/82484 */
+/* { dg-do compile } */
+
+void foo(volatile int *ptr);
+void a (volatile int b) { foo(&b); }