Currently, use-after-scope relies on fact that entry point of gimplify_decl_expr
is gimplify_function_tree. Fixed by checking if asan_poisoned_variables is 
non-null.

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

Ready to be installed?
Martin
>From 6acf276399b574ced231096eb1eceb32771118e3 Mon Sep 17 00:00:00 2001
From: marxin <mli...@suse.cz>
Date: Thu, 15 Dec 2016 18:23:24 +0100
Subject: [PATCH] Do not sanitize in lower_omp_target context (PR
 sanitizer/78815).

gcc/ChangeLog:

2016-12-15  Martin Liska  <mli...@suse.cz>

	PR sanitizer/78815
	* gimplify.c (gimplify_decl_expr): Do not sanitize
	in lower_omp_target context.
---
 gcc/gimplify.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index b738855a637..02c6eea638b 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1619,12 +1619,17 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
 	  is_vla = true;
 	}
 
+      /* If gimplify_decl_expr is called from lower_omp_target context, then
+	 asan_poisoned_varibles will be NULL and we do not want to sanitize
+	 in such case.  */
+
       if (asan_sanitize_use_after_scope ()
 	  && !asan_no_sanitize_address_p ()
 	  && !is_vla
 	  && TREE_ADDRESSABLE (decl)
 	  && !TREE_STATIC (decl)
 	  && !DECL_HAS_VALUE_EXPR_P (decl)
+	  && asan_poisoned_variables
 	  && dbg_cnt (asan_use_after_scope))
 	{
 	  asan_poisoned_variables->add (decl);
-- 
2.11.0

Reply via email to