aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/lex.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@gcc.gnu.org>2002-11-02 21:29:36 +0000
committerTom Tromey <tromey@gcc.gnu.org>2002-11-02 21:29:36 +0000
commitfafe87d07d4d685f3c0f6e8d817f0c5ec530abc5 (patch)
tree9eab0f2c90e0eafd8c918a932688d892ebc2f013 /gcc/java/lex.c
parent77a106a531a92278c5a28b8ec8c373621d302185 (diff)
downloadgcc-fafe87d07d4d685f3c0f6e8d817f0c5ec530abc5.zip
gcc-fafe87d07d4d685f3c0f6e8d817f0c5ec530abc5.tar.gz
gcc-fafe87d07d4d685f3c0f6e8d817f0c5ec530abc5.tar.bz2
Reverted erroneous checkin
From-SVN: r58756
Diffstat (limited to 'gcc/java/lex.c')
-rw-r--r--gcc/java/lex.c65
1 files changed, 37 insertions, 28 deletions
diff --git a/gcc/java/lex.c b/gcc/java/lex.c
index 6c7866c..d690176 100644
--- a/gcc/java/lex.c
+++ b/gcc/java/lex.c
@@ -1218,35 +1218,34 @@ java_lex (java_lval)
}
/* End borrowed section. */
-#ifndef JC1_LITE
/* Range checking. */
- value = build_int_2 (low, high);
- /* Temporarily set type to unsigned. */
- SET_LVAL_NODE_TYPE (value, (long_suffix
- ? unsigned_long_type_node
- : unsigned_int_type_node));
-
- /* For base 10 numbers, only values up to the highest value
- (plus one) can be written. For instance, only ints up to
- 2147483648 can be written. The special case of the largest
- negative value is handled elsewhere. For other bases, any
- number can be represented. */
- if (overflow || (radix == 10
- && tree_int_cst_lt (long_suffix
- ? decimal_long_max
- : decimal_int_max,
- value)))
+ if (long_suffix)
{
- if (long_suffix)
+ /* 9223372036854775808L is valid if operand of a '-'. Otherwise
+ 9223372036854775807L is the biggest `long' literal that can be
+ expressed using a 10 radix. For other radices, everything that
+ fits withing 64 bits is OK. */
+ int hb = (high >> 31);
+ if (overflow || (hb && low && radix == 10)
+ || (hb && high & 0x7fffffff && radix == 10))
JAVA_INTEGRAL_RANGE_ERROR ("Numeric overflow for `long' literal");
- else
+ }
+ else
+ {
+ /* 2147483648 is valid if operand of a '-'. Otherwise,
+ 2147483647 is the biggest `int' literal that can be
+ expressed using a 10 radix. For other radices, everything
+ that fits within 32 bits is OK. As all literals are
+ signed, we sign extend here. */
+ int hb = (low >> 31) & 0x1;
+ if (overflow || high || (hb && low & 0x7fffffff && radix == 10))
JAVA_INTEGRAL_RANGE_ERROR ("Numeric overflow for `int' literal");
+ high = -hb;
}
-
- /* Sign extend the value. */
- SET_LVAL_NODE_TYPE (value, (long_suffix ? long_type_node : int_type_node));
- force_fit_type (value, 0);
+#ifndef JC1_LITE
+ value = build_int_2 (low, high);
JAVA_RADIX10_FLAG (value) = radix == 10;
+ SET_LVAL_NODE_TYPE (value, long_suffix ? long_type_node : int_type_node);
#else
SET_LVAL_NODE_TYPE (build_int_2 (low, high),
long_suffix ? long_type_node : int_type_node);
@@ -1662,14 +1661,24 @@ static void
error_if_numeric_overflow (value)
tree value;
{
- if (TREE_CODE (value) == INTEGER_CST
- && JAVA_RADIX10_FLAG (value)
- && tree_int_cst_sgn (value) < 0)
+ if (TREE_CODE (value) == INTEGER_CST && JAVA_RADIX10_FLAG (value))
{
+ unsigned HOST_WIDE_INT lo, hi;
+
+ lo = TREE_INT_CST_LOW (value);
+ hi = TREE_INT_CST_HIGH (value);
if (TREE_TYPE (value) == long_type_node)
- java_lex_error ("Numeric overflow for `long' literal", 0);
+ {
+ int hb = (hi >> 31);
+ if (hb && !(hi & 0x7fffffff))
+ java_lex_error ("Numeric overflow for `long' literal", 0);
+ }
else
- java_lex_error ("Numeric overflow for `int' literal", 0);
+ {
+ int hb = (lo >> 31) & 0x1;
+ if (hb && !(lo & 0x7fffffff))
+ java_lex_error ("Numeric overflow for `int' literal", 0);
+ }
}
}
#endif /* JC1_LITE */