Tokenizer::setVarId: Fixed problem with class declarations with inheritance. skip them.

This commit is contained in:
Daniel Marjamäki 2011-11-21 21:18:56 +01:00
parent 0dd05e0d56
commit 17f891ad34
2 changed files with 14 additions and 1 deletions

View File

@ -3409,8 +3409,13 @@ void Tokenizer::setVarId()
if (tok->str() == "virtual")
continue;
if (Token::Match(tok, "class|struct|union %type% :|{|;"))
if (Token::Match(tok, "class|struct|union %type% :|{|;")) {
if (tok->strAt(2) == ":") {
while (tok->next() && !Token::Match(tok->next(),"[;{]"))
tok = tok->next();
}
continue;
}
while (Token::Match(tok, "public:|private:|protected:"))
tok = tok->next();

View File

@ -193,6 +193,7 @@ private:
TEST_CASE(varid41); // ticket #3340 (varid for union type)
TEST_CASE(varid42); // ticket #3316 (varid for array)
TEST_CASE(varid43);
TEST_CASE(varid44);
TEST_CASE(varidFunctionCall1);
TEST_CASE(varidFunctionCall2);
TEST_CASE(varidFunctionCall3);
@ -3069,6 +3070,13 @@ private:
tokenizeDebugListing(code));
}
void varid44() {
const std::string code("class A:public B,public C,public D {};");
ASSERT_EQUALS("\n\n##file 0\n"
"1: class A : public B , public C , public D { } ;\n",
tokenizeDebugListing(code));
}
void varidFunctionCall1() {
const std::string code("void f() {\n"
" int x;\n"