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..
|
||||
tok = tok->tokAt(2);
|
||||
while (Token::Match(tok, ". %var%") ||
|
||||
(tok && tok->str() == "[") ||
|
||||
Token::simpleMatch(tok, "( )"))
|
||||
Token::Match(tok, "[|("))
|
||||
{
|
||||
if (tok->str() != "[")
|
||||
tok = tok->tokAt(2);
|
||||
else if (tok->str() == "(")
|
||||
if (tok->str() == ".")
|
||||
tok = tok->tokAt(2);
|
||||
else
|
||||
{
|
||||
// goto "]"
|
||||
tok = tok->next();
|
||||
while (tok && !Token::Match(tok, "++|--|(|[|]"))
|
||||
tok = tok->next();
|
||||
if (!tok)
|
||||
break;
|
||||
else if (tok->str() == "]")
|
||||
tok = tok->next();
|
||||
else
|
||||
break;
|
||||
// goto "]" or ")"
|
||||
tok = tok->link();
|
||||
|
||||
// goto next token..
|
||||
tok = tok ? tok->next() : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5523,6 +5523,7 @@ private:
|
|||
ASSERT_EQUALS(";", tokenizeAndStringify(";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
|
||||
ASSERT_EQUALS("if ( false ) { } else { j = j - i ; }", tokenizeAndStringify("if (false) {} else { j -= i; }"));
|
||||
|
|
Loading…
Reference in New Issue