Fixed #8677 (False positive: unused method)

This commit is contained in:
Daniel Marjamäki 2018-08-08 11:31:25 +02:00
parent ddf7b186bb
commit 1f1c44a04f
2 changed files with 15 additions and 1 deletions

View File

@ -206,7 +206,7 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer, const char Fi
while (Token::Match(funcname, "%name% :: %name%"))
funcname = funcname->tokAt(2);
if (!Token::Match(funcname, "%name% [(),;]:}]"))
if (!Token::Match(funcname, "%name% [(),;]:}>]"))
continue;
}

View File

@ -40,6 +40,7 @@ private:
TEST_CASE(return1);
TEST_CASE(return2);
TEST_CASE(callback1);
TEST_CASE(callback2);
TEST_CASE(else1);
TEST_CASE(functionpointer);
TEST_CASE(template1);
@ -119,6 +120,19 @@ private:
ASSERT_EQUALS("", errout.str());
}
void callback2() { // #8677
check("class C {\n"
"public:\n"
" void callback();\n"
" void start();\n"
"};\n"
"\n"
"void C::callback() {}\n" // <- not unused
"\n"
"void C::start() { ev.set<C, &C::callback>(this); }");
ASSERT_EQUALS("[test.cpp:9]: (style) The function 'start' is never used.\n", errout.str());
}
void else1() {
check("void f1()\n"
"{\n"