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