aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2016-11-08 13:28:33 +0100
committerMartin Liska <marxin@gcc.gnu.org>2016-11-08 12:28:33 +0000
commitfcd1b8dffcaa5806e62d0203b13ad1696fec254f (patch)
tree60e233b74357c8dd648d02460fdf3495684deb06 /gcc/gimplify.c
parentf9ef2c765ad3fce93ddacdabede6b67efdc13c0d (diff)
downloadgcc-fcd1b8dffcaa5806e62d0203b13ad1696fec254f.zip
gcc-fcd1b8dffcaa5806e62d0203b13ad1696fec254f.tar.gz
gcc-fcd1b8dffcaa5806e62d0203b13ad1696fec254f.tar.bz2
use-after-scope fallout
PR testsuite/78242 * g++.dg/asan/use-after-scope-4.C: New test. * g++.dg/asan/use-after-scope-types-4.C: Update scanned pattern. * gcc.dg/asan/use-after-scope-8.c: Remove. PR testsuite/78242 * dbgcnt.def: Add new debug counter asan_use_after_scope. * gimplify.c (gimplify_decl_expr): Do not sanitize vars with a value expr. Do not add artificial variables to live_switch_vars. Use the debug counter. (gimplify_target_expr): Use the debug counter. * internal-fn.def: Remove ECF_TM_PURE from ASAN_MARK builtin. * sanitizer.def: Set ATTR_NOTHROW_LEAF_LIST to BUILT_IN_ASAN_CLOBBER_N and BUILT_IN_ASAN_UNCLOBBER_N. From-SVN: r241961
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index e5930e6..d392450 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -60,6 +60,7 @@ along with GCC; see the file COPYING3. If not see
#include "langhooks-def.h" /* FIXME: for lhd_set_decl_assembler_name */
#include "builtins.h"
#include "asan.h"
+#include "dbgcnt.h"
/* Hash set of poisoned variables in a bind expr. */
static hash_set<tree> *asan_poisoned_variables = NULL;
@@ -1622,11 +1623,13 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
&& !asan_no_sanitize_address_p ()
&& !is_vla
&& TREE_ADDRESSABLE (decl)
- && !TREE_STATIC (decl))
+ && !TREE_STATIC (decl)
+ && !DECL_HAS_VALUE_EXPR_P (decl)
+ && dbg_cnt (asan_use_after_scope))
{
asan_poisoned_variables->add (decl);
asan_poison_variable (decl, false, seq_p);
- if (gimplify_ctxp->live_switch_vars)
+ if (!DECL_ARTIFICIAL (decl) && gimplify_ctxp->live_switch_vars)
gimplify_ctxp->live_switch_vars->add (decl);
}
@@ -6399,7 +6402,8 @@ gimplify_target_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
else
cleanup = clobber;
}
- if (asan_sanitize_use_after_scope ())
+ if (asan_sanitize_use_after_scope ()
+ && dbg_cnt (asan_use_after_scope))
{
tree asan_cleanup = build_asan_poison_call_expr (temp);
if (asan_cleanup)