Fix PR sanitizer/78270 (part 2)
authorMartin Liska <mliska@suse.cz>
Wed, 16 Nov 2016 11:56:58 +0000 (12:56 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 16 Nov 2016 11:56:58 +0000 (11:56 +0000)
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

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

index 40922a098fb15398ff64b6187e2c5848822d50ea..08f0a7c99ecdeb39b69db532b7a0577fb74fc13d 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-16  Martin Liska  <mliska@suse.cz>
+
+       PR sanitizer/78270
+       * gimplify.c (gimplify_switch_expr): Always save previous
+       gimplify_ctxp->live_switch_vars.
+
 2016-11-16  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * config/arc/arc.md (movb peephole2): New peephole2 to merge two
index 16573ddaba9cb958b765164fdc10717b103cb011..c23888b4624eb7912a0c6372107fe5c8c56e3016 100644 (file)
@@ -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<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;
index 00f1166b50e6d1d8989ce1bb3dbe12104611d518..b964464152e501c98cf38c1e37bfbefac205e22c 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-16  Martin Liska  <mliska@suse.cz>
+
+       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  <senthil_kumar.selvaraj@atmel.com>
 
        * 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 (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 55840b0ad6aceb0d8ecd663b4879d4cecaaef4fa..5583ce472e4705b82370980cf8221c17c6d0464d 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
 {