diff --git a/src/checkunusedfunctions.cpp b/src/checkunusedfunctions.cpp index eea3e6a80..9bd9265bb 100644 --- a/src/checkunusedfunctions.cpp +++ b/src/checkunusedfunctions.cpp @@ -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% (")) diff --git a/test/testunusedfunctions.cpp b/test/testunusedfunctions.cpp index fdd5a23f8..8d727085a 100644 --- a/test/testunusedfunctions.cpp +++ b/test/testunusedfunctions.cpp @@ -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 void foo() { }\n" + "\n" + "int main()\n" + "{\n" + " foo();\n" + " return 0\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } }; REGISTER_TEST(TestUnusedFunctions)