fix #2825 (missing varid on class variables when multiple inheritance is used)

This commit is contained in:
Robert Reif 2011-06-29 20:04:04 -04:00
parent c99a15516d
commit 586fdd24f2
2 changed files with 26 additions and 1 deletions

View File

@ -3802,7 +3802,10 @@ void Tokenizer::setVarId()
while (NULL != (tok2 = tok2->previous()))
{
if (Token::Match(tok2, "[,;{})]"))
break;
{
if (!Token::Match(tok2, ", public|protected|private"))
break;
}
if (Token::Match(tok2, "class|struct"))
break;
}

View File

@ -178,6 +178,7 @@ private:
TEST_CASE(varid31); // ticket #2831 (segmentation fault)
TEST_CASE(varid32); // ticket #2835 (segmentation fault)
TEST_CASE(varid33); // ticket #2875 (segmentation fault)
TEST_CASE(varid34); // ticket #2825
TEST_CASE(varidFunctionCall1);
TEST_CASE(varidFunctionCall2);
TEST_CASE(varidFunctionCall3);
@ -2961,6 +2962,27 @@ private:
ASSERT_EQUALS("", errout.str());
}
void varid34() // ticket #2825
{
const std::string code("class Fred : public B1, public B2\n"
"{\n"
"public:\n"
" Fred() { a = 0; }\n"
"private:\n"
" int a;\n"
"};\n");
const std::string expected("\n\n##file 0\n"
"1: class Fred : public B1 , public B2\n"
"2: {\n"
"3: public:\n"
"4: Fred ( ) { a@1 = 0 ; }\n"
"5: private:\n"
"6: int a@1 ;\n"
"7: } ;\n");
ASSERT_EQUALS(expected, tokenizeDebugListing(code));
ASSERT_EQUALS("", errout.str());
}
void varidFunctionCall1()
{
const std::string code("void f() {\n"