Fixed #2234 (Variable is assigned a value that is never used)

This commit is contained in:
Daniel Marjamäki 2010-11-25 18:16:11 +01:00
parent ad91f414db
commit 0a744c0c6e
2 changed files with 7 additions and 1 deletions

View File

@ -4489,10 +4489,14 @@ void Tokenizer::simplifyCompoundAssignment()
{ {
// variable.. // variable..
tok = tok->tokAt(2); tok = tok->tokAt(2);
while (Token::Match(tok, ". %var%") || (tok && tok->str() == "[")) while (Token::Match(tok, ". %var%") ||
(tok && tok->str() == "[") ||
Token::simpleMatch(tok, "( )"))
{ {
if (tok->str() != "[") if (tok->str() != "[")
tok = tok->tokAt(2); tok = tok->tokAt(2);
else if (tok->str() == "(")
tok = tok->tokAt(2);
else else
{ {
// goto "]" // goto "]"

View File

@ -4708,6 +4708,8 @@ private:
ASSERT_EQUALS(";", tokenizeAndStringify(";x |= 0;")); ASSERT_EQUALS(";", tokenizeAndStringify(";x |= 0;"));
ASSERT_EQUALS(";", tokenizeAndStringify(";x *= 1;")); ASSERT_EQUALS(";", tokenizeAndStringify(";x *= 1;"));
ASSERT_EQUALS(";", tokenizeAndStringify(";x /= 1;")); ASSERT_EQUALS(";", tokenizeAndStringify(";x /= 1;"));
ASSERT_EQUALS("; a . x ( ) = a . x ( ) + 1 ;", tokenizeAndStringify("; a.x() += 1;"));
} }
void simplifyAssignmentInFunctionCall() void simplifyAssignmentInFunctionCall()