tree.c (get_unwidened): Check TREE_UNSIGNED on the field's type.
authorJason Merrill <jason@redhat.com>
Wed, 22 Oct 2003 02:19:38 +0000 (22:19 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 22 Oct 2003 02:19:38 +0000 (22:19 -0400)
        * tree.c (get_unwidened): Check TREE_UNSIGNED on the field's type.
        (get_narrower): Likewise.

From-SVN: r72787

gcc/ChangeLog
gcc/tree.c

index afcd8bcb341272af463bef1223f58456408bddc8..1ec11656e300eb629f1e79510c80b8707aa90e4e 100644 (file)
@@ -1,5 +1,8 @@
 2003-10-21  Jason Merrill  <jason@redhat.com>
 
+       * tree.c (get_unwidened): Check TREE_UNSIGNED on the field's type.
+       (get_narrower): Likewise.
+
        * stor-layout.c (layout_decl): Do packed field alignment for
        bit-fields, too.
 
index dd8378e8ec562a8e62de3017f36f174c4534416b..7d0258c1fa02090bbe4f66710e58965f7d5ee202 100644 (file)
@@ -4105,7 +4105,8 @@ get_unwidened (tree op, tree for_type)
     {
       unsigned int innerprec
        = tree_low_cst (DECL_SIZE (TREE_OPERAND (op, 1)), 1);
-      int unsignedp = TREE_UNSIGNED (TREE_OPERAND (op, 1));
+      int unsignedp = (TREE_UNSIGNED (TREE_OPERAND (op, 1))
+                      || TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op, 1))));
       type = (*lang_hooks.types.type_for_size) (innerprec, unsignedp);
 
       /* We can get this structure field in the narrowest type it fits in.
@@ -4189,8 +4190,9 @@ get_narrower (tree op, int *unsignedp_ptr)
     {
       unsigned HOST_WIDE_INT innerprec
        = tree_low_cst (DECL_SIZE (TREE_OPERAND (op, 1)), 1);
-      tree type = (*lang_hooks.types.type_for_size) (innerprec,
-                                                    TREE_UNSIGNED (op));
+      int unsignedp = (TREE_UNSIGNED (TREE_OPERAND (op, 1))
+                      || TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op, 1))));
+      tree type = (*lang_hooks.types.type_for_size) (innerprec, unsignedp);
 
       /* We can get this structure field in a narrower type that fits it,
         but the resulting extension to its nominal type (a fullword type)