fix #2672 (False positive: function can be const, nested classes declared in one line)

This commit is contained in:
Robert Reif 2011-03-23 07:48:18 -04:00
parent ac7f1f874e
commit 3259239dfe
2 changed files with 12 additions and 2 deletions

View File

@ -5715,6 +5715,17 @@ void Tokenizer::simplifyVarDecl()
}
}
else if (Token::Match(tok2, "%type% :: %type% %var% ,|="))
{
if (tok2->tokAt(3)->str() != "operator")
{
tok2 = tok2->tokAt(4); // The ',' token
typelen = 3;
}
else
tok2 = NULL;
}
else if (Token::Match(tok2, "%type% %var% [ %num% ] ,|=|[") ||
Token::Match(tok2, "%type% %var% [ %var% ] ,|=|["))
{

View File

@ -4115,8 +4115,7 @@ private:
void vardecl_stl_2()
{
const char code1[] = "{ std::string x = \"abc\"; }";
TODO_ASSERT_EQUALS("{ std :: string x ; x = \"abc\" ; }",
"{ std :: string x = \"abc\" ; }", tokenizeAndStringify(code1));
ASSERT_EQUALS("{ std :: string x ; x = \"abc\" ; }", tokenizeAndStringify(code1));
const char code2[] = "{ std::vector<int> x = y; }";
TODO_ASSERT_EQUALS("{ std :: vector < int > x ; x = y ; }",