Tokenizer::simplifyTemplates: better handling of '(foo<double>())'. Ticket: #2631

This commit is contained in:
Daniel Marjamäki 2011-03-06 21:15:42 +01:00
parent 6648267ab8
commit f53ff27b71
2 changed files with 18 additions and 1 deletions

View File

@ -2714,7 +2714,7 @@ std::list<Token *> Tokenizer::simplifyTemplatesGetTemplateInstantiations()
if (!tok)
break;
}
else if (Token::Match(tok->previous(), "[{};=] %var% <") ||
else if (Token::Match(tok->previous(), "[({};=] %var% <") ||
Token::Match(tok->tokAt(-2), "[,:] private|protected|public %var% <"))
{
if (templateParameters(tok->next()))

View File

@ -113,6 +113,7 @@ private:
TEST_CASE(template20);
TEST_CASE(template21);
TEST_CASE(template22);
TEST_CASE(template23);
TEST_CASE(template_unhandled);
TEST_CASE(template_default_parameter);
TEST_CASE(template_default_type);
@ -2025,6 +2026,22 @@ private:
ASSERT_EQUALS(expected, sizeof_(code));
}
void template23()
{
const char code[] = "template <classname T> void foo() { }\n"
"void bar() {\n"
" std::cout << (foo<double>());\n"
"}";
const std::string expected("; "
"void bar ( ) {"
" std :: cout << ( foo<double> ( ) ) ; "
"} "
"void foo<double> ( ) { }");
ASSERT_EQUALS(expected, sizeof_(code));
}
void template_unhandled()
{