// { dg-do run }
|
// { dg-do run }
|
// prms-id: 16146
|
// prms-id: 16146
|
|
|
extern "C" int printf (const char *, ...);
|
extern "C" int printf (const char *, ...);
|
|
|
class myFoundation {
|
class myFoundation {
|
protected:
|
protected:
|
myFoundation () { count = 0; }
|
myFoundation () { count = 0; }
|
virtual ~myFoundation () {}
|
virtual ~myFoundation () {}
|
|
|
public:
|
public:
|
void addRef () { ++count; }
|
void addRef () { ++count; }
|
void removeRef () { if (count > 0) --count; }
|
void removeRef () { if (count > 0) --count; }
|
|
|
private:
|
private:
|
long count;
|
long count;
|
};
|
};
|
|
|
|
|
class firstIntermediate :virtual public myFoundation {
|
class firstIntermediate :virtual public myFoundation {
|
public:
|
public:
|
firstIntermediate () {}
|
firstIntermediate () {}
|
~firstIntermediate () {}
|
~firstIntermediate () {}
|
|
|
void bar () { printf ("Bar\n"); }
|
void bar () { printf ("Bar\n"); }
|
};
|
};
|
|
|
|
|
class firstBase : public firstIntermediate {
|
class firstBase : public firstIntermediate {
|
public:
|
public:
|
firstBase () {}
|
firstBase () {}
|
~firstBase () {}
|
~firstBase () {}
|
|
|
virtual void g () {}
|
virtual void g () {}
|
};
|
};
|
|
|
|
|
class secondIntermediate : virtual public myFoundation {
|
class secondIntermediate : virtual public myFoundation {
|
public:
|
public:
|
secondIntermediate () {}
|
secondIntermediate () {}
|
~secondIntermediate () {}
|
~secondIntermediate () {}
|
|
|
virtual void h () {}
|
virtual void h () {}
|
};
|
};
|
|
|
|
|
class secondBase : public secondIntermediate {
|
class secondBase : public secondIntermediate {
|
public:
|
public:
|
secondBase () {}
|
secondBase () {}
|
~secondBase () {}
|
~secondBase () {}
|
|
|
virtual void h () {}
|
virtual void h () {}
|
};
|
};
|
|
|
|
|
class typeInterface : virtual public firstBase {
|
class typeInterface : virtual public firstBase {
|
public:
|
public:
|
typeInterface () {}
|
typeInterface () {}
|
~typeInterface () {}
|
~typeInterface () {}
|
|
|
virtual void i () {}
|
virtual void i () {}
|
};
|
};
|
|
|
class classServices : virtual public firstBase,
|
class classServices : virtual public firstBase,
|
public secondBase {
|
public secondBase {
|
public:
|
public:
|
classServices () {}
|
classServices () {}
|
~classServices () {}
|
~classServices () {}
|
|
|
virtual void j () {}
|
virtual void j () {}
|
};
|
};
|
|
|
class classImplementation : public typeInterface,
|
class classImplementation : public typeInterface,
|
public classServices {
|
public classServices {
|
public:
|
public:
|
classImplementation () {}
|
classImplementation () {}
|
~classImplementation () {}
|
~classImplementation () {}
|
|
|
void g () {}
|
void g () {}
|
void h () {}
|
void h () {}
|
void i () {}
|
void i () {}
|
void j () {}
|
void j () {}
|
};
|
};
|
|
|
int main () {
|
int main () {
|
firstBase* fbp = new classImplementation;
|
firstBase* fbp = new classImplementation;
|
classImplementation* cip = dynamic_cast (fbp);
|
classImplementation* cip = dynamic_cast (fbp);
|
cip->addRef();
|
cip->addRef();
|
myFoundation* mfp = cip;
|
myFoundation* mfp = cip;
|
}
|
}
|
|
|