This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch: fix for PR java/6388


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]