Fixed #2280 (Tokenizer::setVarId : variable id not set for inner iterator)

This commit is contained in:
Daniel Marjamäki 2010-12-06 17:52:44 +01:00
parent 9667d97949
commit 0b696b7079
2 changed files with 12 additions and 1 deletions

View File

@ -3207,7 +3207,7 @@ void Tokenizer::setVarId()
if (c == varname[0])
{
const std::string &prev = tok2->strAt(-1);
if (tok2->str() == varname && prev != "struct" && prev != "union" && prev != "::" && prev != ".")
if (tok2->str() == varname && prev != "struct" && prev != "union" && prev != "::" && prev != "." && tok2->strAt(1) != "::")
tok2->varId(_varId);
}
else if (c == '{')

View File

@ -155,6 +155,7 @@ private:
TEST_CASE(varid24);
TEST_CASE(varid25);
TEST_CASE(varid26); // ticket #1967 (list of function pointers)
TEST_CASE(varid27); // Ticket #2280 (same name for namespace and variable)
TEST_CASE(varidFunctionCall1);
TEST_CASE(varidFunctionCall2);
TEST_CASE(varidStl);
@ -2501,6 +2502,16 @@ private:
ASSERT_EQUALS(expected, tokenizeDebugListing(code));
}
void varid27()
{
const std::string code("int fooled_ya;\n"
"fooled_ya::iterator iter;\n");
const std::string expected("\n\n##file 0\n"
"1: int fooled_ya@1 ;\n"
"2: fooled_ya :: iterator iter@2 ;\n");
ASSERT_EQUALS(expected, tokenizeDebugListing(code));
}
void varidFunctionCall1()
{
const std::string code("void f() {\n"