diff options
author | Richard Sandiford <rdsandiford@googlemail.com> | 2013-11-20 11:57:06 +0000 |
---|---|---|
committer | Richard Sandiford <rsandifo@gcc.gnu.org> | 2013-11-20 11:57:06 +0000 |
commit | 4aaa33517f8a8dd9db112f6e1ba5e34798027a30 (patch) | |
tree | a81f204a8de862310b14f5428e5f4710b6e94a9d /gcc/tree-ssa-alias.c | |
parent | 51935318726e8403eaaa6bb74b441f4730ff1689 (diff) | |
download | gcc-4aaa33517f8a8dd9db112f6e1ba5e34798027a30.zip gcc-4aaa33517f8a8dd9db112f6e1ba5e34798027a30.tar.gz gcc-4aaa33517f8a8dd9db112f6e1ba5e34798027a30.tar.bz2 |
tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Avoid signed overflow.
gcc/
* tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Avoid signed
overflow. Use tree_to_shwi.
From-SVN: r205102
Diffstat (limited to 'gcc/tree-ssa-alias.c')
-rw-r--r-- | gcc/tree-ssa-alias.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index ef9fbfe..a8be818 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -578,7 +578,7 @@ ao_ref_alias_set (ao_ref *ref) void ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size) { - HOST_WIDE_INT t, extra_offset = 0; + HOST_WIDE_INT t, size_hwi, extra_offset = 0; ref->ref = NULL_TREE; if (TREE_CODE (ptr) == SSA_NAME) { @@ -617,9 +617,8 @@ ao_ref_init_from_ptr_and_size (ao_ref *ref, tree ptr, tree size) ref->offset += extra_offset; if (size && tree_fits_shwi_p (size) - && TREE_INT_CST_LOW (size) * BITS_PER_UNIT / BITS_PER_UNIT - == TREE_INT_CST_LOW (size)) - ref->max_size = ref->size = TREE_INT_CST_LOW (size) * BITS_PER_UNIT; + && (size_hwi = tree_to_shwi (size)) <= HOST_WIDE_INT_MAX / BITS_PER_UNIT) + ref->max_size = ref->size = size_hwi * BITS_PER_UNIT; else ref->max_size = ref->size = -1; ref->ref_alias_set = 0; |