Fixed #2620 (Tokenizer::setVarId : wrong handling of member function parameters)

This commit is contained in:
Daniel Marjamäki 2011-03-08 20:41:41 +01:00
parent bf2362d558
commit 0b8581e717
2 changed files with 31 additions and 0 deletions

View File

@ -3603,6 +3603,10 @@ void Tokenizer::setVarId()
--indentlevel;
}
// skip parantheses..
else if (tok2->str() == "(")
tok2 = tok2->link();
// Found a member variable..
else if (indentlevel == 1 && tok2->varId() > 0)
varlist[tok2->str()] = tok2->varId();

View File

@ -190,6 +190,7 @@ private:
TEST_CASE(varidclass6);
TEST_CASE(varidclass7);
TEST_CASE(varidclass8);
TEST_CASE(varidclass9);
TEST_CASE(file1);
TEST_CASE(file2);
@ -3363,6 +3364,32 @@ private:
ASSERT_EQUALS(expected, tokenizeDebugListing(code));
}
void varidclass9()
{
const std::string code("typedef char Str[10];"
"class A {\n"
"public:\n"
" void f(Str &cl);\n"
" void g(Str cl);\n"
"}\n"
"void Fred::f(Str &cl) {\n"
" sizeof(cl);\n"
"}");
const std::string expected("\n\n"
"##file 0\n"
"1: ; class A {\n"
"2: public:\n"
"3: void f ( char ( & cl ) [ 10 ] ) ;\n"
"4: void g ( char cl@1 [ 10 ] ) ;\n"
"5: }\n"
"6: void Fred :: f ( char ( & cl ) [ 10 ] ) {\n"
"7: sizeof ( cl ) ;\n"
"8: }\n");
ASSERT_EQUALS(expected, tokenizeDebugListing(code));
}
void file1()
{