diff --git a/CMakeLists.txt b/CMakeLists.txt index bc287243..8f2ca843 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -132,7 +132,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") message(STATUS "Detected GCC version 4.7+") - set(NORMAL_CXX_FLAGS "-std=gnu++11 -Wall -Wold-style-cast -pedantic-errors") + set(NORMAL_CXX_FLAGS "-std=gnu++11 -Wall -Werror -Wold-style-cast -pedantic-errors") set(RELEASE_CXX_FLAGS "-O2") set(DEBUG_CXX_FLAGS "-g -O0") set(TEST_CXX_FLAGS "-pthread") @@ -144,7 +144,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") message(STATUS "Detected Clang version 3.1+") - set(NORMAL_CXX_FLAGS "-std=c++11 -Wall -Wold-style-cast -pedantic-errors") + set(NORMAL_CXX_FLAGS "-std=c++11 -Wall -Werror -Wold-style-cast -pedantic-errors") set(RELEASE_CXX_FLAGS "-O2") set(DEBUG_CXX_FLAGS "-g -O0") set(TEST_CXX_FLAGS "-pthread") diff --git a/src/CBot/CBotClass.cpp b/src/CBot/CBotClass.cpp index d787eb73..ef220943 100644 --- a/src/CBot/CBotClass.cpp +++ b/src/CBot/CBotClass.cpp @@ -93,8 +93,6 @@ void CBotClass::ClearPublic() //////////////////////////////////////////////////////////////////////////////// void CBotClass::Purge() { - assert ( this != nullptr ); - delete m_pVar; m_pVar = nullptr; m_externalMethods->Clear(); @@ -202,7 +200,6 @@ std::string CBotClass::GetName() //////////////////////////////////////////////////////////////////////////////// CBotClass* CBotClass::GetParent() { - assert ( this != nullptr ); return m_parent; } diff --git a/src/CBot/CBotDefParam.cpp b/src/CBot/CBotDefParam.cpp index b3a11a60..074f025d 100644 --- a/src/CBot/CBotDefParam.cpp +++ b/src/CBot/CBotDefParam.cpp @@ -132,7 +132,6 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack) bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj) { int i = 0; - assert(this != nullptr); CBotDefParam* p = this; bool useDefault = false; diff --git a/src/CBot/CBotInstr/CBotExprVar.h b/src/CBot/CBotInstr/CBotExprVar.h index 2f2e69ab..d9b857cb 100644 --- a/src/CBot/CBotInstr/CBotExprVar.h +++ b/src/CBot/CBotInstr/CBotExprVar.h @@ -80,6 +80,8 @@ public: */ bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep); + using CBotInstr::ExecuteVar; + /*! * \brief RestoreStateVar Fetch variable at runtime. * \param pj diff --git a/src/CBot/CBotInstr/CBotFunction.h b/src/CBot/CBotInstr/CBotFunction.h index a23e2fd5..1f25474f 100644 --- a/src/CBot/CBotInstr/CBotFunction.h +++ b/src/CBot/CBotInstr/CBotFunction.h @@ -86,6 +86,8 @@ public: CBotStack* &pj, CBotVar* pInstance = nullptr); + using CBotInstr::Execute; + /*! * \brief RestoreState * \param ppVars @@ -96,6 +98,8 @@ public: CBotStack* &pj, CBotVar* pInstance = nullptr); + using CBotInstr::RestoreState; + /*! * \brief Compile a function call * diff --git a/src/CBot/CBotInstr/CBotInstr.cpp b/src/CBot/CBotInstr/CBotInstr.cpp index 1d30f673..69bb9025 100644 --- a/src/CBot/CBotInstr/CBotInstr.cpp +++ b/src/CBot/CBotInstr/CBotInstr.cpp @@ -361,7 +361,6 @@ CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypRes bool CBotInstr::HasReturn() { - assert(this != nullptr); if (m_next != nullptr) return m_next->HasReturn(); return false; // end of the list } diff --git a/src/CBot/CBotInstr/CBotLeftExpr.h b/src/CBot/CBotInstr/CBotLeftExpr.h index 7acea068..4cffe46e 100644 --- a/src/CBot/CBotInstr/CBotLeftExpr.h +++ b/src/CBot/CBotInstr/CBotLeftExpr.h @@ -61,6 +61,8 @@ public: */ bool Execute(CBotStack* &pStack, CBotStack* array); + using CBotInstr::Execute; + /*! * \brief ExecuteVar Fetch a variable during compilation. * \param pVar @@ -69,6 +71,8 @@ public: */ bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) override; + using CBotInstr::ExecuteVar; + /*! * \brief ExecuteVar Fetch the variable at runtume. * \param pVar diff --git a/src/CBot/CBotProgram.cpp b/src/CBot/CBotProgram.cpp index 32813de1..a3a216a2 100644 --- a/src/CBot/CBotProgram.cpp +++ b/src/CBot/CBotProgram.cpp @@ -302,7 +302,7 @@ CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser ) bool rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) { - if ( pVar == nullptr ) return CBotErrLowParam; + if ( pVar == nullptr ) { ex = CBotErrLowParam; return true; } int i = 0; pVar = pVar->GetItemList(); diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp index 70ec5631..57aa4290 100644 --- a/src/CBot/CBotStack.cpp +++ b/src/CBot/CBotStack.cpp @@ -82,8 +82,6 @@ CBotStack* CBotStack::AllocateStack() //////////////////////////////////////////////////////////////////////////////// void CBotStack::Delete() { - assert ( this != nullptr ); - if (m_next != nullptr) m_next->Delete(); if (m_next2 != nullptr) m_next2->Delete(); @@ -270,7 +268,7 @@ bool CBotStack::IfStep() bool CBotStack::BreakReturn(CBotStack* pfils, const std::string& name) { if ( m_error>=0 ) return false; // normal output - if ( m_error==-3 ) return false; // normal output (return current) + if ( m_error==CBotError(-3) ) return false; // normal output (return current) if (!m_labelBreak.empty() && (name.empty() || m_labelBreak != name)) return false; // it's not for me @@ -283,7 +281,7 @@ bool CBotStack::BreakReturn(CBotStack* pfils, const std::string& name) //////////////////////////////////////////////////////////////////////////////// bool CBotStack::IfContinue(int state, const std::string& name) { - if ( m_error != -2 ) return false; + if ( m_error != CBotError(-2) ) return false; if (!m_labelBreak.empty() && (name.empty() || m_labelBreak != name)) return false; // it's not for me @@ -311,7 +309,7 @@ void CBotStack::SetBreak(int val, const std::string& name) //////////////////////////////////////////////////////////////////////////////// bool CBotStack::GetRetVar(bool bRet) { - if (m_error == -3) + if (m_error == CBotError(-3)) { if ( m_var ) delete m_var; m_var = m_retvar; diff --git a/src/CBot/CBotToken.cpp b/src/CBot/CBotToken.cpp index e10901eb..d9e33ffd 100644 --- a/src/CBot/CBotToken.cpp +++ b/src/CBot/CBotToken.cpp @@ -199,7 +199,6 @@ const CBotToken& CBotToken::operator=(const CBotToken& src) //////////////////////////////////////////////////////////////////////////////// int CBotToken::GetType() { - assert(this != nullptr); if (m_type == TokenTypKeyWord) return m_keywordId; return m_type; } @@ -225,14 +224,12 @@ void CBotToken::SetString(const std::string& name) //////////////////////////////////////////////////////////////////////////////// int CBotToken::GetStart() { - assert(this != nullptr); return m_start; } //////////////////////////////////////////////////////////////////////////////// int CBotToken::GetEnd() { - assert(this != nullptr); return m_end; } diff --git a/src/CBot/CBotVar/CBotVarString.h b/src/CBot/CBotVar/CBotVarString.h index 162264d2..28d3018d 100644 --- a/src/CBot/CBotVar/CBotVarString.h +++ b/src/CBot/CBotVar/CBotVarString.h @@ -48,12 +48,12 @@ public: SetValString(ToString(val)); } - int GetValInt() + int GetValInt() override { return FromString(GetValString()); } - float GetValFloat() + float GetValFloat() override { return FromString(GetValString()); } diff --git a/src/CBot/stdlib/StringFunctions.cpp b/src/CBot/stdlib/StringFunctions.cpp index c50c39d4..77a359cb 100644 --- a/src/CBot/stdlib/StringFunctions.cpp +++ b/src/CBot/stdlib/StringFunctions.cpp @@ -225,8 +225,14 @@ bool rStrFind( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser ) // puts the result on the stack std::size_t res = s.find(s2); - pResult->SetValInt( res != std::string::npos ? res : -1 ); - if ( res < 0 ) pResult->SetInit( CBotVar::InitType::IS_NAN ); + if (res != std::string::npos) + { + pResult->SetValInt(res); + } + else + { + pResult->SetInit(CBotVar::InitType::IS_NAN); + } return true; } diff --git a/src/app/app.h b/src/app/app.h index b6702907..1b3b3a21 100644 --- a/src/app/app.h +++ b/src/app/app.h @@ -404,3 +404,5 @@ protected: //! Static buffer for putenv locale static char m_languageLocale[50]; }; + +template<> CApplication* CSingleton::m_instance; diff --git a/src/app/input.h b/src/app/input.h index 15cdc98d..2b8617eb 100644 --- a/src/app/input.h +++ b/src/app/input.h @@ -161,3 +161,5 @@ private: std::map m_keyTable; }; + +template<> CInput* CSingleton::m_instance; diff --git a/src/app/pathman.h b/src/app/pathman.h index 059c81fe..87fa4493 100644 --- a/src/app/pathman.h +++ b/src/app/pathman.h @@ -67,3 +67,5 @@ private: //! Save path std::string m_savePath; }; + +template<> CPathManager* CSingleton::m_instance; diff --git a/src/app/signal_handlers.cpp b/src/app/signal_handlers.cpp index 223d7db8..b08a0a22 100644 --- a/src/app/signal_handlers.cpp +++ b/src/app/signal_handlers.cpp @@ -46,7 +46,7 @@ void CSignalHandlers::Init(CSystemUtils* systemUtils) void CSignalHandlers::SignalHandler(int sig) { - std::string signalStr = StrUtils::ToString(signal); + std::string signalStr = StrUtils::ToString(sig); switch(sig) { case SIGSEGV: signalStr = "SIGSEGV, segmentation fault"; break; diff --git a/src/common/config_file.h b/src/common/config_file.h index 0ed8e19f..9acc5aee 100644 --- a/src/common/config_file.h +++ b/src/common/config_file.h @@ -112,3 +112,5 @@ inline CConfigFile & GetConfigFile() { return CConfigFile::GetInstance(); } + +template<> CConfigFile* CSingleton::m_instance; diff --git a/src/common/logger.h b/src/common/logger.h index e0a935d4..e49fbd33 100644 --- a/src/common/logger.h +++ b/src/common/logger.h @@ -136,3 +136,5 @@ inline CLogger* GetLogger() { return CLogger::GetInstancePointer(); } + +template<> CLogger* CSingleton::m_instance; diff --git a/src/common/settings.h b/src/common/settings.h index 4e9b7620..cb236601 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -105,3 +105,5 @@ protected: Language m_language; }; + +template<> CSettings* CSingleton::m_instance; diff --git a/src/graphics/engine/engine.h b/src/graphics/engine/engine.h index 834de1e3..687bbafb 100644 --- a/src/graphics/engine/engine.h +++ b/src/graphics/engine/engine.h @@ -1490,3 +1490,5 @@ protected: } // namespace Gfx + +template<> Gfx::CEngine* CSingleton::m_instance; diff --git a/src/level/robotmain.h b/src/level/robotmain.h index b1e69c97..a683e206 100644 --- a/src/level/robotmain.h +++ b/src/level/robotmain.h @@ -715,3 +715,5 @@ protected: //! Index of currently selected element in command history int m_commandHistoryIndex; }; + +template<> CRobotMain* CSingleton::m_instance; diff --git a/src/object/object_manager.h b/src/object/object_manager.h index 73ae0015..2a02d24e 100644 --- a/src/object/object_manager.h +++ b/src/object/object_manager.h @@ -311,3 +311,5 @@ private: int m_activeObjectIterators; bool m_shouldCleanRemovedObjects; }; + +template<> CObjectManager* CSingleton::m_instance; diff --git a/src/script/scriptfunc.cpp b/src/script/scriptfunc.cpp index ee9bc305..6a264b02 100644 --- a/src/script/scriptfunc.cpp +++ b/src/script/scriptfunc.cpp @@ -413,7 +413,7 @@ bool CScriptFunctions::rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* resul else err = ERR_WRONG_OBJ; - result->SetValInt(err); // indicates the error or ok + result->SetValInt(err); // indicates the error or ok if ( err != ERR_OK ) { if ( script->m_errMode == ERM_STOP ) @@ -506,7 +506,7 @@ bool CScriptFunctions::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* resul else err = ERR_WRONG_OBJ; - result->SetValInt(err); // indicates the error or ok + result->SetValInt(err); // indicates the error or ok if ( err != ERR_OK ) { if ( script->m_errMode == ERM_STOP ) @@ -581,7 +581,7 @@ bool CScriptFunctions::rResearch(CBotVar* thisclass, CBotVar* var, CBotVar* resu else err = ERR_WRONG_OBJ; - result->SetValInt(err); // indicates the error or ok + result->SetValInt(err); // indicates the error or ok if ( err != ERR_OK ) { if( script->m_errMode == ERM_STOP ) @@ -621,7 +621,7 @@ bool CScriptFunctions::rTakeOff(CBotVar* thisclass, CBotVar* var, CBotVar* resul else err = ERR_WRONG_OBJ; - result->SetValInt(err); // indicates the error or ok + result->SetValInt(err); // indicates the error or ok if ( err != ERR_OK ) { if ( script->m_errMode == ERM_STOP )