re PR c++/88984 (ICE in genericize_switch_stmt, at cp/cp-gimplify.c:377)
authorJakub Jelinek <jakub@redhat.com>
Wed, 23 Jan 2019 14:39:43 +0000 (15:39 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 23 Jan 2019 14:39:43 +0000 (15:39 +0100)
PR c++/88984
* cp-gimplify.c (genericize_switch_stmt): Move cond genericization
before the begin_bc_block call.

* c-c++-common/pr88984.c: New test.

From-SVN: r268187

gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr88984.c [new file with mode: 0644]

index 20a54719578151e6aa4b665e05f01faf023b1fc8..363dff135cfbda4ac7e846a94e7f6227950a4423 100644 (file)
@@ -1,3 +1,9 @@
+2019-01-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/88984
+       * cp-gimplify.c (genericize_switch_stmt): Move cond genericization
+       before the begin_bc_block call.
+
 2019-01-21  Jason Merrill  <jason@redhat.com>
 
        PR c++/87893 - constexpr ctor ICE on ARM.
index 121dfa41d8d2a7f405b3751e5d48d8185e7d5138..e476b8f53ec1aaf1581e19fe2a7598cc1bdf7051 100644 (file)
@@ -356,16 +356,17 @@ genericize_switch_stmt (tree *stmt_p, int *walk_subtrees, void *data)
   tree break_block, body, cond, type;
   location_t stmt_locus = EXPR_LOCATION (stmt);
 
-  break_block = begin_bc_block (bc_break, stmt_locus);
-
   body = SWITCH_STMT_BODY (stmt);
   if (!body)
     body = build_empty_stmt (stmt_locus);
   cond = SWITCH_STMT_COND (stmt);
   type = SWITCH_STMT_TYPE (stmt);
 
-  cp_walk_tree (&body, cp_genericize_r, data, NULL);
   cp_walk_tree (&cond, cp_genericize_r, data, NULL);
+
+  break_block = begin_bc_block (bc_break, stmt_locus);
+
+  cp_walk_tree (&body, cp_genericize_r, data, NULL);
   cp_walk_tree (&type, cp_genericize_r, data, NULL);
   *walk_subtrees = 0;
 
index d91be29b4fc16e0556ada6e96c624141c2f60d74..c6006e0655b1a9f678100afd09ea2a1350220c9a 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/88984
+       * c-c++-common/pr88984.c: New test.
+
 2019-01-23  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/89008
diff --git a/gcc/testsuite/c-c++-common/pr88984.c b/gcc/testsuite/c-c++-common/pr88984.c
new file mode 100644 (file)
index 0000000..48c6220
--- /dev/null
@@ -0,0 +1,19 @@
+/* PR c++/88984 */
+/* { dg-do run } */
+
+void
+foo (int x, int y)
+{
+  while (x > 0)
+    switch (({ if (y) break; y; }))
+      {
+      case 2: x = 0;
+      }
+}
+
+int
+main ()
+{
+  foo (1, 1);
+  return 0;
+}