diff mbox series

Sanopt: ignore params with DECL_HAS_VALUE_EXPR_P (PR sanitizer/86962).

Message ID 04eebc30-8dfd-0170-0e6d-7833f09ef4a0@suse.cz
State New
Headers show
Series Sanopt: ignore params with DECL_HAS_VALUE_EXPR_P (PR sanitizer/86962). | expand

Commit Message

Martin Liška Aug. 27, 2018, 1 p.m. UTC
Hello.

In case of nested functions it may happen that we end up
with a PARAM_DECL with DECL_HAS_VALUE_EXPR_P. If would
skip these.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

gcc/ChangeLog:

2018-08-16  Martin Liska  <mliska@suse.cz>

        PR sanitizer/86962
	* sanopt.c (sanitize_rewrite_addressable_params): Ignore
        params with DECL_HAS_VALUE_EXPR_P.

gcc/testsuite/ChangeLog:

2018-08-16  Martin Liska  <mliska@suse.cz>

        PR sanitizer/86962
	* gcc.dg/asan/pr86962.c: New test.
---
 gcc/sanopt.c                        |  6 ++++--
 gcc/testsuite/gcc.dg/asan/pr86962.c | 13 +++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/asan/pr86962.c

Comments

Jakub Jelinek Aug. 27, 2018, 1:03 p.m. UTC | #1
On Mon, Aug 27, 2018 at 03:00:18PM +0200, Martin Liška wrote:
> Hello.
> 
> In case of nested functions it may happen that we end up
> with a PARAM_DECL with DECL_HAS_VALUE_EXPR_P. If would
> skip these.
> 
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
> 
> Ready to be installed?
> Martin
> 
> gcc/ChangeLog:
> 
> 2018-08-16  Martin Liska  <mliska@suse.cz>
> 
>         PR sanitizer/86962
> 	* sanopt.c (sanitize_rewrite_addressable_params): Ignore
>         params with DECL_HAS_VALUE_EXPR_P.
> 
> gcc/testsuite/ChangeLog:
> 
> 2018-08-16  Martin Liska  <mliska@suse.cz>
> 
>         PR sanitizer/86962
> 	* gcc.dg/asan/pr86962.c: New test.

Ok, but watch for the spaces in the ChangeLog entry.

	Jakub
diff mbox series

Patch

diff --git a/gcc/sanopt.c b/gcc/sanopt.c
index 223c06a8355..082f936adb5 100644
--- a/gcc/sanopt.c
+++ b/gcc/sanopt.c
@@ -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.  */
diff --git a/gcc/testsuite/gcc.dg/asan/pr86962.c b/gcc/testsuite/gcc.dg/asan/pr86962.c
new file mode 100644
index 00000000000..7a8cfa98f0e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/pr86962.c
@@ -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);
+}