aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorDodji Seketeli <dodji@redhat.com>2008-08-28 14:49:48 +0000
committerDodji Seketeli <dodji@redhat.com>2008-08-28 14:49:48 +0000
commitb0e2c482139f351f452e4a828cb7e228ee356863 (patch)
treecedeeece4140a9cc8474c6215439d0802ddad3f1 /gcc/tree.c
parentfd047c1c8cf180121a531ce11da1904f35f26563 (diff)
2008-08-28 Dodji Seketeli <dodji@redhat.com>
PR c++/36741 * tree.c (int_fits_type_p): Don't forget unsigned integers of type sizetype which higher end word equals -1. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@139712 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 912d77fd410..f058fd70f14 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -6319,6 +6319,21 @@ int_fits_type_p (const_tree c, const_tree type)
for "unknown if constant fits", 0 for "constant known *not* to fit" and 1
for "constant known to fit". */
+ if (TREE_TYPE (c) == sizetype
+ && TYPE_UNSIGNED (TREE_TYPE (c))
+ && TREE_INT_CST_HIGH (c) == -1
+ && !TREE_OVERFLOW (c))
+ /* So c is an unsigned integer which type is sizetype.
+ sizetype'd integers are sign extended even though they are
+ unsigned. If the integer value fits in the lower end word of c,
+ and if the higher end word has all its bits set to 1, that
+ means the higher end bits are set to 1 only for sign extension.
+ So let's convert c into an equivalent zero extended unsigned
+ integer. */
+ c = force_fit_type_double (size_type_node,
+ TREE_INT_CST_LOW (c),
+ TREE_INT_CST_HIGH (c),
+ false, false);
/* Check if C >= type_low_bound. */
if (type_low_bound && TREE_CODE (type_low_bound) == INTEGER_CST)
{