aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-06-08 18:56:00 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-06-08 18:56:00 +0000
commit2427150138deb7c8efff398b3d9b1915021efd44 (patch)
treed7352ce0a1b992be92518ed5bc68412237a36e6d
parentf419ed5805108254a0fe8176efa7ee55d706fa49 (diff)
downloadgcc-2427150138deb7c8efff398b3d9b1915021efd44.zip
gcc-2427150138deb7c8efff398b3d9b1915021efd44.tar.gz
gcc-2427150138deb7c8efff398b3d9b1915021efd44.tar.bz2
Correct type size comparison.
From-SVN: r174814
-rw-r--r--gcc/go/gofrontend/expressions.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 1061875..5dda791 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -754,8 +754,13 @@ Expression::check_bounds(tree val, tree bound_type, tree sofar,
ret = NULL_TREE;
}
- if ((TYPE_UNSIGNED(val_type) && !TYPE_UNSIGNED(bound_type))
- || TYPE_SIZE(val_type) > TYPE_SIZE(bound_type))
+ HOST_WIDE_INT val_type_size = int_size_in_bytes(val_type);
+ HOST_WIDE_INT bound_type_size = int_size_in_bytes(bound_type);
+ go_assert(val_type_size != -1 && bound_type_size != -1);
+ if (val_type_size > bound_type_size
+ || (val_type_size == bound_type_size
+ && TYPE_UNSIGNED(val_type)
+ && !TYPE_UNSIGNED(bound_type)))
{
tree max = TYPE_MAX_VALUE(bound_type);
tree big = fold_build2_loc(loc, GT_EXPR, boolean_type_node, val,