From d78bcb133d4559273bf6f6125f2659354e3f505e Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Mon, 22 Oct 2018 15:09:33 +0200 Subject: [PATCH] Revert r263947. 2018-10-22 Martin Liska PR tree-optimization/87686 Revert 2018-08-29 Martin Liska * tree-switch-conversion.c (switch_conversion::expand): Strenghten assumption about gswitch statements. 2018-10-22 Martin Liska PR tree-optimization/87686 * g++.dg/tree-ssa/pr87686.C: New test. From-SVN: r265388 --- gcc/ChangeLog | 9 +++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/tree-ssa/pr87686.C | 21 +++++++++++++++++++++ gcc/tree-switch-conversion.c | 9 ++++++++- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr87686.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 736904fb679..8bf143438d5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2018-10-22 Martin Liska + + PR tree-optimization/87686 + Revert + 2018-08-29 Martin Liska + + * tree-switch-conversion.c (switch_conversion::expand): + Strenghten assumption about gswitch statements. + 2018-10-22 Martin Liska * ipa-icf.c (sem_item::compare_attributes): Remove. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 27433018294..b803f72cc9b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-10-22 Martin Liska + + PR tree-optimization/87686 + * g++.dg/tree-ssa/pr87686.C: New test. + 2018-10-22 Jakub Jelinek * g++.target/i386/i386.exp: Use g++-dg-runtest to iterate diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr87686.C b/gcc/testsuite/g++.dg/tree-ssa/pr87686.C new file mode 100644 index 00000000000..65160a79855 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr87686.C @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +class a { +public: + enum b { c, g, d, e } f; + a(b h) : f(h) {} + a i() { + switch (f) { + case d: + return c; + case e: + return g; + } + } /* { dg-warning "control reaches end of non-void function" } */ +}; +struct k { + a j; + k l() { j.i(); } /* { dg-warning "no return statement in function returning non-void" } */ +}; +void m(k h) { h.l(); } diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index 64169a6cd3d..ac2aa585257 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -913,7 +913,14 @@ switch_conversion::expand (gswitch *swtch) /* Group case labels so that we get the right results from the heuristics that decide on the code generation approach for this switch. */ m_cfg_altered |= group_case_labels_stmt (swtch); - gcc_assert (gimple_switch_num_labels (swtch) >= 2); + + /* If this switch is now a degenerate case with only a default label, + there is nothing left for us to do. */ + if (gimple_switch_num_labels (swtch) < 2) + { + m_reason = "switch is a degenerate case"; + return; + } collect (swtch); -- 2.30.2