From: Martin Liska Date: Wed, 16 Nov 2016 11:56:58 +0000 (+0100) Subject: Fix PR sanitizer/78270 (part 2) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=080140bc85bd8b5be9634beb8cbc2f0324e1d649;p=gcc.git Fix PR sanitizer/78270 (part 2) PR sanitizer/78270 * gimplify.c (gimplify_switch_expr): Always save previous gimplify_ctxp->live_switch_vars. PR sanitizer/78270 * gcc.dg/asan/pr78270.c: Update comment style. * gcc.dg/asan/pr78270-2.c: New test. From-SVN: r242485 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 40922a098fb..08f0a7c99ec 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-11-16 Martin Liska + + PR sanitizer/78270 + * gimplify.c (gimplify_switch_expr): Always save previous + gimplify_ctxp->live_switch_vars. + 2016-11-16 Andrew Burgess * config/arc/arc.md (movb peephole2): New peephole2 to merge two diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 16573ddaba9..c23888b4624 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -2255,11 +2255,11 @@ gimplify_switch_expr (tree *expr_p, gimple_seq *pre_p) gimplify_ctxp->case_labels.create (8); /* Do not create live_switch_vars if SWITCH_BODY is not a BIND_EXPR. */ + saved_live_switch_vars = gimplify_ctxp->live_switch_vars; if (TREE_CODE (SWITCH_BODY (switch_expr)) == BIND_EXPR) - { - saved_live_switch_vars = gimplify_ctxp->live_switch_vars; - gimplify_ctxp->live_switch_vars = new hash_set (4); - } + gimplify_ctxp->live_switch_vars = new hash_set (4); + else + gimplify_ctxp->live_switch_vars = NULL; bool old_in_switch_expr = gimplify_ctxp->in_switch_expr; gimplify_ctxp->in_switch_expr = true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 00f1166b50e..b964464152e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-11-16 Martin Liska + + PR sanitizer/78270 + * gcc.dg/asan/pr78270.c: Update comment style. + * gcc.dg/asan/pr78270-2.c: New test. + 2016-11-16 Senthil Kumar Selvaraj * c-c++-common/Wlogical-op-1.c: Use __INT{16,32}_TYPE__ instead diff --git a/gcc/testsuite/gcc.dg/asan/pr78270-2.c b/gcc/testsuite/gcc.dg/asan/pr78270-2.c new file mode 100644 index 00000000000..72195b33e43 --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr78270-2.c @@ -0,0 +1,18 @@ +/* PR sanitizer/78270 */ +/* { dg-do compile } */ +/* { dg-additional-options "-Wno-switch-unreachable" } */ + +int a; +void +fn1 () +{ + switch (a) + { + char b; + case 8: + &b; + switch (0) + ; + } +} + diff --git a/gcc/testsuite/gcc.dg/asan/pr78270.c b/gcc/testsuite/gcc.dg/asan/pr78270.c index 55840b0ad6a..5583ce472e4 100644 --- a/gcc/testsuite/gcc.dg/asan/pr78270.c +++ b/gcc/testsuite/gcc.dg/asan/pr78270.c @@ -1,5 +1,6 @@ -// { dg-do compile } -// { dg-additional-options "-Wno-switch-unreachable" } +/* PR sanitizer/78270 */ +/* { dg-do compile } */ +/* { dg-additional-options "-Wno-switch-unreachable" } */ typedef struct {