diff --git a/lib/templatesimplifier.cpp b/lib/templatesimplifier.cpp index d279be177..713b6bc55 100644 --- a/lib/templatesimplifier.cpp +++ b/lib/templatesimplifier.cpp @@ -209,9 +209,9 @@ unsigned int TemplateSimplifier::templateParameters(const Token *tok) while (Token::Match(tok, "*|&|const")) tok = tok->next(); - // Function pointer.. - if (Token::simpleMatch(tok, "( * ) (")) - tok = tok->linkAt(3)->next(); + // Function pointer or prototype.. + while (tok->str() == "(") + tok = tok->link()->next(); // inner template if (tok->str() == "<") { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index fe13a1456..f6394c25b 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -246,6 +246,7 @@ private: TEST_CASE(varid_unknown_macro); // #2638 - unknown macro is not type TEST_CASE(varid_using); // ticket #3648 TEST_CASE(varid_catch); + TEST_CASE(varid_functionPrototypeTemplate); TEST_CASE(varidclass1); TEST_CASE(varidclass2); @@ -3798,6 +3799,11 @@ private: ASSERT_EQUALS(expected, tokenizeDebugListing(code)); } + void varid_functionPrototypeTemplate() { + ASSERT_EQUALS("\n\n##file 0\n" + "1: function < void ( ) > fptr@1 ;\n", tokenizeDebugListing("function fptr;")); + } + void varidclass1() { const std::string actual = tokenizeDebugListing( "class Fred\n"