diff options
Diffstat (limited to 'libvtv/testsuite/libvtv.cc/test1.cc')
-rw-r--r-- | libvtv/testsuite/libvtv.cc/test1.cc | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/libvtv/testsuite/libvtv.cc/test1.cc b/libvtv/testsuite/libvtv.cc/test1.cc new file mode 100644 index 00000000000..9005826dff4 --- /dev/null +++ b/libvtv/testsuite/libvtv.cc/test1.cc @@ -0,0 +1,74 @@ +// { 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(); +} + + + |