diff options
author | Andrew Pinski <pinskia@physics.uc.edu> | 2005-08-22 16:21:18 +0000 |
---|---|---|
committer | Andrew Pinski <pinskia@gcc.gnu.org> | 2005-08-22 09:21:18 -0700 |
commit | 201ae393e61498aec3afc6a3d426aa2f6577aae0 (patch) | |
tree | ca2f57c6cb033f2c3558de1a8123530e483e4ab5 /gcc/c-common.c | |
parent | c85ba4fb34b8dc43ac29ddb7009863b2cb03565d (diff) | |
download | gcc-201ae393e61498aec3afc6a3d426aa2f6577aae0.zip gcc-201ae393e61498aec3afc6a3d426aa2f6577aae0.tar.gz gcc-201ae393e61498aec3afc6a3d426aa2f6577aae0.tar.bz2 |
re PR c/18715 (warning: "enumeration value not handled in switch" for '...' ranges)
2005-08-22 Andrew Pinski <pinskia@physics.uc.edu>
PR c/18715
* c-common.c (c_do_switch_warnings): Look for a node where the enum's
value is inbetween the range if we did not find an exact match.
2005-08-22 Andrew Pinski <pinskia@physics.uc.edu>
PR c/18175
* gcc.dg/switch-warn-3.c: New test.
From-SVN: r103343
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index 0b208fd..67832777 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -3804,7 +3804,32 @@ c_do_switch_warnings (splay_tree cases, location_t switch_location, { splay_tree_node node = splay_tree_lookup (cases, (splay_tree_key) TREE_VALUE (chain)); - + if (!node) + { + tree low_value = TREE_VALUE (chain); + splay_tree_node low_bound; + splay_tree_node high_bound; + /* Even though there wasn't an exact match, there might be a + case range which includes the enumator's value. */ + low_bound = splay_tree_predecessor (cases, + (splay_tree_key) low_value); + high_bound = splay_tree_successor (cases, + (splay_tree_key) low_value); + + /* It is smaller than the LOW_VALUE, so there is no need to check + unless the LOW_BOUND is in fact itself a case range. */ + if (low_bound + && CASE_HIGH ((tree) low_bound->value) + && tree_int_cst_compare (CASE_HIGH ((tree) low_bound->value), + low_value) >= 0) + node = low_bound; + /* The low end of that range is bigger than the current value. */ + else if (high_bound + && (tree_int_cst_compare ((tree) high_bound->key, + low_value) + <= 0)) + node = high_bound; + } if (node) { /* Mark the CASE_LOW part of the case entry as seen, so |