From: nathan Date: Fri, 14 Oct 2005 12:55:33 +0000 (+0000) Subject: .: X-Git-Tag: upstream/4.9.2~58185 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=96722196333e60239eda33ca3fe3597405bfcfe0;p=platform%2Fupstream%2Flinaro-gcc.git .: 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105405 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c7b6f33..b1746e5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-10-14 Nathan Sidwell + + PR c++/22551 + * c-common.c (c_add_case_label): Clear LOW_VALUE and HIGH_VALUE's + overflow flags. Refactor some conditionals. + 2005-10-13 Andrew Pinski PR tree-opt/21304 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, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a119dca..a0ee3a0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2005-10-14 Nathan Sidwell + PR c++/22551 + * g++.dg/other/switch2.C: New. + PR c++/23984 * g++.dg/init/ctor7.C: New. diff --git a/gcc/testsuite/g++.dg/other/switch2.C b/gcc/testsuite/g++.dg/other/switch2.C new file mode 100644 index 0000000..a2352c0 --- /dev/null +++ b/gcc/testsuite/g++.dg/other/switch2.C @@ -0,0 +1,22 @@ +// Copyright (C) 2005 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 13 Oct 2005 + +// PR 22551:ICE +// Origin: Johnny Casey + +const int B = 0x80000000; + +#define b(x) (B + x) + + +int Foo (int error) +{ + switch (error) + { + case b (1): return 0; // { dg-error "overflow" "" } + case b (2): return 0; // { dg-error "overflow" "" } + case b (3): return 0; // { dg-error "overflow" "" } + case b (4): return 0; // { dg-error "overflow" "" } + case b (5): return 0; // { dg-error "overflow" "" } + } +}