summaryrefslogtreecommitdiff
path: root/gcc/stor-layout.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2006-02-16 17:18:03 -0700
committerJeff Law <law@gcc.gnu.org>2006-02-16 17:18:03 -0700
commit7f18f91710ecaf3f6f90989716f07f5a247d0764 (patch)
treee862177b74293f68fdf42829df228e471d62e970 /gcc/stor-layout.c
parentb18b991a8cfa668851ba490065a095d3d8669667 (diff)
downloadgcc-7f18f91710ecaf3f6f90989716f07f5a247d0764.tar.gz
stor-layout.c (set_sizetype): Set TYPE_MAX_VALUE properly for sizetype when sizetype is unsigned.
* stor-layout.c (set_sizetype): Set TYPE_MAX_VALUE properly for sizetype when sizetype is unsigned. From-SVN: r111170
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r--gcc/stor-layout.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index bf25e97c629..caf176f49c5 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -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;
+ }
}
/* TYPE is an integral type, i.e., an INTEGRAL_TYPE, ENUMERAL_TYPE