Fixed #1928 (missing varId for template class variable)

This commit is contained in:
Daniel Marjamäki 2010-08-14 20:50:49 +02:00
parent 248bb3b6e8
commit 4ff9a1ac94
2 changed files with 30 additions and 1 deletions

View File

@ -2749,9 +2749,21 @@ void Tokenizer::setVarId()
tok2 = tok2->tokAt(2);
again = true;
}
else if (Token::Match(tok2, "%type% ,"))
else if (Token::Match(tok2, "%type% *| ,"))
{
tok2 = tok2->tokAt(2);
if (tok2->str() == ",")
tok2 = tok2->next();
again = true;
}
else if (level > 1 && Token::Match(tok2, "%type% *| >"))
{
--level;
while (tok2->str() != ">")
tok2 = tok2->next();
tok2 = tok2->next();
if (level == 1 && tok->str() == ">")
break;
again = true;
}
else

View File

@ -141,6 +141,7 @@ private:
TEST_CASE(varid16);
TEST_CASE(varid17); // ticket #1810
TEST_CASE(varid18);
TEST_CASE(varid19);
TEST_CASE(varidStl);
TEST_CASE(varid_delete);
TEST_CASE(varid_functions);
@ -2249,6 +2250,22 @@ private:
ASSERT_EQUALS(expected, tokenizeDebugListing(code));
}
void varid19()
{
const std::string code("void foo()\n"
"{\n"
" std::pair<std::vector<double>, int> x;\n"
"}\n");
const std::string expected("\n\n##file 0\n"
"1: void foo ( )\n"
"2: {\n"
"3: std :: pair < std :: vector < double > , int > x@1 ;\n"
"4: }\n");
ASSERT_EQUALS(expected, tokenizeDebugListing(code));
}
void varidStl()
{