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

This commit is contained in:
Daniel Marjamaki 2011-11-02 18:31:13 +01:00
parent af7bf5c805
commit 0884204c2f
2 changed files with 9 additions and 1 deletions

View File

@ -3480,7 +3480,7 @@ void Tokenizer::setVarId()
std::string varname; std::string varname;
Token *tok2 = tok ? tok->next() : 0; Token *tok2 = tok ? tok->next() : 0;
while (tok2) { while (tok2) {
if (tok2->isName()) if (tok2->isName() && tok2->str() != "const")
varname = tok2->str(); varname = tok2->str();
else if (tok2->str() != "*" && tok2->str() != "&") else if (tok2->str() != "*" && tok2->str() != "&")
break; break;

View File

@ -186,6 +186,7 @@ private:
TEST_CASE(varid36); // ticket #2980 (segmentation fault) TEST_CASE(varid36); // ticket #2980 (segmentation fault)
TEST_CASE(varid37); // ticket #3092 (varid for 'Bar bar(*this);') TEST_CASE(varid37); // ticket #3092 (varid for 'Bar bar(*this);')
TEST_CASE(varid38); // ticket #3272 (varid for 'FOO class C;') TEST_CASE(varid38); // ticket #3272 (varid for 'FOO class C;')
TEST_CASE(varid39); // ticket #3279 (varid for 'FOO::BAR const')
TEST_CASE(varidFunctionCall1); TEST_CASE(varidFunctionCall1);
TEST_CASE(varidFunctionCall2); TEST_CASE(varidFunctionCall2);
TEST_CASE(varidFunctionCall3); TEST_CASE(varidFunctionCall3);
@ -2955,6 +2956,13 @@ private:
tokenizeDebugListing(code)); tokenizeDebugListing(code));
} }
void varid39() {
const std::string code = "void f(FOO::BAR const);\n";
ASSERT_EQUALS("\n\n##file 0\n"
"1: void f ( FOO :: BAR const ) ;\n",
tokenizeDebugListing(code));
}
void varidFunctionCall1() { void varidFunctionCall1() {
const std::string code("void f() {\n" const std::string code("void f() {\n"
" int x;\n" " int x;\n"