Fixed #2660 (False positive: Variable 'v' is assigned a value that is never used)
This commit is contained in:
parent
1ddfa9a906
commit
e89f6d6ec0
|
@ -4974,25 +4974,17 @@ void Tokenizer::simplifyCompoundAssignment()
|
||||||
// variable..
|
// variable..
|
||||||
tok = tok->tokAt(2);
|
tok = tok->tokAt(2);
|
||||||
while (Token::Match(tok, ". %var%") ||
|
while (Token::Match(tok, ". %var%") ||
|
||||||
(tok && tok->str() == "[") ||
|
Token::Match(tok, "[|("))
|
||||||
Token::simpleMatch(tok, "( )"))
|
|
||||||
{
|
{
|
||||||
if (tok->str() != "[")
|
if (tok->str() == ".")
|
||||||
tok = tok->tokAt(2);
|
|
||||||
else if (tok->str() == "(")
|
|
||||||
tok = tok->tokAt(2);
|
tok = tok->tokAt(2);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// goto "]"
|
// goto "]" or ")"
|
||||||
tok = tok->next();
|
tok = tok->link();
|
||||||
while (tok && !Token::Match(tok, "++|--|(|[|]"))
|
|
||||||
tok = tok->next();
|
// goto next token..
|
||||||
if (!tok)
|
tok = tok ? tok->next() : 0;
|
||||||
break;
|
|
||||||
else if (tok->str() == "]")
|
|
||||||
tok = tok->next();
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5523,6 +5523,7 @@ private:
|
||||||
ASSERT_EQUALS(";", tokenizeAndStringify(";x /= 1;"));
|
ASSERT_EQUALS(";", tokenizeAndStringify(";x /= 1;"));
|
||||||
|
|
||||||
ASSERT_EQUALS("; a . x ( ) = a . x ( ) + 1 ;", tokenizeAndStringify("; a.x() += 1;"));
|
ASSERT_EQUALS("; a . x ( ) = a . x ( ) + 1 ;", tokenizeAndStringify("; a.x() += 1;"));
|
||||||
|
ASSERT_EQUALS("; x ( 1 ) = x ( 1 ) + 1 ;", tokenizeAndStringify("; x(1) += 1;"));
|
||||||
|
|
||||||
// #2368
|
// #2368
|
||||||
ASSERT_EQUALS("if ( false ) { } else { j = j - i ; }", tokenizeAndStringify("if (false) {} else { j -= i; }"));
|
ASSERT_EQUALS("if ( false ) { } else { j = j - i ; }", tokenizeAndStringify("if (false) {} else { j -= i; }"));
|
||||||
|
|
Loading…
Reference in New Issue