diff options
author | Aleksandar Ristovski <aristovski@qnx.com> | 2008-04-01 16:16:43 +0000 |
---|---|---|
committer | Aleksandar Ristovski <aristovski@qnx.com> | 2008-04-01 16:16:43 +0000 |
commit | f0050c208902d6609eb02162b33d8e64003fbce5 (patch) | |
tree | 242347bbc8b1c13e016601261ba78459e415864d /gdb | |
parent | 6af87b034856eae3d77416c5b2a67bdd60072946 (diff) | |
download | gdb-f0050c208902d6609eb02162b33d8e64003fbce5.zip gdb-f0050c208902d6609eb02162b33d8e64003fbce5.tar.gz gdb-f0050c208902d6609eb02162b33d8e64003fbce5.tar.bz2 |
* gdb.cp/casts.cc: Add class reference variables.
* gdb.cp/casts.exp: New test cases for up/down casting references.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/testsuite/gdb.cp/casts.cc | 2 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/casts.exp | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/casts.cc b/gdb/testsuite/gdb.cp/casts.cc index 831add9..6ecd340 100644 --- a/gdb/testsuite/gdb.cp/casts.cc +++ b/gdb/testsuite/gdb.cp/casts.cc @@ -15,6 +15,8 @@ main (int argc, char **argv) { A *a = new B(42, 1729); B *b = (B *) a; + A &ar = *b; + B &br = (B&)ar; return 0; /* breakpoint spot: casts.exp: 1 */ } diff --git a/gdb/testsuite/gdb.cp/casts.exp b/gdb/testsuite/gdb.cp/casts.exp index 9d6c472..c8b7332 100644 --- a/gdb/testsuite/gdb.cp/casts.exp +++ b/gdb/testsuite/gdb.cp/casts.exp @@ -80,3 +80,20 @@ gdb_test "print * (B *) a" ".* = {<A> = {a = 42}, b = 1729}" \ # the dereference. gdb_test "print * b" ".* = {<A> = {a = 42}, b = 1729}" \ "let compiler cast base class pointer to derived class pointer" + +# Check upcasting (it is trivial but still). +gdb_test "print * (A *) b" ".* = {a = 42}" \ + "cast derived class pointer to base class pointer" + +# Casting References. +# Check upcasting. +gdb_test "print (A &) br" ".* = .A &.* {a = 42}" \ + "cast derived class reference to base class reference" + +# Check downcasting. +gdb_test "print (B &) ar" ".* = .B.* {<A> = {a = 42}, b = 1729}" \ + "cast base class reference to derived class reference" + +# Check compiler casting +gdb_test "print br" ".* = .B.* {<A> = {a = 42}, b = 1729}" \ + "let compiler cast base class reference to derived class reference" |