diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 1e1ed4454..fbeed2752 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5644,7 +5644,7 @@ void Tokenizer::simplifyVarDecl() continue; Token *type0 = tok; - if (!Token::Match(type0, "%type%")) + if (!Token::Match(type0, "::| %type%")) continue; if (Token::Match(type0, "else|return|public:|protected:|private:")) continue; @@ -5675,6 +5675,12 @@ void Tokenizer::simplifyVarDecl() continue; // check for qualification.. + if (Token::Match(tok2, ":: %type%")) + { + typelen++; + tok2 = tok2->next(); + } + if (Token::Match(tok2, "%type% :: %type%")) { while (tok2 && Token::Match(tok2, "%type% ::")) diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 22c63786d..7febb17a9 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -239,6 +239,7 @@ private: TEST_CASE(vardecl11); TEST_CASE(vardecl12); TEST_CASE(vardecl13); + TEST_CASE(vardecl14); TEST_CASE(vardecl_stl_1); TEST_CASE(vardecl_stl_2); TEST_CASE(vardecl_template); @@ -4251,6 +4252,12 @@ private: ASSERT_EQUALS("void f ( ) {\nint a ; a = ( x < y ) ? 1 : 0 ;\n}", tokenizeAndStringify(code)); } + void vardecl14() + { + const char code[] = "::std::tr1::shared_ptr pNum1, pNum2;\n"; + ASSERT_EQUALS(":: std :: tr1 :: shared_ptr < int > pNum1 ; :: std :: tr1 :: shared_ptr < int > pNum2 ;", tokenizeAndStringify(code)); + } + void volatile_variables() { const char code[] = "volatile int a=0;\n"