@@ -685,10 +685,10 @@ c_readstr (const char *str, enum machine_mode mode)
HOST_WIDE_INT tmp[MAX_BITSIZE_MODE_ANY_INT / HOST_BITS_PER_WIDE_INT];
gcc_assert (GET_MODE_CLASS (mode) == MODE_INT);
-
unsigned int len = (GET_MODE_PRECISION (mode) + HOST_BITS_PER_WIDE_INT - 1)
/ HOST_BITS_PER_WIDE_INT;
+ gcc_assert (len <= MAX_BITSIZE_MODE_ANY_INT / HOST_BITS_PER_WIDE_INT);
for (i = 0; i < len; i++)
tmp[i] = 0;
@@ -4963,6 +4963,7 @@ make_tree (tree type, rtx x)
return t;
case CONST_DOUBLE:
+ gcc_assert (HOST_BITS_PER_WIDE_INT * 2 <= MAX_BITSIZE_MODE_ANY_INT);
if (TARGET_SUPPORTS_WIDE_INT == 0 && GET_MODE (x) == VOIDmode)
t = wide_int_to_tree (type,
wide_int::from_array (&CONST_DOUBLE_LOW (x), 2,
@@ -1312,6 +1312,7 @@ lto_input_tree_1 (struct lto_input_block *ib, struct data_in *data_in,
for (i = 0; i < len; i++)
a[i] = streamer_read_hwi (ib);
+ gcc_assert (TYPE_PRECISION (type) <= MAX_BITSIZE_MODE_ANY_INT);
result = wide_int_to_tree (type, wide_int::from_array
(a, len, TYPE_PRECISION (type)));
streamer_tree_cache_append (data_in->reader_cache, result, hash);
@@ -1377,10 +1377,12 @@ real_to_integer (const REAL_VALUE_TYPE *r)
wide_int
real_to_integer (const REAL_VALUE_TYPE *r, bool *fail, int precision)
{
+ typedef FIXED_WIDE_INT (WIDE_INT_MAX_PRECISION * 2) real_int;
HOST_WIDE_INT val[2 * MAX_BITSIZE_MODE_ANY_INT / HOST_BITS_PER_WIDE_INT];
int exp;
int words;
wide_int result;
+ real_int tmp;
int w;
switch (r->cl)
@@ -1440,10 +1442,10 @@ real_to_integer (const REAL_VALUE_TYPE *r, bool *fail, int precision)
}
#endif
w = SIGSZ * HOST_BITS_PER_LONG + words * HOST_BITS_PER_WIDE_INT;
- result = wide_int::from_array
+ tmp = real_int::from_array
(val, (w + HOST_BITS_PER_WIDE_INT - 1) / HOST_BITS_PER_WIDE_INT, w);
- result = wi::lrshift (result, (words * HOST_BITS_PER_WIDE_INT) - exp);
- result = wide_int::from (result, precision, UNSIGNED);
+ tmp = wi::lrshift<real_int> (tmp, (words * HOST_BITS_PER_WIDE_INT) - exp);
+ result = wide_int::from (tmp, precision, UNSIGNED);
if (r->sign)
return -result;
@@ -5384,6 +5384,7 @@ simplify_immed_subreg (enum machine_mode outermode, rtx op,
tmp[u] = buf;
base += HOST_BITS_PER_WIDE_INT;
}
+ gcc_assert (GET_MODE_PRECISION (outer_submode) <= MAX_BITSIZE_MODE_ANY_INT);
r = wide_int::from_array (tmp, units,
GET_MODE_PRECISION (outer_submode));
elems[elem] = immed_wide_int_const (r, outer_submode);
@@ -62,7 +62,7 @@ build_replicated_const (tree type, tree inner_type, HOST_WIDE_INT value)
HOST_WIDE_INT a[WIDE_INT_MAX_ELTS];
int i;
- gcc_assert (n);
+ gcc_assert (n && n <= WIDE_INT_MAX_ELTS);
if (width == HOST_BITS_PER_WIDE_INT)
low = value;
@@ -75,6 +75,7 @@ build_replicated_const (tree type, tree inner_type, HOST_WIDE_INT value)
for (i = 0; i < n; i++)
a[i] = low;
+ gcc_assert (TYPE_PRECISION (type) <= MAX_BITSIZE_MODE_ANY_INT);
return wide_int_to_tree
(type, wide_int::from_array (a, n, TYPE_PRECISION (type)));
}