Fixed #1636 (Fix false positive with strncpy termination check)

This commit is contained in:
Robert Reif 2010-04-30 21:36:48 +02:00 committed by Daniel Marjamäki
parent 5738f34872
commit 1fa1ff8d14
2 changed files with 22 additions and 2 deletions

View File

@ -500,6 +500,15 @@ private:
void Variables::alias(unsigned int varid1, unsigned int varid2)
{
// alias to self
if (varid1 == varid2)
{
VariableUsage *var = find(varid1);
if (var)
var->use();
return;
}
std::set<unsigned int>::iterator i;
VariableUsage *var1 = find(varid1);

View File

@ -74,7 +74,8 @@ private:
TEST_CASE(localvar9); // ticket #1605
TEST_CASE(localvar10);
TEST_CASE(localvar11);
TEST_CASE(localvaralias);
TEST_CASE(localvaralias1);
TEST_CASE(localvaralias2); // ticket #1637
TEST_CASE(localvarasm);
// Don't give false positives for variables in structs/unions
@ -926,7 +927,7 @@ private:
ASSERT_EQUALS("", errout.str());
}
void localvaralias()
void localvaralias1()
{
functionVariableUsage("void foo()\n"
"{\n"
@ -1183,6 +1184,16 @@ private:
"[test.cpp:5]: (style) Variable 's' is assigned a value that is never used\n", errout.str());
}
void localvaralias2() // ticket 1637
{
functionVariableUsage("void foo()\n"
"{\n"
" int * a;\n"
" a = a;\n"
"}\n");
ASSERT_EQUALS(std::string(""), errout.str());
}
void localvarasm()
{
functionVariableUsage("void foo(int &b)\n"