Merge branch 'master' of git@github.com:danmar/cppcheck

This commit is contained in:
Reijo Tomperi 2009-09-03 23:36:42 +03:00
commit 23c07dd2b8
2 changed files with 26 additions and 0 deletions

View File

@ -504,6 +504,19 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[])
void Tokenizer::simplifyTemplates() void Tokenizer::simplifyTemplates()
{ {
// Remove "typename" unless used in template arguments..
for (Token *tok = _tokens; tok; tok = tok->next())
{
if (tok->str() == "typename")
tok->deleteThis();
if (Token::simpleMatch(tok, "template <"))
{
while (tok->str() != ">")
tok = tok->next();
}
}
// Locate templates.. // Locate templates..
std::list<Token *> templates; std::list<Token *> templates;
for (Token *tok = _tokens; tok; tok = tok->next()) for (Token *tok = _tokens; tok; tok = tok->next())

View File

@ -79,6 +79,7 @@ private:
TEST_CASE(template11); TEST_CASE(template11);
TEST_CASE(template12); TEST_CASE(template12);
TEST_CASE(template_default_parameter); TEST_CASE(template_default_parameter);
TEST_CASE(template_typename);
TEST_CASE(namespaces); TEST_CASE(namespaces);
@ -944,6 +945,18 @@ private:
ASSERT_EQUALS(expected, sizeof_(code)); ASSERT_EQUALS(expected, sizeof_(code));
} }
void template_typename()
{
const char code[] = "template <class T>\n"
"void foo(typename T::t *)\n"
"{ }";
// The expected result..
const std::string expected(" template < class T >"
" void foo ( T :: t * )"
" { }");
ASSERT_EQUALS(expected, sizeof_(code));
}
void namespaces() void namespaces()
{ {