This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: fix for PR java/6388
- From: Richard Henderson <rth at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: Java Patch List <java-patches at gcc dot gnu dot org>, Gcc Patch List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 11 Jun 2002 15:12:17 -0700
- Subject: Re: Patch: fix for PR java/6388
- References: <87u1o9ispo.fsf@creche.redhat.com>
On Tue, Jun 11, 2002 at 12:19:15PM -0600, Tom Tromey wrote:
> Is this ok? Or is there a better way to do the sign extension?
I don't think this is anywhere near correct for 64-bit H_W_I.
In particular, check for long_suffix check just above is
hopelessly 32-bit centric.
Why don't you use int_fits_type_p instead?
Something like
decimal_int_range_type = build_index_type (build_int_2 (0x80000000, 0));
decimal_long_range_type
= build_index_type (HOST_BITS_PER_WIDE_INT == 32
? build_int_2 (0, 0x80000000)
: build_int_2 (0x8000000000000000, 0));
...
value = build_int_2 (low, high);
if (long_suffix)
range = (radix == 10 ? decimal_long_range_type : unsigned_long_type_node);
else
range = (radix == 10 ? decimal_int_range_type : unsigned_int_type_node);
/* Temporarily set type for int_fits_type_p. Must be unsigned. */
TREE_TYPE (value) = unsigned_long_type_node;
if (! int_fits_type_p (value, range))
{
if (long_suffix)
JAVA_INTEGRAL_RANGE_ERROR ("Numeric overflow for `long' literal");
else
JAVA_INTEGRAL_RANGE_ERROR ("Numeric overflow for `int' literal");
}
SET_LVAL_NODE_TYPE (value, long_suffix ? long_type_node : int_type_node);
r~