Fixed #2584 (false positive 'variable n is never used')

This commit is contained in:
Daniel Marjamäki 2011-02-16 20:33:24 +01:00
parent f6872a7008
commit 54e0b60cc5
2 changed files with 2 additions and 1 deletions

View File

@ -4712,7 +4712,7 @@ void Tokenizer::simplifyCompoundAssignment()
// "a+=b" => "a = a + b"
for (Token *tok = _tokens; tok; tok = tok->next())
{
if (Token::Match(tok, "[;{}:] *| (| %var%"))
if (Token::Match(tok, "[;{}] (") || Token::Match(tok, "[;{}:] *| (| %var%"))
{
if (tok->str() == ":")
{

View File

@ -5196,6 +5196,7 @@ private:
ASSERT_EQUALS("{ x = x >> y ; }", tokenizeAndStringify("{ x >>= y;}"));
ASSERT_EQUALS("; * p = * p + y ;", tokenizeAndStringify("; *p += y;"));
ASSERT_EQUALS("; ( * p ) = ( * p ) + y ;", tokenizeAndStringify("; (*p) += y;"));
ASSERT_EQUALS("; * ( p [ 0 ] ) = * ( p [ 0 ] ) + y ;", tokenizeAndStringify("; *(p[0]) += y;"));
ASSERT_EQUALS("case 0 : x = x + y ; break ;", tokenizeAndStringify("case 0: x += y; break;"));