Fixed #3279 (Token::Match called with varid 0)

This commit is contained in:
Daniel Marjamäki 2011-11-09 18:49:17 +01:00
parent b7cc9779c4
commit 2d00cabee1
2 changed files with 11 additions and 0 deletions

View File

@ -3483,6 +3483,9 @@ void Tokenizer::setVarId()
} while (again);
}
if (Token::Match(tok, "%str%"))
continue;
// Determine name of declared variable..
std::string varname;
Token *tok2 = tok ? tok->next() : 0;

View File

@ -188,6 +188,7 @@ private:
TEST_CASE(varid37); // ticket #3092 (varid for 'Bar bar(*this);')
TEST_CASE(varid38); // ticket #3272 (varid for 'FOO class C;')
TEST_CASE(varid39); // ticket #3279 (varid for 'FOO::BAR const')
TEST_CASE(varid40); // ticket #3279
TEST_CASE(varidFunctionCall1);
TEST_CASE(varidFunctionCall2);
TEST_CASE(varidFunctionCall3);
@ -2999,6 +3000,13 @@ private:
}
}
void varid40() {
const std::string code("extern \"C\" int (*a())();");
ASSERT_EQUALS("\n\n##file 0\n"
"1: extern \"C\" int ( * a ( ) ) ( ) ;\n",
tokenizeDebugListing(code));
}
void varidFunctionCall1() {
const std::string code("void f() {\n"
" int x;\n"