aboutsummaryrefslogtreecommitdiff
path: root/gdb/p-exp.y
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2001-03-19 19:05:21 +0000
committerAndrew Cagney <cagney@redhat.com>2001-03-19 19:05:21 +0000
commit7451d027679bb07d31ddb8d0359d62b0226ffc71 (patch)
tree8aaa7effccb32413062c31142999c8f3fd23610a /gdb/p-exp.y
parent177495c9073d6c70971c0a2dbf8f3933ead3015f (diff)
downloadgdb-7451d027679bb07d31ddb8d0359d62b0226ffc71.zip
gdb-7451d027679bb07d31ddb8d0359d62b0226ffc71.tar.gz
gdb-7451d027679bb07d31ddb8d0359d62b0226ffc71.tar.bz2
* p-exp.y (parse_number): Avoid shift overflow when ``long''.
Code copied from c-exp.y.
Diffstat (limited to 'gdb/p-exp.y')
-rw-r--r--gdb/p-exp.y13
1 files changed, 6 insertions, 7 deletions
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 8945a05..b09ec08 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -858,14 +858,13 @@ parse_number (p, len, parsed_float, putithere)
}
else
{
- high_bit = (((ULONGEST)1)
- << (TARGET_LONG_LONG_BIT - 32 - 1)
- << 16
- << 16);
- if (high_bit == 0)
+ int shift;
+ if (sizeof (ULONGEST) * HOST_CHAR_BIT < TARGET_LONG_LONG_BIT)
/* A long long does not fit in a LONGEST. */
- high_bit =
- (ULONGEST)1 << (sizeof (LONGEST) * HOST_CHAR_BIT - 1);
+ shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
+ else
+ shift = (TARGET_LONG_LONG_BIT - 1);
+ high_bit = (ULONGEST) 1 << shift;
unsigned_type = builtin_type_unsigned_long_long;
signed_type = builtin_type_long_long;
}