Fixed #4000, added support for function prototypes to TemplateSimplifier::templateParameters()

This commit is contained in:
PKEuS 2012-08-12 05:19:56 -07:00
parent a15e307df0
commit 2ac2674f67
2 changed files with 9 additions and 3 deletions

View File

@ -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() == "<") {

View File

@ -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<void(void)> fptr;"));
}
void varidclass1() {
const std::string actual = tokenizeDebugListing(
"class Fred\n"