aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family/c-gimplify.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-06-13 23:01:44 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2016-06-13 23:01:44 +0200
commit0dda258b6f3194849dc9a47aa9417d7ce942a3ec (patch)
treefae907821c12aec70cd88accb0a2ed6e5aa80ad2 /gcc/c-family/c-gimplify.c
parentef7cf206b6f9fd93ac41393829f79164b8adad1b (diff)
downloadgcc-0dda258b6f3194849dc9a47aa9417d7ce942a3ec.zip
gcc-0dda258b6f3194849dc9a47aa9417d7ce942a3ec.tar.gz
gcc-0dda258b6f3194849dc9a47aa9417d7ce942a3ec.tar.bz2
re PR sanitizer/71498 (ubsan bounds checking influenced by surrounding code)
PR sanitizer/71498 * c-gimplify.c (ubsan_walk_array_refs_r): Set *walk_subtrees = 0 on all BIND_EXPRs, and on all BIND_EXPRs recurse also on BIND_EXPR_BODY. * c-c++-common/ubsan/bounds-13.c: New test. From-SVN: r237409
Diffstat (limited to 'gcc/c-family/c-gimplify.c')
-rw-r--r--gcc/c-family/c-gimplify.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c
index 0757193..c18b057 100644
--- a/gcc/c-family/c-gimplify.c
+++ b/gcc/c-family/c-gimplify.c
@@ -67,23 +67,23 @@ ubsan_walk_array_refs_r (tree *tp, int *walk_subtrees, void *data)
{
hash_set<tree> *pset = (hash_set<tree> *) data;
- /* Since walk_tree doesn't call the callback function on the decls
- in BIND_EXPR_VARS, we have to walk them manually. */
if (TREE_CODE (*tp) == BIND_EXPR)
{
+ /* Since walk_tree doesn't call the callback function on the decls
+ in BIND_EXPR_VARS, we have to walk them manually, so we can avoid
+ instrumenting DECL_INITIAL of TREE_STATIC vars. */
+ *walk_subtrees = 0;
for (tree decl = BIND_EXPR_VARS (*tp); decl; decl = DECL_CHAIN (decl))
{
if (TREE_STATIC (decl))
- {
- *walk_subtrees = 0;
- continue;
- }
+ continue;
walk_tree (&DECL_INITIAL (decl), ubsan_walk_array_refs_r, pset,
pset);
walk_tree (&DECL_SIZE (decl), ubsan_walk_array_refs_r, pset, pset);
walk_tree (&DECL_SIZE_UNIT (decl), ubsan_walk_array_refs_r, pset,
pset);
}
+ walk_tree (&BIND_EXPR_BODY (*tp), ubsan_walk_array_refs_r, pset, pset);
}
else if (TREE_CODE (*tp) == ADDR_EXPR
&& TREE_CODE (TREE_OPERAND (*tp, 0)) == ARRAY_REF)