aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2005-10-14 12:55:33 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2005-10-14 12:55:33 +0000
commitc0e22534e4977ab263f6ae40b70d8bd76334665c (patch)
tree95318492904cbe890293b0e21d33b89a4257665b /gcc/c-common.c
parent771c0562b56432ea64558329688a8281bc1e9996 (diff)
downloadgcc-c0e22534e4977ab263f6ae40b70d8bd76334665c.zip
gcc-c0e22534e4977ab263f6ae40b70d8bd76334665c.tar.gz
gcc-c0e22534e4977ab263f6ae40b70d8bd76334665c.tar.bz2
re PR c++/22551 ([ICE] in tree_low_cst, at tree.c:3843)
.: PR c++/22551 * c-common.c (c_add_case_label): Clear LOW_VALUE and HIGH_VALUE's overflow flags. Refactor some conditionals. testsuite: PR c++/22551 * g++.dg/other/switch2.C: New. From-SVN: r105405
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index c5b409e..c5ba85e 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -3588,25 +3588,32 @@ c_add_case_label (splay_tree cases, tree cond, tree orig_type,
{
low_value = check_case_value (low_value);
low_value = convert_and_check (type, low_value);
+ if (low_value == error_mark_node)
+ goto error_out;
+ /* Do not propagate any overflow information past this point.
+ It is safe to just clear the flags, as any constants with
+ them set will not be shared. */
+ TREE_CONSTANT_OVERFLOW (low_value) = TREE_OVERFLOW (low_value) = 0;
}
if (high_value)
{
high_value = check_case_value (high_value);
high_value = convert_and_check (type, high_value);
+ if (high_value == error_mark_node)
+ goto error_out;
+ TREE_CONSTANT_OVERFLOW (high_value) = TREE_OVERFLOW (high_value) = 0;
}
- /* If an error has occurred, bail out now. */
- if (low_value == error_mark_node || high_value == error_mark_node)
- goto error_out;
-
- /* If the LOW_VALUE and HIGH_VALUE are the same, then this isn't
- really a case range, even though it was written that way. Remove
- the HIGH_VALUE to simplify later processing. */
- if (tree_int_cst_equal (low_value, high_value))
- high_value = NULL_TREE;
- if (low_value && high_value
- && !tree_int_cst_lt (low_value, high_value))
- warning (0, "empty range specified");
+ if (low_value && high_value)
+ {
+ /* If the LOW_VALUE and HIGH_VALUE are the same, then this isn't
+ really a case range, even though it was written that way.
+ Remove the HIGH_VALUE to simplify later processing. */
+ if (tree_int_cst_equal (low_value, high_value))
+ high_value = NULL_TREE;
+ else if (!tree_int_cst_lt (low_value, high_value))
+ warning (0, "empty range specified");
+ }
/* See if the case is in range of the type of the original testing
expression. If both low_value and high_value are out of range,