From d0f2db231639f73802c07f03cf4a77125a0daeb7 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Wed, 23 Jan 2019 15:39:43 +0100 Subject: [PATCH] re PR c++/88984 (ICE in genericize_switch_stmt, at cp/cp-gimplify.c:377) 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 | 6 ++++++ gcc/cp/cp-gimplify.c | 7 ++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/pr88984.c | 19 +++++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/pr88984.c diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 20a54719578..363dff135cf 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2019-01-23 Jakub Jelinek + + PR c++/88984 + * cp-gimplify.c (genericize_switch_stmt): Move cond genericization + before the begin_bc_block call. + 2019-01-21 Jason Merrill PR c++/87893 - constexpr ctor ICE on ARM. diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 121dfa41d8d..e476b8f53ec 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d91be29b4fc..c6006e0655b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-23 Jakub Jelinek + + PR c++/88984 + * c-c++-common/pr88984.c: New test. + 2019-01-23 Richard Biener 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 index 00000000000..48c62208f0f --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr88984.c @@ -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; +} -- 2.30.2