Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.mike/p16146.C

raw
1 // { dg-do run }
2 // prms-id: 16146
3
4 extern "C" int printf (const char *, ...);
5
6 class myFoundation {
7 protected:
8 myFoundation () { count = 0; }
9 virtual ~myFoundation () {}
10
11 public:
12 void addRef () { ++count; }
13 void removeRef () { if (count > 0) --count; }
14
15 private:
16 long count;
17 };
18
19
20 class firstIntermediate :virtual public myFoundation {
21 public:
22 firstIntermediate () {}
23 ~firstIntermediate () {}
24
25 void bar () { printf ("Bar\n"); }
26 };
27
28
29 class firstBase : public firstIntermediate {
30 public:
31 firstBase () {}
32 ~firstBase () {}
33
34 virtual void g () {}
35 };
36
37
38 class secondIntermediate : virtual public myFoundation {
39 public:
40 secondIntermediate () {}
41 ~secondIntermediate () {}
42
43 virtual void h () {}
44 };
45
46
47 class secondBase : public secondIntermediate {
48 public:
49 secondBase () {}
50 ~secondBase () {}
51
52 virtual void h () {}
53 };
54
55
56 class typeInterface : virtual public firstBase {
57 public:
58 typeInterface () {}
59 ~typeInterface () {}
60
61 virtual void i () {}
62 };
63
64 class classServices : virtual public firstBase,
65 public secondBase {
66 public:
67 classServices () {}
68 ~classServices () {}
69
70 virtual void j () {}
71 };
72
73 class classImplementation : public typeInterface,
74 public classServices {
75 public:
76 classImplementation () {}
77 ~classImplementation () {}
78
79 void g () {}
80 void h () {}
81 void i () {}
82 void j () {}
83 };
84
85 int main () {
86 firstBase* fbp = new classImplementation;
87 classImplementation* cip = dynamic_cast <classImplementation*> (fbp);
88 cip->addRef();
89 myFoundation* mfp = cip;
90 }