stor-layout.c (set_sizetype): Set TYPE_MAX_VALUE properly for sizetype when sizetype...
authorJeff Law <law@redhat.com>
Fri, 17 Feb 2006 00:18:03 +0000 (17:18 -0700)
committerJeff Law <law@gcc.gnu.org>
Fri, 17 Feb 2006 00:18:03 +0000 (17:18 -0700)
        * stor-layout.c (set_sizetype): Set TYPE_MAX_VALUE properly
        for sizetype when sizetype is unsigned.

From-SVN: r111170

gcc/ChangeLog
gcc/stor-layout.c

index fc3e1c8..57696b6 100644 (file)
@@ -1,3 +1,8 @@
+2006-02-16  Jeff Law  <law@redhat.com>
+
+       * stor-layout.c (set_sizetype): Set TYPE_MAX_VALUE properly
+       for sizetype when sizetype is unsigned.
+
 2006-02-16  Denis Nagorny <denis_nagorny@linux.intel.com>
 
        PR rtl-optimization/25603
index bf25e97..caf176f 100644 (file)
@@ -2018,6 +2018,25 @@ set_sizetype (tree type)
       ssizetype = sizetype;
       sbitsizetype = bitsizetype;
     }
+
+  /* If SIZETYPE is unsigned, we need to fix TYPE_MAX_VALUE so that
+     it is sign extended in a way consistent with force_fit_type.  */
+  if (TYPE_UNSIGNED (type))
+    {
+      tree orig_max, new_max;
+
+      orig_max = TYPE_MAX_VALUE (sizetype);
+
+      /* Build a new node with the same values, but a different type.  */
+      new_max = build_int_cst_wide (sizetype,
+                                   TREE_INT_CST_LOW (orig_max),
+                                   TREE_INT_CST_HIGH (orig_max));
+
+      /* Now sign extend it using force_fit_type to ensure
+        consistency.  */
+      new_max = force_fit_type (new_max, 0, 0, 0);
+      TYPE_MAX_VALUE (sizetype) = new_max;
+    }
 }
 \f
 /* TYPE is an integral type, i.e., an INTEGRAL_TYPE, ENUMERAL_TYPE