Commit 2d9d49e4 by Olivier Hainque Committed by Richard Kenner

stmt.c (expand_end_case): Do subtraction of lower bound as trees to avoid overflow.

	* stmt.c (expand_end_case): Do subtraction of lower bound as trees
	to avoid overflow.

From-SVN: r47932
parent cdb29058
Wed Dec 12 07:37:52 2001 Olivier Hainque <hainque@act-europe.fr>
* stmt.c (expand_end_case): Do subtraction of lower bound as trees
to avoid overflow.
Wed Dec 12 07:35:24 2001 Douglas B. Rupp <rupp@gnat.com> Wed Dec 12 07:35:24 2001 Douglas B. Rupp <rupp@gnat.com>
* cppfiles.c (read_include_file): Set buffer size properly when * cppfiles.c (read_include_file): Set buffer size properly when
......
...@@ -5525,18 +5525,20 @@ expand_end_case (orig_index) ...@@ -5525,18 +5525,20 @@ expand_end_case (orig_index)
for (n = thiscase->data.case_stmt.case_list; n; n = n->right) for (n = thiscase->data.case_stmt.case_list; n; n = n->right)
{ {
HOST_WIDE_INT i /* Compute the low and high bounds relative to the minimum
= tree_low_cst (n->low, 0) - tree_low_cst (minval, 0); value since that should fit in a HOST_WIDE_INT while the
actual values may not. */
while (1) HOST_WIDE_INT i_low
{ = tree_low_cst (fold (build (MINUS_EXPR, index_type,
labelvec[i] n->low, minval)), 1);
= gen_rtx_LABEL_REF (Pmode, label_rtx (n->code_label)); HOST_WIDE_INT i_high
if (i + tree_low_cst (minval, 0) = tree_low_cst (fold (build (MINUS_EXPR, index_type,
== tree_low_cst (n->high, 0)) n->high, minval)), 1);
break; HOST_WIDE_INT i;
i++;
} for (i = i_low; i <= i_high; i ++)
labelvec[i]
= gen_rtx_LABEL_REF (Pmode, label_rtx (n->code_label));
} }
/* Fill in the gaps with the default. */ /* Fill in the gaps with the default. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment