From 65881b93469783cccc7a9570d55ce14d8de01dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 24 Jan 2010 20:04:09 +0100 Subject: [PATCH] Fixed #1238 (False Negative : memory leak with template class) --- lib/tokenize.cpp | 2 +- test/testsimplifytokens.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index f55423a45..d64fc0ab1 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1323,7 +1323,7 @@ void Tokenizer::simplifyTemplates() continue; if (Token::Match(tok2->previous(), "[;{}=]") && - !Token::Match(tok2, (pattern + (isfunc ? "(" : "%var%")).c_str())) + !Token::Match(tok2, (pattern + (isfunc ? "(" : "*| %var%")).c_str())) continue; // New type.. diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index f31418baf..a3591707a 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -95,6 +95,7 @@ private: TEST_CASE(template15); TEST_CASE(template16); TEST_CASE(template17); + TEST_CASE(template18); TEST_CASE(template_default_parameter); TEST_CASE(template_default_type); TEST_CASE(template_typename); @@ -1459,6 +1460,18 @@ private: sizeof_(code); } + void template18() + { + const char code[] = "template class foo { T a; };\n" + "foo *f;"; + + const std::string expected("; ; " + "foo * f ; " + "class foo { int a ; }"); + + ASSERT_EQUALS(expected, sizeof_(code)); + } + void template_default_parameter() { {