From cbc81e20f52fc2aac2d50fbf5cfb4cf540059d76 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Wed, 23 Mar 2011 21:15:49 -0400 Subject: [PATCH] fix Tokenizer::simplifyVarDecl() template assignment --- lib/tokenize.cpp | 6 +++--- test/testtokenize.cpp | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 5c978a85f..3930e7406 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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(";"); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index ea1167a50..22c63786d 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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 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()