diff options
author | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-18 12:20:49 +0000 |
---|---|---|
committer | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-02-18 12:20:49 +0000 |
commit | d47a5ab185811d06aab4e614d6b9cca636aedb1a (patch) | |
tree | a9c7d9f0218df9d72684d8174c257d1e35351b39 /gcc/stmt.c | |
parent | 37e8021c4fa1bb1674ca6aab1fd9e2f6618d0709 (diff) | |
download | gcc-d47a5ab185811d06aab4e614d6b9cca636aedb1a.tar.gz |
gcc/ChangeLog:
PR c++/20008
* stmt.c (expand_case): Don't assume cleanup_tree_cfg will remove
cases that are out-of-range for the index type.
gcc/testsuite/ChangeLog:
PR c++/20008
* g++.dg/opt/switch4.C: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@95225 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/stmt.c')
-rw-r--r-- | gcc/stmt.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/stmt.c b/gcc/stmt.c index a438532b11b..64e070b5a0a 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -2394,8 +2394,14 @@ expand_case (tree exp) BITMAP_FREE (label_bitmap); /* cleanup_tree_cfg removes all SWITCH_EXPR with a single - destination, such as one with a default case only. */ - gcc_assert (count != 0); + destination, such as one with a default case only. However, + it doesn't remove cases that are out of range for the switch + type, so we may still get a zero here. */ + if (count == 0) + { + emit_jump (default_label); + return; + } /* Compute span of values. */ range = fold (build2 (MINUS_EXPR, index_type, maxval, minval)); |