- Disabled -Weffc++ flag, fixing these warnings produces too much useless code

- Enabled -pedantic, -Wold-style-cast and -Wundef for src/ and test/


git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@499 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
lfittl 2006-01-19 23:11:57 +00:00
parent 7acf9ff6be
commit c68642eb5f
25 changed files with 83 additions and 56 deletions

View file

@ -9,6 +9,7 @@ General:
- improved Makefiles (lf)
- improved make.msvc.bat files (pk)
- cvs LOG keywords added (rs)
- removed old c style casts (lf)
Singleton:
- support of allocators with a standard interface added (Thanks to Miguel A. Figueroa-Villanueva, pk)
@ -217,4 +218,4 @@ Threading:
LOKI_CLASS_LEVEL_THREADING and LOKI_OBJECT_LEVEL_THREADING (pk)
CVS commits by Rich Sposato (rs) and Peter Kümmel (pk)
CVS commits by Rich Sposato (rs) and Peter Kümmel (pk)

View file

@ -726,6 +726,7 @@ template <typename AP, typename Id, typename P1 >
public:
Factory()
: associations_()
{
}
@ -1035,6 +1036,10 @@ template <typename AP, typename Id, typename P1 >
#endif // FACTORY_INC_
// $Log$
// Revision 1.15 2006/01/19 23:11:55 lfittl
// - Disabled -Weffc++ flag, fixing these warnings produces too much useless code
// - Enabled -pedantic, -Wold-style-cast and -Wundef for src/ and test/
//
// Revision 1.14 2006/01/16 19:05:09 rich_sposato
// Added cvs keywords.
//

View file

@ -537,6 +537,8 @@ namespace Loki
class SingletonFixedLongevity
{
public:
virtual ~SingletonFixedLongevity() {}
static void ScheduleDestruction(T* pObj, atexit_pfn_t pFun)
{
Private::Adapter<T> adapter = { pFun };
@ -833,6 +835,10 @@ namespace Loki
#endif // SINGLETON_INC_
// $Log$
// Revision 1.22 2006/01/19 23:11:55 lfittl
// - Disabled -Weffc++ flag, fixing these warnings produces too much useless code
// - Enabled -pedantic, -Wold-style-cast and -Wundef for src/ and test/
//
// Revision 1.21 2006/01/16 20:10:51 syntheticpp
// another fight against tabs
//

View file

@ -324,7 +324,7 @@ public:
void reserve(size_type res_arg = 0)
{
Enforce(res_arg <= max_size(), (std::length_error*)0, "");
Enforce(res_arg <= max_size(), static_cast<std::length_error*>(0), "");
Storage::reserve(res_arg);
}
@ -343,13 +343,13 @@ public:
const_reference at(size_type n) const
{
Enforce(n <= size(), (std::out_of_range*)0, "");
Enforce(n <= size(), static_cast<std::out_of_range*>(0), "");
return (*this)[n];
}
reference at(size_type n)
{
Enforce(n < size(), (std::out_of_range*)0, "");
Enforce(n < size(), static_cast<std::out_of_range*>(0), "");
return (*this)[n];
}
@ -373,7 +373,7 @@ public:
size_type n)
{
const size_type sz = str.size();
Enforce(pos <= sz, (std::out_of_range*)0, "");
Enforce(pos <= sz, static_cast<std::out_of_range*>(0), "");
Procust(n, sz - pos);
return append(str.data() + pos, n);
}
@ -429,7 +429,7 @@ public:
size_type n)
{
const size_type sz = str.size();
Enforce(pos <= sz, (std::out_of_range*)0, "");
Enforce(pos <= sz, static_cast<std::out_of_range*>(0), "");
Procust(n, sz - pos);
return assign(str.data() + pos, n);
}
@ -465,14 +465,14 @@ public:
flex_string& insert(size_type pos1, const flex_string& str,
size_type pos2, size_type n)
{
Enforce(pos2 <= str.length(), (std::out_of_range*)0, "");
Enforce(pos2 <= str.length(), static_cast<std::out_of_range*>(0), "");
Procust(n, str.length() - pos2);
return insert(pos1, str.data() + pos2, n);
}
flex_string& insert(size_type pos, const value_type* s, size_type n)
{
Enforce(pos <= length(), (std::out_of_range*)0, "");
Enforce(pos <= length(), static_cast<std::out_of_range*>(0), "");
insert(begin() + pos, s, s + n);
return *this;
}
@ -482,7 +482,7 @@ public:
flex_string& insert(size_type pos, size_type n, value_type c)
{
Enforce(pos <= length(), (std::out_of_range*)0, "");
Enforce(pos <= length(), static_cast<std::out_of_range*>(0), "");
insert(begin() + pos, n, c);
return *this;
}
@ -612,7 +612,7 @@ public:
{
Invariant checker(*this);
(void) checker;
Enforce(pos <= length(), (std::out_of_range*)0, "");
Enforce(pos <= length(), static_cast<std::out_of_range*>(0), "");
Procust(n, length() - pos);
std::copy(begin() + pos + n, end(), begin() + pos);
resize(length() - n);
@ -642,7 +642,7 @@ public:
flex_string& replace(size_type pos1, size_type n1, const flex_string& str,
size_type pos2, size_type n2)
{
Enforce(pos2 <= str.length(), (std::out_of_range*)0, "");
Enforce(pos2 <= str.length(), static_cast<std::out_of_range*>(0), "");
return replace(pos1, n1, str.data() + pos2,
Min(n2, str.size() - pos2));
}
@ -741,7 +741,7 @@ public:
{
Invariant checker(*this);
(void) checker;
Enforce(pos <= size(), (std::out_of_range*)0, "");
Enforce(pos <= size(), static_cast<std::out_of_range*>(0), "");
Procust(n1, length() - pos);
const iterator b = begin() + pos;
return replace(b, b + n1, s_or_n2, n_or_c);
@ -854,7 +854,7 @@ public:
size_type copy(value_type* s, size_type n, size_type pos = 0) const
{
Enforce(pos <= size(), (std::out_of_range*)0, "");
Enforce(pos <= size(), static_cast<std::out_of_range*>(0), "");
Procust(n, size() - pos);
flex_string_details::pod_copy(
@ -1046,7 +1046,7 @@ public:
flex_string substr(size_type pos = 0, size_type n = npos) const
{
Enforce(pos <= size(), (std::out_of_range*)0, "");
Enforce(pos <= size(), static_cast<std::out_of_range*>(0), "");
return flex_string(data() + pos, Min(n, size() - pos));
}
@ -1073,7 +1073,7 @@ public:
int compare(size_type pos1, size_type n1,
const value_type* s, size_type n2) const
{
Enforce(pos1 <= size(), (std::out_of_range*)0, "");
Enforce(pos1 <= size(), static_cast<std::out_of_range*>(0), "");
Procust(n1, size() - pos1);
const int r = traits_type::compare(data(), s, Min(n1, n2));
return
@ -1087,7 +1087,7 @@ public:
const flex_string& str,
size_type pos2, size_type n2) const
{
Enforce(pos2 <= str.size(), (std::out_of_range*)0, "");
Enforce(pos2 <= str.size(), static_cast<std::out_of_range*>(0), "");
return compare(pos1, n1, str.data() + pos2, Min(n2, str.size() - pos2));
}
@ -1286,6 +1286,6 @@ getline(
template <typename E1, class T, class A, class S>
const typename flex_string<E1, T, A, S>::size_type
flex_string<E1, T, A, S>::npos = (typename flex_string<E1, T, A, S>::size_type)(-1);
flex_string<E1, T, A, S>::npos = static_cast<typename flex_string<E1, T, A, S>::size_type>(-1);
#endif // FLEX_STRING_SHELL_INC_

View file

@ -1,6 +1,6 @@
OBJ = Singleton.o SmallObj.o OrderedStatic.o SafeFormat.o
BIN = ../lib/libloki.a
CXXFLAGS = -Wall -Weffc++ -pedantic -O2
CXXFLAGS = -Wall -Wold-style-cast -Wundef -pedantic -O2
CPPFLAGS = -I../include -DNDEBUG
$(BIN): $(OBJ)

View file

@ -1115,7 +1115,7 @@ void * SmallObjAllocator::Allocate( std::size_t numBytes, bool doThrow )
if ( ( NULL == place ) && doThrow )
{
#if _MSC_VER
#ifdef _MSC_VER
throw std::bad_alloc( "could not allocate small object" );
#else
// GCC did not like a literal string passed to std::bad_alloc.
@ -1222,6 +1222,10 @@ bool SmallObjAllocator::IsCorrupt( void ) const
////////////////////////////////////////////////////////////////////////////////
// $Log$
// Revision 1.27 2006/01/19 23:11:56 lfittl
// - Disabled -Weffc++ flag, fixing these warnings produces too much useless code
// - Enabled -pedantic, -Wold-style-cast and -Wundef for src/ and test/
//
// Revision 1.26 2006/01/18 17:21:31 lfittl
// - Compile library with -Weffc++ and -pedantic (gcc)
// - Fix most issues raised by using -Weffc++ (initialization lists)

View file

@ -194,12 +194,12 @@ CreatorT<Product> cT;
bool reg()
{
bool const ok1 = PFactoryNull::Instance().Register( 1, createProductNull );
bool const ok2 = PFactoryNull::Instance().Register( 2, (Product*(*)()) createProductOver );
bool const ok2 = PFactoryNull::Instance().Register( 2, static_cast<Product*(*)()>(createProductOver) );
bool const ok3 = PFactoryNull::Instance().Register( 3, c, &AbstractCreator::create );
bool const ok4 = PFactoryNull::Instance().Register( 4, &cT, &CreatorT<Product>::create );
bool const ok5 = PFactory::Instance().Register( "One", createProductParm );
bool const ok6 = PFactory::Instance().Register( "Two", (Product*(*)(int,int))createProductOver );
bool const ok6 = PFactory::Instance().Register( "Two", static_cast<Product*(*)(int,int)>(createProductOver) );
bool const ok7 = PFactory::Instance().Register( "Three", c, &AbstractCreator::createParm );
bool const ok8 = PFactory::Instance().Register( "Four", &cT, &CreatorT<Product>::createParm );
@ -303,6 +303,10 @@ int main()
// $Log$
// Revision 1.14 2006/01/19 23:11:56 lfittl
// - Disabled -Weffc++ flag, fixing these warnings produces too much useless code
// - Enabled -pedantic, -Wold-style-cast and -Wundef for src/ and test/
//
// Revision 1.13 2006/01/09 07:27:01 syntheticpp
// replace tabs
//

View file

@ -1,5 +1,5 @@
BIN = Factory
CXXFLAGS = -Wall -O2
CXXFLAGS = -Wall -Wold-style-cast -Wundef -pedantic -O2
CPPFLAGS = -I../../include -DNDEBUG
LDFLAGS = -L../../lib
LDLIBS = -lloki

View file

@ -1,5 +1,5 @@
BIN = FunctionTest
CXXFLAGS = -Wall -O2
CXXFLAGS = -Wall -Wold-style-cast -Wundef -pedantic -O2
CPPFLAGS = -I../../include -DNDEBUG
LDFLAGS = -L../../lib
LDLIBS = -lloki -lboost_test_exec_monitor

View file

@ -1,6 +1,6 @@
BIN1 = main
BIN2 = main2
CXXFLAGS = -Wall -fexpensive-optimizations -O3
CXXFLAGS = -Wall -Wold-style-cast -Wundef -pedantic -fexpensive-optimizations -O3
CPPFLAGS = -I../../include -DNDEBUG
LDFLAGS = -L../../lib
LDLIBS = -lloki

View file

@ -1,5 +1,5 @@
BIN = main
CXXFLAGS = -Wall -O2
CXXFLAGS = -Wall -Wold-style-cast -Wundef -pedantic -O2
CPPFLAGS = -I../../include -DNDEBUG
LDFLAGS = -L../../lib
LDLIBS = -lloki

View file

@ -1,6 +1,5 @@
BIN = main
CC = gcc
CXXFLAGS = -Wall -O2 -pedantic
CXXFLAGS = -Wall -Wold-style-cast -Wundef -pedantic -O2
CPPFLAGS = -I../../include -DNDEBUG
LDFLAGS = -L../../lib
LDLIBS = -lloki

View file

@ -358,7 +358,7 @@ void test_vect5()
void test_vect6()
{
srand( (unsigned int) time(NULL) );
srand( static_cast<unsigned int>(time(NULL)) );
typedef Loki::AssocVector<int, int> IntMap;
const unsigned int numTests = 20;

View file

@ -57,9 +57,9 @@ namespace FactoryTestPrivate
{
FactoryType factory;
factory.Register(1, (Shape * (*)()) createPolygon);
factory.Register(2, (Shape * (*)()) createCircle);
factory.Register(3, (Shape * (*)()) createLine);
factory.Register(1, reinterpret_cast<Shape* (*)()>(createPolygon));
factory.Register(2, reinterpret_cast<Shape* (*)()>(createCircle));
factory.Register(3, reinterpret_cast<Shape* (*)()>(createLine));
Shape *s;
@ -96,9 +96,9 @@ namespace FactoryTestPrivate
{
CloneFactoryType factory;
factory.Register(Loki::TypeInfo(typeid(Polygon)), (Shape * (*)(const Shape *)) clonePolygon);
factory.Register(Loki::TypeInfo(typeid(Circle)), (Shape * (*)(const Shape *)) cloneCircle);
factory.Register(Loki::TypeInfo(typeid(Line)), (Shape * (*)(const Shape *)) cloneLine);
factory.Register(Loki::TypeInfo(typeid(Polygon)), reinterpret_cast<Shape* (*)(const Shape*)>(clonePolygon));
factory.Register(Loki::TypeInfo(typeid(Circle)), reinterpret_cast<Shape* (*)(const Shape*)>(cloneCircle));
factory.Register(Loki::TypeInfo(typeid(Line)), reinterpret_cast<Shape* (*)(const Shape*)>(cloneLine));
Polygon p;
Circle c;

View file

@ -1,5 +1,5 @@
BIN = Test
CXXFLAGS = -Wall -O2
CXXFLAGS = -Wall -Wold-style-cast -Wundef -pedantic -O2
CPPFLAGS = -I../../include -DNDEBUG
LDFLAGS = -L../../lib
LDLIBS = -lloki

View file

@ -54,7 +54,7 @@ public:
testAssert("TypeAt",r,result);
#if !(_MSC_VER && !__INTEL_COMPILER && !__MWERKS__ && _MSC_VER < 1300)
#if !(defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) && _MSC_VER < 1300)
// TypeAtNonStrict works like TypeAt on MSVC 6.0
@ -79,7 +79,7 @@ public:
testAssert("IndexOf",r,result);
#if !(_MSC_VER && !__INTEL_COMPILER && !__MWERKS__ && _MSC_VER < 1300)
#if !(defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) && _MSC_VER < 1300)
// Append, Erase, EraseAll, NoDuplicates, Replace, ReplaceAll, Reverse,
// MostDerived and DerivedToFront doesn't work on MSVC 6.0

View file

@ -65,7 +65,7 @@ public:
testAssert("TypeAt",r,result);
#if !(_MSC_VER && !__INTEL_COMPILER && !__MWERKS__ && _MSC_VER < 1300)
#if !(defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) && _MSC_VER < 1300)
// TypeAtNonStrict works like TypeAt on MSVC 6.0
@ -90,7 +90,7 @@ public:
testAssert("IndexOf",r,result);
#if !(_MSC_VER && !__INTEL_COMPILER && !__MWERKS__ && _MSC_VER < 1300)
#if !(defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) && _MSC_VER < 1300)
// Append, Erase, EraseAll, NoDuplicates, Replace, ReplaceAll, Reverse,
// MostDerived and DerivedToFront doesn't work on MSVC 6.0

View file

@ -1,5 +1,5 @@
BIN = main
CXXFLAGS = -Wall -fexpensive-optimizations -O3
CXXFLAGS = -Wall -Wold-style-cast -Wundef -pedantic -fexpensive-optimizations -O3
CPPFLAGS = -I../../include -DNDEBUG
LDFLAGS = -L../../lib
LDLIBS = -lloki
@ -7,4 +7,4 @@ LDLIBS = -lloki
.PHONY: build clean
build: $(BIN)
clean:
rm -f $(BIN) $(BIN).exe $(BIN).o
rm -f $(BIN) $(BIN).exe $(BIN).o

View file

@ -1,5 +1,5 @@
BIN = main
CXXFLAGS = -Wall -O2
CXXFLAGS = -Wall -Wold-style-cast -Wundef -pedantic -O2
CPPFLAGS = -I../../include -DNDEBUG
LDFLAGS = -L../../lib
LDLIBS = -lloki

View file

@ -408,13 +408,13 @@ int main()
void* p;
p = (void*) &Singleton_with_MySmallObject_DieAs::Instance();
p = (void*) &Singleton_MyFunctionObject_DieAs::Instance();
p = static_cast<void*>(&Singleton_with_MySmallObject_DieAs::Instance());
p = static_cast<void*>(&Singleton_MyFunctionObject_DieAs::Instance());
std::cout<<"\n";
p = (void*) &Follower1_Singleton_B1_die_first::Instance();
p = (void*) &Follower1_Singleton_B1_die_last::Instance();
p = static_cast<void*>(&Follower1_Singleton_B1_die_first::Instance());
p = static_cast<void*>(&Follower1_Singleton_B1_die_last::Instance());
// test of FollowIntoDeath policy, not supported by msvc 7.1 compiler
@ -422,9 +422,9 @@ int main()
std::cout << "\nMaster1:\n\n";
p = (void*) &Follower1_Singleton_DefaultLifetime::Instance();
p = (void*) &Follower1_Singleton_PhoenixSingleton::Instance();
p = (void*) &Follower1_Singleton_DeletableSingleton::Instance();
p = static_cast<void*>(&Follower1_Singleton_DefaultLifetime::Instance());
p = static_cast<void*>(&Follower1_Singleton_PhoenixSingleton::Instance());
p = static_cast<void*>(&Follower1_Singleton_DeletableSingleton::Instance());
std::cout << "\n\nMaster2:\n\n";
@ -441,7 +441,7 @@ int main()
// memory leak when code is enabled
//#define ENABLE_MEMORY_LEAK
#ifdef ENABLE_MEMORY_LEAK
p = (void*) &Follower1_Singleton_NoDestroy::Instance();
p = static_cast<void*>(&Follower1_Singleton_NoDestroy::Instance());
B2_NoDestroy *no2 = &Follower2_Singleton_NoDestroy::Instance();
no2->data = &Master2_NoDestroy::Singleton::Instance();
#endif

View file

@ -1,7 +1,7 @@
BIN1 = DeletableSingleton
BIN2 = Dependencies
BIN3 = Phoenix
CXXFLAGS = -Wall -O2
CXXFLAGS = -Wall -Wold-style-cast -Wundef -pedantic -O2
CPPFLAGS = -I../../include -DNDEBUG
LDFLAGS = -L../../lib
LDLIBS = -lloki

View file

@ -1,6 +1,6 @@
BIN1 = SmallObjBench
BIN2 = SmallObjSingleton
CXXFLAGS = -Wall -fexpensive-optimizations -O3
CXXFLAGS = -Wall -Wold-style-cast -Wundef -pedantic -fexpensive-optimizations -O3
CPPFLAGS = -I../../include -DNDEBUG
LDFLAGS = -L../../lib
LDLIBS = -lloki

View file

@ -195,11 +195,11 @@ int FUNC(void** arrv, const int N, int loop, Timer& t, const char* s) \
LOKI_SMALLOBJ_BENCH(delete_new ,delete new T;)
LOKI_SMALLOBJ_BENCH(delete_new_mal ,std::free(std::malloc(sizeof(T))););
LOKI_SMALLOBJ_BENCH(delete_new_mal ,std::free(std::malloc(sizeof(T)));)
LOKI_SMALLOBJ_BENCH(delete_new_all ,std::allocator<T> st;st.deallocate(st.allocate(1), 1);)
LOKI_SMALLOBJ_BENCH(delete_new_array ,delete[] new T[N];)
LOKI_SMALLOBJ_BENCH(delete_new_array_mal,std::free(std::malloc(sizeof(T[TN]))););
LOKI_SMALLOBJ_BENCH(delete_new_array_mal,std::free(std::malloc(sizeof(T[TN])));)
LOKI_SMALLOBJ_BENCH(delete_new_array_all,std::allocator<T[TN]> st;st.deallocate(st.allocate(1), 1);)
LOKI_SMALLOBJ_BENCH_ARRAY(new_del_on_arr , , arr[i] = new T; ,
@ -324,6 +324,10 @@ int main()
// ----------------------------------------------------------------------------
// $Log$
// Revision 1.19 2006/01/19 23:11:57 lfittl
// - Disabled -Weffc++ flag, fixing these warnings produces too much useless code
// - Enabled -pedantic, -Wold-style-cast and -Wundef for src/ and test/
//
// Revision 1.18 2006/01/05 09:55:09 syntheticpp
// assert, include path, and virtual ~ patches by Lukas Fittl
//

View file

@ -52,7 +52,7 @@ public:
int rel(int t)
{
return ( t100==0 ? 100 : (int) floor(100.0*t/t100+0.5) );
return ( t100==0 ? 100 : static_cast<int>(floor(100.0*t/t100+0.5)) );
}
double speedup(int t)
@ -75,6 +75,10 @@ private:
#endif
// $Log$
// Revision 1.6 2006/01/19 23:11:57 lfittl
// - Disabled -Weffc++ flag, fixing these warnings produces too much useless code
// - Enabled -pedantic, -Wold-style-cast and -Wundef for src/ and test/
//
// Revision 1.5 2005/10/30 14:03:23 syntheticpp
// replace tabs space
//

View file

@ -1,5 +1,5 @@
BIN = main
CXXFLAGS = -Wall -O2
CXXFLAGS = -Wall -Wold-style-cast -Wundef -pedantic -O2
CPPFLAGS = -I../../include -DNDEBUG
LDFLAGS = -L../../lib
LDLIBS = -lloki