Fixed #1788 (Tokenizer: template destructor is lost)

This commit is contained in:
Daniel Marjamäki 2010-06-12 08:32:05 +02:00
parent 69ecc24bf5
commit f3fbdc96e1
2 changed files with 24 additions and 1 deletions

View File

@ -2356,7 +2356,7 @@ void Tokenizer::simplifyTemplates()
}
// member function implemented outside class definition
else if (_indentlevel == 0 && _parlevel == 0 && Token::Match(tok3, (pattern + " :: %var% (").c_str()))
else if (_indentlevel == 0 && _parlevel == 0 && Token::Match(tok3, (pattern + " :: ~| %var% (").c_str()))
{
addtoken(name2.c_str(), tok3->linenr(), tok3->fileIndex());
while (tok3->str() != "::")

View File

@ -103,6 +103,7 @@ private:
TEST_CASE(template17);
TEST_CASE(template18);
TEST_CASE(template19);
TEST_CASE(template20);
TEST_CASE(template_unhandled);
TEST_CASE(template_default_parameter);
TEST_CASE(template_default_type);
@ -1753,6 +1754,28 @@ private:
ASSERT_EQUALS(expected, sizeof_(code));
}
void template20()
{
// Ticket #1788 - the destructor implementation is lost
const char code[] = "template <class T> class A\n"
"{\n"
"public:\n"
" ~A();\n"
"};\n"
"\n"
"template <class T> A<T>::~A()\n"
"{\n"
"}\n"
"\n"
"A<int> a;\n";
// The expected result..
const std::string expected("; ; ; A<int> a ; "
"class A<int> { public: ~ A<int> ( ) ; } "
"A<int> :: ~ A<int> ( ) { }");
ASSERT_EQUALS(expected, sizeof_(code));
}
void template_unhandled()
{
// An unhandled template usage should be simplified..