diff options
author | Jim Blandy <jimb@codesourcery.com> | 2002-08-21 17:24:31 +0000 |
---|---|---|
committer | Jim Blandy <jimb@codesourcery.com> | 2002-08-21 17:24:31 +0000 |
commit | b84d7120bde1a20f4f6c769b6e37f4ef9c9ac684 (patch) | |
tree | 244710749051f07eeb04686d11e596424907f59a /gdb/valops.c | |
parent | 4fbf528cefe914fe5204ef0521442a3c8d0992b8 (diff) | |
download | gdb-b84d7120bde1a20f4f6c769b6e37f4ef9c9ac684.tar.gz |
* valops.c (value_cast): Simplify and correct logic for doing a
static cast from a pointer to a base class to a pointer to a
derived class.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r-- | gdb/valops.c | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/gdb/valops.c b/gdb/valops.c index 569c85b62cd..1eeedd32cf7 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -361,18 +361,11 @@ value_cast (struct type *type, struct value *arg2) value_zero (t1, not_lval), 0, t1, 1); if (v) { - struct value *v2 = value_ind (arg2); - VALUE_ADDRESS (v2) -= VALUE_ADDRESS (v) - + VALUE_OFFSET (v); - - /* JYG: adjust the new pointer value and - embedded offset. */ - v2->aligner.contents[0] -= VALUE_EMBEDDED_OFFSET (v); - VALUE_EMBEDDED_OFFSET (v2) = 0; - - v2 = value_addr (v2); - VALUE_TYPE (v2) = type; - return v2; + CORE_ADDR addr2 = value_as_address (arg2); + addr2 -= (VALUE_ADDRESS (v) + + VALUE_OFFSET (v) + + VALUE_EMBEDDED_OFFSET (v)); + return value_from_pointer (type, addr2); } } } |