Merge branch 'master' of git@github.com:danmar/cppcheck
This commit is contained in:
commit
23c07dd2b8
|
@ -504,6 +504,19 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[])
|
|||
|
||||
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..
|
||||
std::list<Token *> templates;
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
|
|
|
@ -79,6 +79,7 @@ private:
|
|||
TEST_CASE(template11);
|
||||
TEST_CASE(template12);
|
||||
TEST_CASE(template_default_parameter);
|
||||
TEST_CASE(template_typename);
|
||||
|
||||
TEST_CASE(namespaces);
|
||||
|
||||
|
@ -944,6 +945,18 @@ private:
|
|||
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()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue