From f13e5f58eff1d8b517ea0566b8881a488a3672a4 Mon Sep 17 00:00:00 2001 From: syntheticpp Date: Thu, 2 Mar 2006 09:57:39 +0000 Subject: [PATCH] add incomplete type tests git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@580 7ec92016-0320-0410-acc4-a06ded1c099a --- test/Pimpl/Pimpl.vcproj | 4 +++ test/Pimpl/main.cpp | 9 +++++- test/Pimpl/type2.h | 65 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/test/Pimpl/Pimpl.vcproj b/test/Pimpl/Pimpl.vcproj index 2879ad8..e754498 100755 --- a/test/Pimpl/Pimpl.vcproj +++ b/test/Pimpl/Pimpl.vcproj @@ -332,6 +332,10 @@ RelativePath=".\type.h" > + + diff --git a/test/Pimpl/main.cpp b/test/Pimpl/main.cpp index fb23cf3..52ba9ea 100755 --- a/test/Pimpl/main.cpp +++ b/test/Pimpl/main.cpp @@ -10,7 +10,7 @@ // without express or implied warranty. //////////////////////////////////////////////////////////////////////////////// -// $Header: +// $Header$ #ifdef _MSC_VER #pragma warning (disable: 4512) @@ -166,6 +166,13 @@ int main() // more test code //////////////////// +// incomplete type test +// this must give errors + +//Incomplete1 ii; // compiler error +//Incomplete2 i2; // linker error +//Incomplete4 i4; // compiler error + ///////////////////////////////////////// // Definition of ImplT ///////////////////////////////////////// diff --git a/test/Pimpl/type2.h b/test/Pimpl/type2.h index 444a6fb..029a69e 100755 --- a/test/Pimpl/type2.h +++ b/test/Pimpl/type2.h @@ -19,14 +19,18 @@ // class A2 declaration ///////////////////////////////////////// +template< class T> +class Impl; + class A2 { public: A2(); + ~A2(); void foo(); private: - PimplT d; + PimplT::Type d; }; @@ -38,6 +42,7 @@ class B2 : private PimplT::Owner { public: B2(); + ~B2(); void foo(); }; @@ -51,6 +56,7 @@ class C2 { public: C2(); + ~C2(); void foo(); private: @@ -67,5 +73,62 @@ class D2 : private RimplT::Owner { public: D2(); + ~D2(); void foo(); }; + + +///////////////////////////////////////// +// incomplete type test +///////////////////////////////////////// +class Incomplete1 +{ +public: + Incomplete1(); + void foo(); +private: + PimplT::Type d; +}; + +class Incomplete2 +{ +public: + Incomplete2(); + ~Incomplete2(); + void foo(); +private: + PimplT::Type d; +}; + + +// Test: don't compile with inline destructor +#if 0 + +class Incomplete3 +{ +public: + Incomplete3(); + ~Incomplete3() + { + // inline destructor + } + void foo(); +private: + PimplT::Type d; +}; +#endif + + +// Test: don't compile with incomplete type and auto_ptr + +#include + +class Impl4; +class Incomplete4 +{ +public: + Incomplete4(); + void foo(); +private: + Pimpl > d; +};