aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2008-10-22 20:21:55 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2008-10-22 20:21:55 +0200
commit972afb58199cd9228dbf974fe0fbd698b430550e (patch)
treef6e3ecababdb7c9cb2c4fa8858443e73e6840f66 /gcc/fold-const.c
parent58ddc179d494fd426aca184a1a5749d9fa6f81b9 (diff)
downloadgcc-972afb58199cd9228dbf974fe0fbd698b430550e.zip
gcc-972afb58199cd9228dbf974fe0fbd698b430550e.tar.gz
gcc-972afb58199cd9228dbf974fe0fbd698b430550e.tar.bz2
re PR middle-end/37882 (Bitfield miscompilation)
PR middle-end/37882 * fold-const.c (build_range_type): For 1 .. signed_max range call build_nonstandard_inter_type if signed_type_for returned a type with bigger precision. * gcc.c-torture/execute/pr37882.c: New test. From-SVN: r141303
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 605caa8..88e70d6 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -4503,7 +4503,12 @@ build_range_check (tree type, tree exp, int in_p, tree low, tree high)
{
if (TYPE_UNSIGNED (etype))
{
- etype = signed_type_for (etype);
+ tree signed_etype = signed_type_for (etype);
+ if (TYPE_PRECISION (signed_etype) != TYPE_PRECISION (etype))
+ etype
+ = build_nonstandard_integer_type (TYPE_PRECISION (etype), 0);
+ else
+ etype = signed_etype;
exp = fold_convert (etype, exp);
}
return fold_build2 (GT_EXPR, type, exp,