Fixed #3272 (Internal error)

This commit is contained in:
Daniel Marjamaki 2011-11-01 18:03:32 +01:00
parent 9dd3360cd6
commit 937a4497ca
2 changed files with 10 additions and 3 deletions

View File

@ -3389,9 +3389,6 @@ void Tokenizer::setVarId()
if (tok && tok->str() == "friend")
continue;
if (Token::Match(tok, "class|struct %type% ;"))
continue;
// skip global namespace prefix
if (Token::simpleMatch(tok, "::"))
tok = tok->next();
@ -3497,6 +3494,9 @@ void Tokenizer::setVarId()
tok2 = tok2->next();
}
if (Token::Match(tok2 ? tok2->tokAt(-2) : 0, "class|struct %type% ;"))
continue;
// End of tokens reached..
if (!tok2)
break;

View File

@ -185,6 +185,7 @@ private:
TEST_CASE(varid35); // ticket #2937
TEST_CASE(varid36); // ticket #2980 (segmentation fault)
TEST_CASE(varid37); // ticket #3092 (varid for 'Bar bar(*this);')
TEST_CASE(varid38); // ticket #3272 (varid for 'FOO class C;')
TEST_CASE(varidFunctionCall1);
TEST_CASE(varidFunctionCall2);
TEST_CASE(varidFunctionCall3);
@ -2947,6 +2948,12 @@ private:
tokenizeDebugListing(code));
}
void varid38() {
const std::string code = "FOO class C;\n";
ASSERT_EQUALS("\n\n##file 0\n"
"1: FOO class C ;\n",
tokenizeDebugListing(code));
}
void varidFunctionCall1() {
const std::string code("void f() {\n"