]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/lang/cpp/diamond/main.cpp
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / lang / cpp / diamond / main.cpp
1 //===-- main.cpp ------------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 #include <stdio.h>
10
11 static int g_next_value = 12345;
12
13 class VBase
14 {
15 public:
16     VBase() : m_value(g_next_value++) {}
17     virtual ~VBase() {}
18     void Print() 
19     {
20         printf("%p: %s\n%p: m_value = 0x%8.8x\n", this, __PRETTY_FUNCTION__, &m_value, m_value);
21     }
22     int m_value;
23 };
24
25 class Derived1 : public virtual VBase
26 {
27 public:
28     Derived1() {};
29     void Print ()
30     {
31         printf("%p: %s\n", this, __PRETTY_FUNCTION__);
32         VBase::Print();
33     }
34
35 };
36
37 class Derived2 : public virtual VBase
38 {
39 public:
40     Derived2() {};
41     
42     void Print ()
43     {
44         printf("%p: %s\n", this, __PRETTY_FUNCTION__);
45         VBase::Print();
46     }
47 };
48
49 class Joiner1 : public Derived1, public Derived2
50 {
51 public:
52     Joiner1() : 
53         m_joiner1(3456), 
54         m_joiner2(6789) {}
55     void Print ()
56     {
57         printf("%p: %s \n%p: m_joiner1 = 0x%8.8x\n%p: m_joiner2 = 0x%8.8x\n",
58                this,
59                __PRETTY_FUNCTION__,
60                &m_joiner1,
61                m_joiner1,
62                &m_joiner2,
63                m_joiner2);
64         Derived1::Print();
65         Derived2::Print();
66     }
67     int m_joiner1;
68     int m_joiner2;
69 };
70
71 class Joiner2 : public Derived2
72 {
73     int m_stuff[32];
74 };
75
76 int main(int argc, const char * argv[])
77 {
78     Joiner1 j1;
79     Joiner2 j2;
80     j1.Print();
81     j2.Print();
82     Derived2 *d = &j1;
83     d = &j2;  // breakpoint 1
84     return 0; // breakpoint 2
85 }