aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/testsuite/gdb.cp/casts.cc20
-rw-r--r--gdb/testsuite/gdb.cp/casts.exp6
-rw-r--r--gdb/valops.c2
3 files changed, 27 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.cp/casts.cc b/gdb/testsuite/gdb.cp/casts.cc
index 543db89..ea4dc96 100644
--- a/gdb/testsuite/gdb.cp/casts.cc
+++ b/gdb/testsuite/gdb.cp/casts.cc
@@ -34,6 +34,20 @@ struct DoublyDerived : public VirtuallyDerived,
{
};
+struct Left
+{
+ int left;
+};
+
+struct Right
+{
+ int right;
+};
+
+struct LeftRight : public Left, public Right
+{
+};
+
int
main (int argc, char **argv)
{
@@ -48,5 +62,11 @@ main (int argc, char **argv)
Alpha *ad = &derived;
Alpha *add = &doublyderived;
+ LeftRight gd;
+ gd.left = 23;
+ gd.right = 27;
+ unsigned long long gd_value = (unsigned long long) &gd;
+ unsigned long long r_value = (unsigned long long) (Right *) &gd;
+
return 0; /* breakpoint spot: casts.exp: 1 */
}
diff --git a/gdb/testsuite/gdb.cp/casts.exp b/gdb/testsuite/gdb.cp/casts.exp
index cda870f..5d0a524 100644
--- a/gdb/testsuite/gdb.cp/casts.exp
+++ b/gdb/testsuite/gdb.cp/casts.exp
@@ -174,6 +174,12 @@ gdb_test "print dynamic_cast<Gamma *> (add)" \
" = \\(Gamma \\*\\) $nonzero_hex" \
"dynamic_cast to sibling"
+gdb_test "print (unsigned long long) &gd == gd_value" " = true"
+gdb_test "print (unsigned long long) (LeftRight *) (Right *) &gd == gd_value" \
+ " = true"
+gdb_test "print (unsigned long long) (LeftRight *) (Right *) r_value == gd_value" \
+ " = true"
+
if {[prepare_for_testing "failed to prepare" ${testfile}03 $srcfile2 \
{debug c++ additional_flags=-std=c++03}]} {
return -1
diff --git a/gdb/valops.c b/gdb/valops.c
index 42a1213..e84cabf 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -274,7 +274,7 @@ value_cast_structs (struct type *type, struct value *v2)
if (v)
{
/* Downcasting is possible (t1 is superclass of v2). */
- CORE_ADDR addr2 = value_address (v2);
+ CORE_ADDR addr2 = value_address (v2) + value_embedded_offset (v2);
addr2 -= value_address (v) + value_embedded_offset (v);
return value_at (type, addr2);