Fixed #1238 (False Negative : memory leak with template class)

This commit is contained in:
Daniel Marjamäki 2010-01-24 20:04:09 +01:00
parent 6d9740adea
commit 65881b9346
2 changed files with 14 additions and 1 deletions

View File

@ -1323,7 +1323,7 @@ void Tokenizer::simplifyTemplates()
continue; continue;
if (Token::Match(tok2->previous(), "[;{}=]") && if (Token::Match(tok2->previous(), "[;{}=]") &&
!Token::Match(tok2, (pattern + (isfunc ? "(" : "%var%")).c_str())) !Token::Match(tok2, (pattern + (isfunc ? "(" : "*| %var%")).c_str()))
continue; continue;
// New type.. // New type..

View File

@ -95,6 +95,7 @@ private:
TEST_CASE(template15); TEST_CASE(template15);
TEST_CASE(template16); TEST_CASE(template16);
TEST_CASE(template17); TEST_CASE(template17);
TEST_CASE(template18);
TEST_CASE(template_default_parameter); TEST_CASE(template_default_parameter);
TEST_CASE(template_default_type); TEST_CASE(template_default_type);
TEST_CASE(template_typename); TEST_CASE(template_typename);
@ -1459,6 +1460,18 @@ private:
sizeof_(code); sizeof_(code);
} }
void template18()
{
const char code[] = "template <class T> class foo { T a; };\n"
"foo<int> *f;";
const std::string expected("; ; "
"foo<int> * f ; "
"class foo<int> { int a ; }");
ASSERT_EQUALS(expected, sizeof_(code));
}
void template_default_parameter() void template_default_parameter()
{ {
{ {