Added checktype.cpp to VS solution; Fixed MSVC warning about signed/unsigned mismatch

This commit is contained in:
PKEuS 2014-09-11 18:47:28 +02:00
parent dd5f41f01d
commit 87e6a3501a
5 changed files with 17 additions and 5 deletions

View File

@ -30,7 +30,7 @@ namespace {
CheckType instance;
}
static bool astGetSizeSign(const Settings *settings, const Token *tok, int *size, char *sign)
static bool astGetSizeSign(const Settings *settings, const Token *tok, unsigned int *size, char *sign)
{
if (!tok)
return false;
@ -43,7 +43,7 @@ static bool astGetSizeSign(const Settings *settings, const Token *tok, int *size
if (tok->str().find("L") != std::string::npos)
return false;
MathLib::bigint value = MathLib::toLongNumber(tok->str());
int sz;
unsigned int sz;
if (value >= -(1<<7) && value <= (1<<7)-1)
sz = 8;
else if (value >= -(1<<15) && value <= (1<<15)-1)
@ -66,7 +66,7 @@ static bool astGetSizeSign(const Settings *settings, const Token *tok, int *size
const Variable *var = tok->variable();
if (!var)
return false;
int sz = 0;
unsigned int sz = 0;
for (const Token *type = var->typeStartToken(); type; type = type->next()) {
if (type->str() == "*")
return false; // <- FIXME: handle pointers
@ -185,7 +185,7 @@ void CheckType::checkIntegerOverflow()
continue;
// get size and sign of result..
int size = 0;
unsigned int size = 0;
char sign = 0;
if (!astGetSizeSign(_settings, tok, &size, &sign))
continue;
@ -228,7 +228,7 @@ void CheckType::checkSignConversion()
if (!tok->isArithmeticalOp())
continue;
int size = 0;
unsigned int size = 0;
char sign = 0;
if (!astGetSizeSign(_settings, tok, &size, &sign))
continue;

View File

@ -58,6 +58,7 @@
<ClCompile Include="checkpostfixoperator.cpp" />
<ClCompile Include="checksizeof.cpp" />
<ClCompile Include="checkstl.cpp" />
<ClCompile Include="checktype.cpp" />
<ClCompile Include="checkuninitvar.cpp" />
<ClCompile Include="checkunusedfunctions.cpp" />
<ClCompile Include="checkunusedvar.cpp" />
@ -103,6 +104,7 @@
<ClInclude Include="checkpostfixoperator.h" />
<ClInclude Include="checksizeof.h" />
<ClInclude Include="checkstl.h" />
<ClInclude Include="checktype.h" />
<ClInclude Include="checkuninitvar.h" />
<ClInclude Include="checkunusedfunctions.h" />
<ClInclude Include="checkunusedvar.h" />

View File

@ -140,6 +140,9 @@
<ClCompile Include="checkcondition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="checktype.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="checkbufferoverrun.h">
@ -277,6 +280,9 @@
<ClInclude Include="checkcondition.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="checktype.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="version.rc" />

View File

@ -80,6 +80,7 @@
<ClCompile Include="testtimer.cpp" />
<ClCompile Include="testtoken.cpp" />
<ClCompile Include="testtokenize.cpp" />
<ClCompile Include="testtype.cpp" />
<ClCompile Include="testuninitvar.cpp" />
<ClCompile Include="testunusedfunctions.cpp" />
<ClCompile Include="testunusedprivfunc.cpp" />

View File

@ -190,6 +190,9 @@
<ClCompile Include="testcondition.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="testtype.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="options.h">