aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp/virtbase.cc
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2011-02-02 17:41:54 +0000
committerPedro Alves <palves@redhat.com>2011-02-02 17:41:54 +0000
commit580688f393b43a7456e3bf2857da9c5401e8954f (patch)
tree0a3e410d5f8c8057b923342ff003021d3e290495 /gdb/testsuite/gdb.cp/virtbase.cc
parent3d2c1d41d4b6cdaa6052ddfd99b0745cc70c9cbb (diff)
downloadgdb-580688f393b43a7456e3bf2857da9c5401e8954f.zip
gdb-580688f393b43a7456e3bf2857da9c5401e8954f.tar.gz
gdb-580688f393b43a7456e3bf2857da9c5401e8954f.tar.bz2
gdb/
* c-valprint.c (c_value_print): When doing virtual base pointer adjustment, create a new value with adjusted contents rather than changing the contents of the value being printed (and getting it wrong). gdb/testsuite/ * gdb.cp/virtbase.cc (VirtualBase, VirtualMiddleA, VirtualMiddleB) (Virtual): New structs. (virtual_o, virtual_middle_b): New globals. * gdb.cp/virtbase.exp: New tests.
Diffstat (limited to 'gdb/testsuite/gdb.cp/virtbase.cc')
-rw-r--r--gdb/testsuite/gdb.cp/virtbase.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/virtbase.cc b/gdb/testsuite/gdb.cp/virtbase.cc
index 1e6874f..e23dbda 100644
--- a/gdb/testsuite/gdb.cp/virtbase.cc
+++ b/gdb/testsuite/gdb.cp/virtbase.cc
@@ -88,6 +88,37 @@ public:
RTTI_data() : data(1) {}
};
+/* These classes are for testing pointer adjustment when printing a
+ pointer into a virtual base, with print object on. */
+struct VirtualBase {
+ int x;
+
+ virtual ~VirtualBase() {}
+};
+
+struct VirtualMiddleA : public virtual VirtualBase {
+ /* Make sure the vbase offset of Virtual::VirtualBaseB is larger
+ than what fits in one byte. */
+ int y[300];
+
+ virtual ~VirtualMiddleA() {}
+};
+
+struct VirtualMiddleB : public virtual VirtualBase {
+ int y;
+
+ virtual ~VirtualMiddleB() {}
+};
+
+struct Virtual : public virtual VirtualMiddleA, public virtual VirtualMiddleB {
+ int z;
+
+ virtual ~Virtual() {}
+};
+
+Virtual virtual_o;
+VirtualMiddleB *virtual_middle_b = &virtual_o;
+
int main() {
ph::Derived tst;
tst.get_y();