Fix all compiler warnings and enable -Werror (#955)
This removes all compilation warnings on: * g++ 4.7.4, 4.8.5, 4.9.4, 5.4.1, 6.3.0, 7.0.1-svn246759 * clang++ 3.9.1, 4.0.0, 5.0.0-svn303007master
parent
5055c5de11
commit
11d950221b
|
@ -132,7 +132,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||||
|
|
||||||
message(STATUS "Detected GCC version 4.7+")
|
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(RELEASE_CXX_FLAGS "-O2")
|
||||||
set(DEBUG_CXX_FLAGS "-g -O0")
|
set(DEBUG_CXX_FLAGS "-g -O0")
|
||||||
set(TEST_CXX_FLAGS "-pthread")
|
set(TEST_CXX_FLAGS "-pthread")
|
||||||
|
@ -144,7 +144,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
|
||||||
message(STATUS "Detected Clang version 3.1+")
|
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(RELEASE_CXX_FLAGS "-O2")
|
||||||
set(DEBUG_CXX_FLAGS "-g -O0")
|
set(DEBUG_CXX_FLAGS "-g -O0")
|
||||||
set(TEST_CXX_FLAGS "-pthread")
|
set(TEST_CXX_FLAGS "-pthread")
|
||||||
|
|
|
@ -93,8 +93,6 @@ void CBotClass::ClearPublic()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CBotClass::Purge()
|
void CBotClass::Purge()
|
||||||
{
|
{
|
||||||
assert ( this != nullptr );
|
|
||||||
|
|
||||||
delete m_pVar;
|
delete m_pVar;
|
||||||
m_pVar = nullptr;
|
m_pVar = nullptr;
|
||||||
m_externalMethods->Clear();
|
m_externalMethods->Clear();
|
||||||
|
@ -202,7 +200,6 @@ std::string CBotClass::GetName()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
CBotClass* CBotClass::GetParent()
|
CBotClass* CBotClass::GetParent()
|
||||||
{
|
{
|
||||||
assert ( this != nullptr );
|
|
||||||
return m_parent;
|
return m_parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -132,7 +132,6 @@ CBotDefParam* CBotDefParam::Compile(CBotToken* &p, CBotCStack* pStack)
|
||||||
bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
|
bool CBotDefParam::Execute(CBotVar** ppVars, CBotStack* &pj)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
assert(this != nullptr);
|
|
||||||
CBotDefParam* p = this;
|
CBotDefParam* p = this;
|
||||||
|
|
||||||
bool useDefault = false;
|
bool useDefault = false;
|
||||||
|
|
|
@ -80,6 +80,8 @@ public:
|
||||||
*/
|
*/
|
||||||
bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep);
|
bool ExecuteVar(CBotVar* &pVar, CBotStack* &pile, CBotToken* prevToken, bool bStep);
|
||||||
|
|
||||||
|
using CBotInstr::ExecuteVar;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief RestoreStateVar Fetch variable at runtime.
|
* \brief RestoreStateVar Fetch variable at runtime.
|
||||||
* \param pj
|
* \param pj
|
||||||
|
|
|
@ -86,6 +86,8 @@ public:
|
||||||
CBotStack* &pj,
|
CBotStack* &pj,
|
||||||
CBotVar* pInstance = nullptr);
|
CBotVar* pInstance = nullptr);
|
||||||
|
|
||||||
|
using CBotInstr::Execute;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief RestoreState
|
* \brief RestoreState
|
||||||
* \param ppVars
|
* \param ppVars
|
||||||
|
@ -96,6 +98,8 @@ public:
|
||||||
CBotStack* &pj,
|
CBotStack* &pj,
|
||||||
CBotVar* pInstance = nullptr);
|
CBotVar* pInstance = nullptr);
|
||||||
|
|
||||||
|
using CBotInstr::RestoreState;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Compile a function call
|
* \brief Compile a function call
|
||||||
*
|
*
|
||||||
|
|
|
@ -361,7 +361,6 @@ CBotInstr* CBotInstr::CompileArray(CBotToken* &p, CBotCStack* pStack, CBotTypRes
|
||||||
|
|
||||||
bool CBotInstr::HasReturn()
|
bool CBotInstr::HasReturn()
|
||||||
{
|
{
|
||||||
assert(this != nullptr);
|
|
||||||
if (m_next != nullptr) return m_next->HasReturn();
|
if (m_next != nullptr) return m_next->HasReturn();
|
||||||
return false; // end of the list
|
return false; // end of the list
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,8 @@ public:
|
||||||
*/
|
*/
|
||||||
bool Execute(CBotStack* &pStack, CBotStack* array);
|
bool Execute(CBotStack* &pStack, CBotStack* array);
|
||||||
|
|
||||||
|
using CBotInstr::Execute;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief ExecuteVar Fetch a variable during compilation.
|
* \brief ExecuteVar Fetch a variable during compilation.
|
||||||
* \param pVar
|
* \param pVar
|
||||||
|
@ -69,6 +71,8 @@ public:
|
||||||
*/
|
*/
|
||||||
bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) override;
|
bool ExecuteVar(CBotVar* &pVar, CBotCStack* &pile) override;
|
||||||
|
|
||||||
|
using CBotInstr::ExecuteVar;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief ExecuteVar Fetch the variable at runtume.
|
* \brief ExecuteVar Fetch the variable at runtume.
|
||||||
* \param pVar
|
* \param pVar
|
||||||
|
|
|
@ -302,7 +302,7 @@ CBotTypResult cSizeOf( CBotVar* &pVar, void* pUser )
|
||||||
|
|
||||||
bool rSizeOf( CBotVar* pVar, CBotVar* pResult, int& ex, 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;
|
int i = 0;
|
||||||
pVar = pVar->GetItemList();
|
pVar = pVar->GetItemList();
|
||||||
|
|
|
@ -82,8 +82,6 @@ CBotStack* CBotStack::AllocateStack()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void CBotStack::Delete()
|
void CBotStack::Delete()
|
||||||
{
|
{
|
||||||
assert ( this != nullptr );
|
|
||||||
|
|
||||||
if (m_next != nullptr) m_next->Delete();
|
if (m_next != nullptr) m_next->Delete();
|
||||||
if (m_next2 != nullptr) m_next2->Delete();
|
if (m_next2 != nullptr) m_next2->Delete();
|
||||||
|
|
||||||
|
@ -270,7 +268,7 @@ bool CBotStack::IfStep()
|
||||||
bool CBotStack::BreakReturn(CBotStack* pfils, const std::string& name)
|
bool CBotStack::BreakReturn(CBotStack* pfils, const std::string& name)
|
||||||
{
|
{
|
||||||
if ( m_error>=0 ) return false; // normal output
|
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))
|
if (!m_labelBreak.empty() && (name.empty() || m_labelBreak != name))
|
||||||
return false; // it's not for me
|
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)
|
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))
|
if (!m_labelBreak.empty() && (name.empty() || m_labelBreak != name))
|
||||||
return false; // it's not for me
|
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)
|
bool CBotStack::GetRetVar(bool bRet)
|
||||||
{
|
{
|
||||||
if (m_error == -3)
|
if (m_error == CBotError(-3))
|
||||||
{
|
{
|
||||||
if ( m_var ) delete m_var;
|
if ( m_var ) delete m_var;
|
||||||
m_var = m_retvar;
|
m_var = m_retvar;
|
||||||
|
|
|
@ -199,7 +199,6 @@ const CBotToken& CBotToken::operator=(const CBotToken& src)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CBotToken::GetType()
|
int CBotToken::GetType()
|
||||||
{
|
{
|
||||||
assert(this != nullptr);
|
|
||||||
if (m_type == TokenTypKeyWord) return m_keywordId;
|
if (m_type == TokenTypKeyWord) return m_keywordId;
|
||||||
return m_type;
|
return m_type;
|
||||||
}
|
}
|
||||||
|
@ -225,14 +224,12 @@ void CBotToken::SetString(const std::string& name)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CBotToken::GetStart()
|
int CBotToken::GetStart()
|
||||||
{
|
{
|
||||||
assert(this != nullptr);
|
|
||||||
return m_start;
|
return m_start;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CBotToken::GetEnd()
|
int CBotToken::GetEnd()
|
||||||
{
|
{
|
||||||
assert(this != nullptr);
|
|
||||||
return m_end;
|
return m_end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,12 +48,12 @@ public:
|
||||||
SetValString(ToString(val));
|
SetValString(ToString(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetValInt()
|
int GetValInt() override
|
||||||
{
|
{
|
||||||
return FromString<int>(GetValString());
|
return FromString<int>(GetValString());
|
||||||
}
|
}
|
||||||
|
|
||||||
float GetValFloat()
|
float GetValFloat() override
|
||||||
{
|
{
|
||||||
return FromString<float>(GetValString());
|
return FromString<float>(GetValString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,8 +225,14 @@ bool rStrFind( CBotVar* pVar, CBotVar* pResult, int& ex, void* pUser )
|
||||||
|
|
||||||
// puts the result on the stack
|
// puts the result on the stack
|
||||||
std::size_t res = s.find(s2);
|
std::size_t res = s.find(s2);
|
||||||
pResult->SetValInt( res != std::string::npos ? res : -1 );
|
if (res != std::string::npos)
|
||||||
if ( res < 0 ) pResult->SetInit( CBotVar::InitType::IS_NAN );
|
{
|
||||||
|
pResult->SetValInt(res);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pResult->SetInit(CBotVar::InitType::IS_NAN);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -404,3 +404,5 @@ protected:
|
||||||
//! Static buffer for putenv locale
|
//! Static buffer for putenv locale
|
||||||
static char m_languageLocale[50];
|
static char m_languageLocale[50];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<> CApplication* CSingleton<CApplication>::m_instance;
|
||||||
|
|
|
@ -161,3 +161,5 @@ private:
|
||||||
|
|
||||||
std::map<InputSlot, std::string> m_keyTable;
|
std::map<InputSlot, std::string> m_keyTable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<> CInput* CSingleton<CInput>::m_instance;
|
||||||
|
|
|
@ -67,3 +67,5 @@ private:
|
||||||
//! Save path
|
//! Save path
|
||||||
std::string m_savePath;
|
std::string m_savePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<> CPathManager* CSingleton<CPathManager>::m_instance;
|
||||||
|
|
|
@ -46,7 +46,7 @@ void CSignalHandlers::Init(CSystemUtils* systemUtils)
|
||||||
|
|
||||||
void CSignalHandlers::SignalHandler(int sig)
|
void CSignalHandlers::SignalHandler(int sig)
|
||||||
{
|
{
|
||||||
std::string signalStr = StrUtils::ToString(signal);
|
std::string signalStr = StrUtils::ToString(sig);
|
||||||
switch(sig)
|
switch(sig)
|
||||||
{
|
{
|
||||||
case SIGSEGV: signalStr = "SIGSEGV, segmentation fault"; break;
|
case SIGSEGV: signalStr = "SIGSEGV, segmentation fault"; break;
|
||||||
|
|
|
@ -112,3 +112,5 @@ inline CConfigFile & GetConfigFile()
|
||||||
{
|
{
|
||||||
return CConfigFile::GetInstance();
|
return CConfigFile::GetInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> CConfigFile* CSingleton<CConfigFile>::m_instance;
|
||||||
|
|
|
@ -136,3 +136,5 @@ inline CLogger* GetLogger()
|
||||||
{
|
{
|
||||||
return CLogger::GetInstancePointer();
|
return CLogger::GetInstancePointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<> CLogger* CSingleton<CLogger>::m_instance;
|
||||||
|
|
|
@ -105,3 +105,5 @@ protected:
|
||||||
|
|
||||||
Language m_language;
|
Language m_language;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<> CSettings* CSingleton<CSettings>::m_instance;
|
||||||
|
|
|
@ -1490,3 +1490,5 @@ protected:
|
||||||
|
|
||||||
|
|
||||||
} // namespace Gfx
|
} // namespace Gfx
|
||||||
|
|
||||||
|
template<> Gfx::CEngine* CSingleton<Gfx::CEngine>::m_instance;
|
||||||
|
|
|
@ -715,3 +715,5 @@ protected:
|
||||||
//! Index of currently selected element in command history
|
//! Index of currently selected element in command history
|
||||||
int m_commandHistoryIndex;
|
int m_commandHistoryIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<> CRobotMain* CSingleton<CRobotMain>::m_instance;
|
||||||
|
|
|
@ -311,3 +311,5 @@ private:
|
||||||
int m_activeObjectIterators;
|
int m_activeObjectIterators;
|
||||||
bool m_shouldCleanRemovedObjects;
|
bool m_shouldCleanRemovedObjects;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<> CObjectManager* CSingleton<CObjectManager>::m_instance;
|
||||||
|
|
|
@ -413,7 +413,7 @@ bool CScriptFunctions::rDestroy(CBotVar* thisclass, CBotVar* var, CBotVar* resul
|
||||||
else
|
else
|
||||||
err = ERR_WRONG_OBJ;
|
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 ( err != ERR_OK )
|
||||||
{
|
{
|
||||||
if ( script->m_errMode == ERM_STOP )
|
if ( script->m_errMode == ERM_STOP )
|
||||||
|
@ -506,7 +506,7 @@ bool CScriptFunctions::rFactory(CBotVar* thisclass, CBotVar* var, CBotVar* resul
|
||||||
else
|
else
|
||||||
err = ERR_WRONG_OBJ;
|
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 ( err != ERR_OK )
|
||||||
{
|
{
|
||||||
if ( script->m_errMode == ERM_STOP )
|
if ( script->m_errMode == ERM_STOP )
|
||||||
|
@ -581,7 +581,7 @@ bool CScriptFunctions::rResearch(CBotVar* thisclass, CBotVar* var, CBotVar* resu
|
||||||
else
|
else
|
||||||
err = ERR_WRONG_OBJ;
|
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 ( err != ERR_OK )
|
||||||
{
|
{
|
||||||
if( script->m_errMode == ERM_STOP )
|
if( script->m_errMode == ERM_STOP )
|
||||||
|
@ -621,7 +621,7 @@ bool CScriptFunctions::rTakeOff(CBotVar* thisclass, CBotVar* var, CBotVar* resul
|
||||||
else
|
else
|
||||||
err = ERR_WRONG_OBJ;
|
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 ( err != ERR_OK )
|
||||||
{
|
{
|
||||||
if ( script->m_errMode == ERM_STOP )
|
if ( script->m_errMode == ERM_STOP )
|
||||||
|
|
Loading…
Reference in New Issue