aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp/virtbase.cc
blob: 1e6874fd3b0d595bff3e52c556bb3964a1d0b783 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// This first batch of classes are for PR 11226.
namespace mc {
  class Base {
  protected:
    int x;
    
  public:
    Base(void) { x = 2; };
  };
}

namespace ph {
  class Middle: public virtual mc::Base {
  protected:
    int y;
    
  public:
    Middle(void): mc::Base() { y = 3; };

    int get_y(void)
    {
      return y;			// breakpoint 1
    };
  };

  class Derived: public virtual Middle {
  protected:
    int z;
    
  public:
    Derived(void): Middle() { z = 4; };

    int get_z(void)
    {
      return z;			// breakpoint 2
    };
  };
}

// These classes are for PR 9629.
struct A {};
struct B : virtual A {};

struct C {int v; C() {v=11;};};
struct D:virtual C{};

class E:B,D{};

// These classes are for another regression test, from
// https://bugzilla.redhat.com/show_bug.cgi?id=560741

class RHA
{
public:
  RHA() : mA(0xaaaaaaaa) {}
  virtual void a() = 0;  
  int mA;
};

class RHB
{
public:
  RHB() : mB(0xbbbbbbbb) {}
  virtual void b() = 0;
  int mB;
};

class RHC : public RHA,
	  public RHB
{
public:
  RHC() : RHA(), RHB() {}
  virtual void a() {}
  virtual void b() {}
};

class RTTI_base
{
public:
  virtual ~RTTI_base() {}
};

class RTTI_data
{
public:
  RTTI_base base;
  int data;
  RTTI_data() : data(1) {}
};

int main() {
  ph::Derived tst;
  tst.get_y();
  tst.get_z();

  E *e = new E;
  RHB *b = new RHC();
  RTTI_data rtti_data;

  return 0;			// breakpoint 3
}