Tokenizer::simplifyTemplates: better handling of '(foo<double>())'. Ticket: #2631
This commit is contained in:
parent
6648267ab8
commit
f53ff27b71
|
@ -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()))
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue