Fixed #558 (Tokenizer: Bad simplification of 'for(unsigned i = 0; i < 100; ++i)')

This commit is contained in:
Daniel Marjamäki 2009-08-05 20:15:48 +02:00
parent 1c59e4a51b
commit e1beb70f80
2 changed files with 9 additions and 2 deletions

View File

@ -2442,10 +2442,10 @@ void Tokenizer::unsignedint()
if (!Token::Match(tok, "unsigned %var% [;,=]"))
continue;
// Previous token should either be a symbol or one of "{};"
// Previous token should either be a symbol or one of "{};("
if (tok->previous() &&
!tok->previous()->isName() &&
!Token::Match(tok->previous(), "[{};]"))
!Token::Match(tok->previous(), "[{};(]"))
continue;
// next token should not be a standard type?

View File

@ -2320,6 +2320,13 @@ private:
ASSERT_EQUALS(code2, tokenizeAndStringify(code1));
}
// insert "int" after "unsigned"..
{
const char code1[] = "for (unsigned i=0; i<10; i++)";
const char code2[] = "for ( unsigned int i = 0 ; i < 10 ; i ++ )";
ASSERT_EQUALS(code2, tokenizeAndStringify(code1));
}
}
};