OSDN Git Service

Correct type size comparison.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 8 Jun 2011 18:56:00 +0000 (18:56 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 8 Jun 2011 18:56:00 +0000 (18:56 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174814 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/go/gofrontend/expressions.cc

index 1061875..5dda791 100644 (file)
@@ -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,