Fix PR sanitizer/78270 (part 2) 84/189284/2
authormarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Nov 2016 11:56:58 +0000 (11:56 +0000)
committerMikhail Kashkarov <m.kashkarov@partner.samsung.com>
Thu, 18 Oct 2018 13:20:10 +0000 (16:20 +0300)
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.

upstream hash: 904e262bdb88c2cf1eefeb4997c8d4ed2a888d55
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@242485 138bc75d-0d04-0410-961f-82ee72b054a4

Change-Id: I760170bff746390269035dd2c10afff960d06445

gcc/gimplify.c
gcc/testsuite/gcc.dg/asan/pr78270-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/asan/pr78270.c

index c294390..673738c 100644 (file)
@@ -2240,11 +2240,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<tree> (4);
-       }
+       gimplify_ctxp->live_switch_vars = new hash_set<tree> (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/gcc.dg/asan/pr78270-2.c b/gcc/testsuite/gcc.dg/asan/pr78270-2.c
new file mode 100644 (file)
index 0000000..72195b3
--- /dev/null
@@ -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)
+       ;
+    }
+}
+
index 55840b0..5583ce4 100644 (file)
@@ -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
 {