Fixed #2760 (false positive: uninitialized variable ', (a) =')
This commit is contained in:
parent
67ef647262
commit
168bd2ebfc
|
@ -7231,6 +7231,14 @@ bool Tokenizer::simplifyRedundantParenthesis()
|
|||
tok->deleteNext();
|
||||
ret = true;
|
||||
}
|
||||
|
||||
if (Token::simpleMatch(tok->previous(), ", (") &&
|
||||
Token::simpleMatch(tok->link(), ") ="))
|
||||
{
|
||||
tok->link()->deleteThis();
|
||||
tok->deleteThis();
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -8540,7 +8548,7 @@ void Tokenizer::simplifyComma()
|
|||
|
||||
if (tok->previous() && tok->previous()->previous())
|
||||
{
|
||||
if (Token::simpleMatch(tok->previous()->previous(), "delete") &&
|
||||
if (Token::Match(tok->previous()->previous(), "delete %var% , %var% ;") &&
|
||||
tok->next()->varId() != 0)
|
||||
{
|
||||
// Handle "delete a, b;"
|
||||
|
|
|
@ -222,6 +222,7 @@ private:
|
|||
TEST_CASE(removeParentheses9); // Ticket #1962
|
||||
TEST_CASE(removeParentheses10); // Ticket #2320
|
||||
TEST_CASE(removeParentheses11); // Ticket #2505
|
||||
TEST_CASE(removeParentheses12); // Ticket #2760 ',(b)='
|
||||
|
||||
TEST_CASE(tokenize_double);
|
||||
TEST_CASE(tokenize_strings);
|
||||
|
@ -3820,7 +3821,7 @@ private:
|
|||
void removeParentheses7()
|
||||
{
|
||||
const char code[] = ";char *p; (delete(p), (p)=0);";
|
||||
ASSERT_EQUALS("; char * p ; delete p ; ( p ) = 0 ;", tokenizeAndStringify(code,true));
|
||||
ASSERT_EQUALS("; char * p ; delete p ; p = 0 ;", tokenizeAndStringify(code,true));
|
||||
}
|
||||
|
||||
void removeParentheses8()
|
||||
|
@ -3853,6 +3854,12 @@ private:
|
|||
ASSERT_EQUALS("{ } x ( ) ;", tokenizeAndStringify("{}(x());", false));
|
||||
}
|
||||
|
||||
void removeParentheses12()
|
||||
{
|
||||
// #2760
|
||||
ASSERT_EQUALS(", x = 0 ;", tokenizeAndStringify(",(x)=0;", false));
|
||||
}
|
||||
|
||||
void tokenize_double()
|
||||
{
|
||||
const char code[] = "void f()\n"
|
||||
|
|
Loading…
Reference in New Issue