add incomplete type tests

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@580 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
syntheticpp 2006-03-02 09:57:39 +00:00
parent a28d4d6ddd
commit f13e5f58ef
3 changed files with 76 additions and 2 deletions

View file

@ -332,6 +332,10 @@
RelativePath=".\type.h" RelativePath=".\type.h"
> >
</File> </File>
<File
RelativePath=".\type2.h"
>
</File>
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>

View file

@ -10,7 +10,7 @@
// without express or implied warranty. // without express or implied warranty.
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// $Header: // $Header$
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning (disable: 4512) #pragma warning (disable: 4512)
@ -166,6 +166,13 @@ int main()
// more test code // 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<E> // Definition of ImplT<E>
///////////////////////////////////////// /////////////////////////////////////////

View file

@ -19,14 +19,18 @@
// class A2 declaration // class A2 declaration
///////////////////////////////////////// /////////////////////////////////////////
template< class T>
class Impl;
class A2 class A2
{ {
public: public:
A2(); A2();
~A2();
void foo(); void foo();
private: private:
PimplT<A2> d; PimplT<A2>::Type d;
}; };
@ -38,6 +42,7 @@ class B2 : private PimplT<B2>::Owner
{ {
public: public:
B2(); B2();
~B2();
void foo(); void foo();
}; };
@ -51,6 +56,7 @@ class C2
{ {
public: public:
C2(); C2();
~C2();
void foo(); void foo();
private: private:
@ -67,5 +73,62 @@ class D2 : private RimplT<D2>::Owner
{ {
public: public:
D2(); D2();
~D2();
void foo(); void foo();
}; };
/////////////////////////////////////////
// incomplete type test
/////////////////////////////////////////
class Incomplete1
{
public:
Incomplete1();
void foo();
private:
PimplT<Incomplete1>::Type d;
};
class Incomplete2
{
public:
Incomplete2();
~Incomplete2();
void foo();
private:
PimplT<Incomplete2>::Type d;
};
// Test: don't compile with inline destructor
#if 0
class Incomplete3
{
public:
Incomplete3();
~Incomplete3()
{
// inline destructor
}
void foo();
private:
PimplT<Incomplete3>::Type d;
};
#endif
// Test: don't compile with incomplete type and auto_ptr
#include <memory>
class Impl4;
class Incomplete4
{
public:
Incomplete4();
void foo();
private:
Pimpl<Impl4, std::auto_ptr<Impl4> > d;
};