Sanopt: ignore params with DECL_HAS_VALUE_EXPR_P (PR sanitizer/86962).
authorMartin Liska <mliska@suse.cz>
Mon, 27 Aug 2018 13:21:28 +0000 (15:21 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Mon, 27 Aug 2018 13:21:28 +0000 (13:21 +0000)
2018-08-27  Martin Liska  <mliska@suse.cz>

        PR sanitizer/86962
* sanopt.c (sanitize_rewrite_addressable_params): Ignore
        params with DECL_HAS_VALUE_EXPR_P.
2018-08-27  Martin Liska  <mliska@suse.cz>

        PR sanitizer/86962
* gcc.dg/asan/pr86962.c: New test.

From-SVN: r263882

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

index 6c79e41f2db687d182d26e9a497b7eb2fa0a07ee..6a047129086b8ea713cbe277c32f9de57f5262f3 100644 (file)
@@ -1,3 +1,9 @@
+2018-08-27  Martin Liska  <mliska@suse.cz>
+
+       PR sanitizer/86962
+       * sanopt.c (sanitize_rewrite_addressable_params): Ignore
+       params with DECL_HAS_VALUE_EXPR_P.
+
 2018-08-27  Martin Liska  <mliska@suse.cz>
 
        * config/i386/i386.c (ix86_expand_set_or_movmem): Dump
index 223c06a83557ece5caeb7adb639a68b08d6d4f2a..082f936adb50a76bc5e159f37013265c4ec458a0 100644 (file)
@@ -1165,13 +1165,15 @@ sanitize_rewrite_addressable_params (function *fun)
 
          gimple_add_tmp_var (var);
 
+         /* We skip parameters that have a DECL_VALUE_EXPR.  */
+         if (DECL_HAS_VALUE_EXPR_P (arg))
+           continue;
+
          if (dump_file)
            fprintf (dump_file,
                     "Rewriting parameter whose address is taken: %s\n",
                     IDENTIFIER_POINTER (DECL_NAME (arg)));
 
-         gcc_assert (!DECL_HAS_VALUE_EXPR_P (arg));
-
          SET_DECL_PT_UID (var, DECL_PT_UID (arg));
 
          /* Assign value of parameter to newly created variable.  */
index 6e6ffd84ff2a9c256df37c02e0b7cbeefa240369..4f49ffd055aa373eb85eef93eddea61bd74042f5 100644 (file)
@@ -1,3 +1,8 @@
+2018-08-27  Martin Liska  <mliska@suse.cz>
+
+       PR sanitizer/86962
+       * gcc.dg/asan/pr86962.c: New test.
+
 2018-08-27  Martin Liska  <mliska@suse.cz>
 
        * gcc.dg/tree-prof/val-prof-10.c: New test.
diff --git a/gcc/testsuite/gcc.dg/asan/pr86962.c b/gcc/testsuite/gcc.dg/asan/pr86962.c
new file mode 100644 (file)
index 0000000..7a8cfa9
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR sanitizer/86962 */
+/* { dg-do compile } */
+
+extern int dummy (int *);
+
+void foo(int i)
+{
+  int j=i;
+
+  void bar() { int x=j, y=i; }
+
+  dummy(&i);
+}