[PING^2] Fix dynamic_cast operator
Commit Message
Original post: https://sourceware.org/ml/gdb-patches/2014-04/msg00089.html
ChangeLog:
2014-04-28 Siva Chandra Reddy <sivachandra@google.com>
* valops.c (value_dynamic_cast): Fix mixup between rtti_type
and resolved_type.
testsuite/
* gdb.cp/casts.exp: Adjust expected result for few tests.
Comments
On Mon, Apr 28, 2014 at 7:13 AM, Siva Chandra <sivachandra@google.com> wrote:
> Original post: https://sourceware.org/ml/gdb-patches/2014-04/msg00089.html
>
> ChangeLog:
> 2014-04-28 Siva Chandra Reddy <sivachandra@google.com>
>
> * valops.c (value_dynamic_cast): Fix mixup between rtti_type
> and resolved_type.
>
> testsuite/
> * gdb.cp/casts.exp: Adjust expected result for few tests.
Hi.
fyi, I've been deferring commenting on this patch as I think the
original author of dynamic_cast support can do a better job. Tom can
get to it whenever he's able. Just letting you know I haven't set
aside time to.
On Mon, Apr 28, 2014 at 7:13 AM, Siva Chandra <sivachandra@google.com> wrote:
> Original post: https://sourceware.org/ml/gdb-patches/2014-04/msg00089.html
>
> ChangeLog:
> 2014-04-28 Siva Chandra Reddy <sivachandra@google.com>
>
> * valops.c (value_dynamic_cast): Fix mixup between rtti_type
> and resolved_type.
>
> testsuite/
> * gdb.cp/casts.exp: Adjust expected result for few tests.
Ping.
I have seen some patches around dynamic values recently and hence
trying to bubble this up.
@@ -151,8 +151,7 @@ gdb_test "print dynamic_cast<Alpha &> (derived)" \
"dynamic_cast simple upcast to reference"
gdb_test "print dynamic_cast<Derived *> (ad)" \
- " = \\(Derived \\*\\) ${nonzero_hex}( <vtable for Derived.*>)?" \
- "dynamic_cast simple downcast"
+ " = \\(Derived \\*\\) ${nonzero_hex}" "dynamic_cast simple downcast"
gdb_test "print dynamic_cast<VirtuallyDerived *> (add)" \
" = \\(VirtuallyDerived \\*\\) $nonzero_hex" \
@@ -167,8 +166,7 @@ gdb_test "print dynamic_cast<VirtuallyDerived &> (*ad)" \
"dynamic_cast to reference to non-existing base"
gdb_test "print dynamic_cast<DoublyDerived *> (add)" \
- " = \\(DoublyDerived \\*\\) ${nonzero_hex}( <vtable for DoublyDerived.*>)?" \
- "dynamic_cast unique downcast"
+ " = \\(DoublyDerived \\*\\) ${nonzero_hex}" "dynamic_cast unique downcast"
gdb_test "print dynamic_cast<Gamma *> (add)" \
" = \\(Gamma \\*\\) $nonzero_hex" \
@@ -801,14 +801,14 @@ value_dynamic_cast (struct type *type, struct value *arg)
&& TYPE_CODE (TYPE_TARGET_TYPE (resolved_type)) == TYPE_CODE_VOID)
return value_at_lazy (type, addr);
- tem = value_at (type, addr);
- type = value_type (tem);
+ tem = value_at (rtti_type, addr);
/* The first dynamic check specified in 5.2.7. */
if (is_public_ancestor (arg_type, TYPE_TARGET_TYPE (resolved_type)))
{
if (class_types_same_p (rtti_type, TYPE_TARGET_TYPE (resolved_type)))
- return tem;
+ return value_from_pointer (type, addr);
+
result = NULL;
if (dynamic_cast_check_1 (TYPE_TARGET_TYPE (resolved_type),
value_contents_for_printing (tem),