- un = (ULONGEST)n >> 2;
- if (long_p == 0
- && (un >> (gdbarch_int_bit (parse_gdbarch (par_state)) - 2)) == 0)
- {
- high_bit
- = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch (par_state)) - 1);
-
- /* A large decimal (not hex or octal) constant (between INT_MAX
- and UINT_MAX) is a long or unsigned long, according to ANSI,
- never an unsigned int, but this code treats it as unsigned
- int. This probably should be fixed. GCC gives a warning on
- such constants. */
-
- unsigned_type = parse_type (par_state)->builtin_unsigned_int;
- signed_type = parse_type (par_state)->builtin_int;
- }
- else if (long_p <= 1
- && (un >> (gdbarch_long_bit (parse_gdbarch (par_state)) - 2)) == 0)
- {
- high_bit
- = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch (par_state)) - 1);
- unsigned_type = parse_type (par_state)->builtin_unsigned_long;
- signed_type = parse_type (par_state)->builtin_long;
- }
+ int int_bits = gdbarch_int_bit (par_state->gdbarch ());
+ int long_bits = gdbarch_long_bit (par_state->gdbarch ());
+ int long_long_bits = gdbarch_long_long_bit (par_state->gdbarch ());
+ bool have_signed = !unsigned_p;
+ bool have_int = long_p == 0;
+ bool have_long = long_p <= 1;
+ if (have_int && have_signed && fits_in_type (1, n, int_bits, true))
+ putithere->typed_val_int.type = parse_type (par_state)->builtin_int;
+ else if (have_int && fits_in_type (1, n, int_bits, false))
+ putithere->typed_val_int.type
+ = parse_type (par_state)->builtin_unsigned_int;
+ else if (have_long && have_signed && fits_in_type (1, n, long_bits, true))
+ putithere->typed_val_int.type = parse_type (par_state)->builtin_long;
+ else if (have_long && fits_in_type (1, n, long_bits, false))
+ putithere->typed_val_int.type
+ = parse_type (par_state)->builtin_unsigned_long;
+ else if (have_signed && fits_in_type (1, n, long_long_bits, true))
+ putithere->typed_val_int.type
+ = parse_type (par_state)->builtin_long_long;
+ else if (fits_in_type (1, n, long_long_bits, false))
+ putithere->typed_val_int.type
+ = parse_type (par_state)->builtin_unsigned_long_long;