Tokenizer: setVarId improved to handle declaration at the first token

This commit is contained in:
Daniel Marjamäki 2009-02-02 17:35:46 +00:00
parent 27c0f786bc
commit d0af67a1b1
2 changed files with 6 additions and 3 deletions

View File

@ -468,8 +468,11 @@ void Tokenizer::setVarId()
unsigned int _varId = 0;
for (Token *tok = _tokens; tok; tok = tok->next())
{
if (!(firstMatch = Token::Match(tok, "[;{}(] %type% *| %var%"))
&& !Token::Match(tok, "[;{}(] %type% %type% *| %var%"))
if ( tok != _tokens && !Token::Match(tok, "[;{}(]") )
continue;
if (!(firstMatch = Token::Match(tok->next(), "%type% *| %var%"))
&& !Token::Match(tok->next(), "%type% %type% *| %var%"))
continue;
// Determine name of declared variable..

View File

@ -67,7 +67,7 @@ private:
TEST_CASE(varid1);
TEST_CASE(varid2);
// TODO TEST_CASE(varid3);
TEST_CASE(varid3);
TEST_CASE(file1);
TEST_CASE(file2);