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:
parent
a28d4d6ddd
commit
f13e5f58ef
3 changed files with 76 additions and 2 deletions
|
@ -332,6 +332,10 @@
|
|||
RelativePath=".\type.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\type2.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
|
|
@ -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<E>
|
||||
/////////////////////////////////////////
|
||||
|
|
|
@ -19,14 +19,18 @@
|
|||
// class A2 declaration
|
||||
/////////////////////////////////////////
|
||||
|
||||
template< class T>
|
||||
class Impl;
|
||||
|
||||
class A2
|
||||
{
|
||||
public:
|
||||
A2();
|
||||
~A2();
|
||||
void foo();
|
||||
|
||||
private:
|
||||
PimplT<A2> d;
|
||||
PimplT<A2>::Type d;
|
||||
};
|
||||
|
||||
|
||||
|
@ -38,6 +42,7 @@ class B2 : private PimplT<B2>::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<D2>::Owner
|
|||
{
|
||||
public:
|
||||
D2();
|
||||
~D2();
|
||||
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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue