Fixed ticket #373 (False unused functions)
Skip template functions when checking for unused functions
This commit is contained in:
parent
084b3c002f
commit
2307395d6e
|
@ -55,6 +55,10 @@ void CheckUnusedFunctions::parseTokens(const Tokenizer &tokenizer)
|
|||
if (tok->str().find(":") != std::string::npos)
|
||||
continue;
|
||||
|
||||
// If this is a template function, skip it
|
||||
if (Token::simpleMatch(tok->previous(), ">"))
|
||||
continue;
|
||||
|
||||
const Token *funcname = 0;
|
||||
|
||||
if (Token::Match(tok, "%type% %var% ("))
|
||||
|
|
|
@ -41,6 +41,7 @@ private:
|
|||
TEST_CASE(callback1);
|
||||
TEST_CASE(else1);
|
||||
TEST_CASE(functionpointer);
|
||||
TEST_CASE(template1);
|
||||
}
|
||||
|
||||
void check(const char code[])
|
||||
|
@ -119,6 +120,18 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void template1()
|
||||
{
|
||||
check("template<class T> void foo() { }\n"
|
||||
"\n"
|
||||
"int main()\n"
|
||||
"{\n"
|
||||
" foo<int>();\n"
|
||||
" return 0\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestUnusedFunctions)
|
||||
|
|
Loading…
Reference in New Issue