From 3259239dfe910193ee5efd701bb224b73eafd32a Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Wed, 23 Mar 2011 07:48:18 -0400 Subject: [PATCH] fix #2672 (False positive: function can be const, nested classes declared in one line) --- lib/tokenize.cpp | 11 +++++++++++ test/testtokenize.cpp | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 48955d39c..01ee0c1ac 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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% ] ,|=|[")) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 19bf4fb03..ea1167a50 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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 x = y; }"; TODO_ASSERT_EQUALS("{ std :: vector < int > x ; x = y ; }",