// { dg-do assemble }
|
// { dg-do assemble }
|
// PRMS ID: 7507
|
// PRMS ID: 7507
|
|
|
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
|
|
class Base0
|
class Base0
|
{
|
{
|
public:
|
public:
|
Base0() {}
|
Base0() {}
|
virtual ~Base0() {}
|
virtual ~Base0() {}
|
};
|
};
|
|
|
class Base1
|
class Base1
|
{
|
{
|
public:
|
public:
|
Base1() {}
|
Base1() {}
|
virtual ~Base1() {}
|
virtual ~Base1() {}
|
};
|
};
|
|
|
class Derived : public Base0, public Base1
|
class Derived : public Base0, public Base1
|
{
|
{
|
public:
|
public:
|
Derived() {}
|
Derived() {}
|
virtual ~Derived() {}
|
virtual ~Derived() {}
|
};
|
};
|
|
|
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
|
|
class Dummy
|
class Dummy
|
{
|
{
|
public:
|
public:
|
Dummy(Base0 * theBase) {}
|
Dummy(Base0 * theBase) {}
|
~Dummy() {}
|
~Dummy() {}
|
};
|
};
|
|
|
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
|
|
template
|
template
|
class ConstSmartPtr
|
class ConstSmartPtr
|
{
|
{
|
T* myItem; // private
|
T* myItem; // private
|
|
|
public:
|
public:
|
ConstSmartPtr(T const* theItem);
|
ConstSmartPtr(T const* theItem);
|
|
|
operator T const*() const
|
operator T const*() const
|
{ return myItem; }
|
{ return myItem; }
|
protected:
|
protected:
|
T* _item() const
|
T* _item() const
|
{ return myItem; }
|
{ return myItem; }
|
};
|
};
|
|
|
template
|
template
|
class SmartPtr : public ConstSmartPtr
|
class SmartPtr : public ConstSmartPtr
|
{
|
{
|
public:
|
public:
|
SmartPtr(T* theItem)
|
SmartPtr(T* theItem)
|
: ConstSmartPtr(theItem) {}
|
: ConstSmartPtr(theItem) {}
|
|
|
T* item() const
|
T* item() const
|
{ return this->_item(); }
|
{ return this->_item(); }
|
|
|
operator T*() const
|
operator T*() const
|
{ return this->_item(); }
|
{ return this->_item(); }
|
};
|
};
|
|
|
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
|
|
void
|
void
|
function()
|
function()
|
{
|
{
|
SmartPtr myObj = new Derived();
|
SmartPtr myObj = new Derived();
|
|
|
Dummy th1(myObj); // Doesn't work under Cygnus
|
Dummy th1(myObj); // Doesn't work under Cygnus
|
Dummy th2((Base0 *) myObj); // Doesn't work either
|
Dummy th2((Base0 *) myObj); // Doesn't work either
|
}
|
}
|
|
|
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
|
|