fix Tokenizer::simplifyVarDecl() template assignment

This commit is contained in:
Robert Reif 2011-03-23 21:15:49 -04:00
parent 7e3e5d628d
commit cbc81e20f5
2 changed files with 5 additions and 6 deletions

View File

@ -5795,12 +5795,12 @@ void Tokenizer::simplifyVarDecl()
tok2 = tok2->tokAt(2);
}
if (tok2->str() == "*" || tok2->str() == "&")
if (tok2->str() == "*")
{
tok2 = tok2->next();
}
if (Token::Match(tok2, "%var% ,"))
if (Token::Match(tok2, "%var% ,|="))
{
tok2 = tok2->next(); // The ',' token
typelen--;
@ -5868,7 +5868,7 @@ void Tokenizer::simplifyVarDecl()
{
// "type var =" => "type var; var ="
Token *VarTok = type0->tokAt((int)typelen);
while (Token::Match(VarTok, "*|const"))
while (Token::Match(VarTok, "*|&|const"))
VarTok = VarTok->next();
insertTokens(eq, VarTok, 2);
eq->str(";");

View File

@ -3015,7 +3015,7 @@ private:
"2: {\n"
"3: std :: vector < int > b@1 ;\n"
"4: std :: vector < int > & a@2 = b@1 ;\n"
"5: std :: vector < int > * c@3 = & b@1 ;\n"
"5: std :: vector < int > * c@3 ; c@3 = & b@1 ;\n"
"6: }\n");
ASSERT_EQUALS(expected, actual);
@ -4118,8 +4118,7 @@ private:
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 ; }",
"{ std :: vector < int > x = y ; }", tokenizeAndStringify(code2));
ASSERT_EQUALS("{ std :: vector < int > x ; x = y ; }", tokenizeAndStringify(code2));
}
void vardecl_template()