Fixed #431 (Unused private function, wrong line when two functions with same name)
This commit is contained in:
parent
9d1d7ebf8d
commit
ddc1ad7d4d
|
@ -544,13 +544,13 @@ void CheckClass::privateFunctions()
|
|||
else if (Token::Match(tok2, "%var% ("))
|
||||
{
|
||||
// Remove function from FuncList
|
||||
for (std::list<const Token *>::iterator it = FuncList.begin(); it != FuncList.end(); ++it)
|
||||
std::list<const Token *>::iterator it = FuncList.begin();
|
||||
while (it != FuncList.end())
|
||||
{
|
||||
if (tok2->str() == (*it)->str())
|
||||
{
|
||||
FuncList.remove(*it);
|
||||
break;
|
||||
}
|
||||
FuncList.erase(it++);
|
||||
else
|
||||
it++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ private:
|
|||
TEST_CASE(ctor);
|
||||
|
||||
TEST_CASE(classInClass);
|
||||
TEST_CASE(sameFunctionNames);
|
||||
}
|
||||
|
||||
|
||||
|
@ -254,6 +255,23 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
void sameFunctionNames()
|
||||
{
|
||||
check("class A\n"
|
||||
"{\n"
|
||||
"public:\n"
|
||||
" void a()\n"
|
||||
" {\n"
|
||||
" f(1);\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
"private:\n"
|
||||
" void f() { }\n"
|
||||
" void f(int) { }\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestUnusedPrivateFunction)
|
||||
|
|
Loading…
Reference in New Issue