gcc/libvtv/testsuite/libvtv.cc/povray-derived.cc
Caroline Tice 41e96dc8f0 Update libvtv testsuite so that most of the tests now run under
the dejagnu test harness.

From-SVN: r202373
2013-09-08 16:35:14 -07:00

75 lines
1.0 KiB
C++

// { dg-do run }
// Small test case from povray, see if it reproduces.
#include <stdio.h>
class POVMS_MessageReceiver
{
private:
int x;
class Handler
{
public:
virtual void print() = 0;
};
protected:
template<class T> class MemberHandler : public Handler
{
public:
MemberHandler(T *xx)
{
x = xx;
}
~MemberHandler() {}
void print()
{
printf("In print\n");
}
private:
T *x;
};
private:
struct HandlerNode
{
Handler *handler;
};
HandlerNode *receiver;
public:
POVMS_MessageReceiver(int xx) : x(xx) {}
~POVMS_MessageReceiver() {}
void foo(int *xx);
void try_call();
};
void POVMS_MessageReceiver::foo(int *xx)
{
receiver = new HandlerNode;
receiver->handler = new MemberHandler<int>(xx);
}
void POVMS_MessageReceiver::try_call()
{
receiver->handler->print();
}
int main()
{
int loc = 34;
POVMS_MessageReceiver a_test(100);
a_test.foo(&loc);
a_test.try_call();
}