diff options
author | Andrew Cagney <cagney@redhat.com> | 2000-07-12 08:31:49 +0000 |
---|---|---|
committer | Andrew Cagney <cagney@redhat.com> | 2000-07-12 08:31:49 +0000 |
commit | 634acd5f8a2e36efa4eb98c71fc04519aa8abb26 (patch) | |
tree | 176e4adfd8ff57cc462bf2079bcd7b3318ab854c /gdb/valops.c | |
parent | 0ba2a60ea96bb63756bfb01ccc2e20081aad3995 (diff) | |
download | gdb-634acd5f8a2e36efa4eb98c71fc04519aa8abb26.zip gdb-634acd5f8a2e36efa4eb98c71fc04519aa8abb26.tar.gz gdb-634acd5f8a2e36efa4eb98c71fc04519aa8abb26.tar.bz2 |
* valops.c (value_cast): Allow cast from INT, ENUM or RANGE to
POINTER.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r-- | gdb/valops.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gdb/valops.c b/gdb/valops.c index 114a035..a32db08 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -290,6 +290,20 @@ value_cast (type, arg2) return value_from_longest (type, convert_to_boolean ? (LONGEST) (longest ? 1 : 0) : longest); } + else if (code1 == TYPE_CODE_PTR && (code2 == TYPE_CODE_INT || + code2 == TYPE_CODE_ENUM || + code2 == TYPE_CODE_RANGE)) + { + int ptr_bit = HOST_CHAR_BIT * TYPE_LENGTH (type); + LONGEST longest = value_as_long (arg2); + if (ptr_bit < sizeof (LONGEST) * HOST_CHAR_BIT) + { + if (longest >= ((LONGEST) 1 << ptr_bit) + || longest <= -((LONGEST) 1 << ptr_bit)) + warning ("value truncated"); + } + return value_from_longest (type, longest); + } else if (TYPE_LENGTH (type) == TYPE_LENGTH (type2)) { if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR) |