Fixed #1717 (False positive: Resource leak with while)
This commit is contained in:
parent
83c62eca9c
commit
08b6e6ee09
|
@ -3590,6 +3590,7 @@ bool Tokenizer::simplifyTokenList()
|
|||
|
||||
simplifyFunctionParameters();
|
||||
elseif();
|
||||
simplifyErrNoInWhile();
|
||||
simplifyIfAssign();
|
||||
simplifyRedundantParanthesis();
|
||||
simplifyIfNot();
|
||||
|
@ -3598,7 +3599,6 @@ bool Tokenizer::simplifyTokenList()
|
|||
simplifyComparisonOrder();
|
||||
simplifyNestedStrcat();
|
||||
simplifyWhile0();
|
||||
simplifyErrNoInWhile();
|
||||
simplifyFuncInWhile();
|
||||
|
||||
simplifyIfAssign(); // could be affected by simplifyIfNot
|
||||
|
|
|
@ -37,6 +37,12 @@ private:
|
|||
|
||||
void run()
|
||||
{
|
||||
// Make sure the Tokenizer::simplifyTokenList works.
|
||||
// The order of the simplifications is important. So this test
|
||||
// case shall make sure the simplifications are done in the
|
||||
// correct order
|
||||
TEST_CASE(simplifyTokenList1);
|
||||
|
||||
TEST_CASE(cast);
|
||||
TEST_CASE(iftruefalse);
|
||||
TEST_CASE(combine_strings);
|
||||
|
@ -297,6 +303,15 @@ private:
|
|||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void simplifyTokenList1()
|
||||
{
|
||||
// #1717 : The simplifyErrNoInWhile needs to be used before simplifyIfAssign..
|
||||
ASSERT_EQUALS("; x = f ( ) ; while ( ( x ) == -1 ) { x = f ( ) ; }",
|
||||
tok(";while((x=f())==-1 && errno==EINTR){}",true));
|
||||
}
|
||||
|
||||
|
||||
void cast()
|
||||
{
|
||||
ASSERT_EQUALS("if ( ! p )", tok("if (p == (char *)0)"));
|
||||
|
|
Loading…
Reference in New Issue