diff options
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/gdb.cp/casts.cc | 22 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/casts.exp | 20 |
2 files changed, 42 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/casts.cc b/gdb/testsuite/gdb.cp/casts.cc index f64d13c..5c7f9dc 100644 --- a/gdb/testsuite/gdb.cp/casts.cc +++ b/gdb/testsuite/gdb.cp/casts.cc @@ -50,6 +50,24 @@ struct LeftRight : public Left, public Right { }; +struct VirtualLeft +{ + virtual ~VirtualLeft () {} + + int left; +}; + +struct VirtualRight +{ + virtual ~VirtualRight () {} + + int right; +}; + +struct VirtualLeftRight : public VirtualLeft, public VirtualRight +{ +}; + int main (int argc, char **argv) { @@ -70,5 +88,9 @@ main (int argc, char **argv) unsigned long long gd_value = (unsigned long long) (std::uintptr_t)&gd; unsigned long long r_value = (unsigned long long) (Right *) &gd; + VirtualLeftRight *vlr = new VirtualLeftRight (); + VirtualLeft *vl = vlr; + VirtualRight *vr = vlr; + return 0; /* breakpoint spot: casts.exp: 1 */ } diff --git a/gdb/testsuite/gdb.cp/casts.exp b/gdb/testsuite/gdb.cp/casts.exp index 41bb125..a0c7382 100644 --- a/gdb/testsuite/gdb.cp/casts.exp +++ b/gdb/testsuite/gdb.cp/casts.exp @@ -180,6 +180,26 @@ gdb_test "print (unsigned long long) (LeftRight *) (Right *) &gd == gd_value" \ gdb_test "print (unsigned long long) (LeftRight *) (Right *) r_value == gd_value" \ " = true" +gdb_test "print dynamic_cast<VirtualLeftRight *> (vlr) == vlr" " = true" +gdb_test "print dynamic_cast<VirtualLeftRight *> (vl) == vlr" " = true" +gdb_test "print dynamic_cast<VirtualLeftRight *> (vr) == vlr" " = true" +gdb_test "print dynamic_cast<VirtualLeft *> (vlr) == vl" " = true" +gdb_test "print dynamic_cast<VirtualLeft *> (vl) == vl" " = true" +gdb_test "print dynamic_cast<VirtualLeft *> (vr) == vl" " = true" +gdb_test "print dynamic_cast<VirtualRight *> (vlr) == vr" " = true" +gdb_test "print dynamic_cast<VirtualRight *> (vl) == vr" " = true" +gdb_test "print dynamic_cast<VirtualRight *> (vr) == vr" " = true" + +gdb_test "print &dynamic_cast<VirtualLeftRight &> (*vlr) == vlr" " = true" +gdb_test "print &dynamic_cast<VirtualLeftRight &> (*vl) == vlr" " = true" +gdb_test "print &dynamic_cast<VirtualLeftRight &> (*vr) == vlr" " = true" +gdb_test "print &dynamic_cast<VirtualLeft &> (*vlr) == vl" " = true" +gdb_test "print &dynamic_cast<VirtualLeft &> (*vl) == vl" " = true" +gdb_test "print &dynamic_cast<VirtualLeft &> (*vr) == vl" " = true" +gdb_test "print &dynamic_cast<VirtualRight &> (*vlr) == vr" " = true" +gdb_test "print &dynamic_cast<VirtualRight &> (*vl) == vr" " = true" +gdb_test "print &dynamic_cast<VirtualRight &> (*vr) == vr" " = true" + if {[prepare_for_testing "failed to prepare" ${testfile}03 $srcfile2 \ {debug c++ additional_flags=-std=c++03}]} { return -1 |