Fixed #1220 (False memory leak when using while)

This commit is contained in:
Daniel Marjamäki 2010-01-10 14:00:32 +01:00
parent 3fabe53570
commit f65bf6d565
2 changed files with 9 additions and 0 deletions

View File

@ -1528,6 +1528,13 @@ void CheckMemoryLeakInFunction::simplifycode(Token *tok, bool &all)
done = false;
}
// Reduce "{ loop ;" => ";"
if (Token::Match(tok2, "{ loop ;"))
{
tok2->deleteNext();
done = false;
}
// Reduce "loop if break ; => ";"
if (Token::Match(tok2->next(), "loop if break|continue ; !!else"))
{

View File

@ -592,7 +592,9 @@ private:
// switch..
ASSERT_EQUALS("; alloc ; dealloc ;", simplifycode(";alloc;switch{case;break;};dealloc;"));
ASSERT_EQUALS("; if return ; }", simplifycode("; switch { case ; return ; default ; break ; } }"));
ASSERT_EQUALS("; if return ; else use ; }", simplifycode("; switch { case ; return ; default ; use ; break ; } }"));
ASSERT_EQUALS("; use ; }", simplifycode("; while1 { loop { ; } switch { case ; dealloc ; return ; default ; break ; } } }"));
// loops..
ASSERT_EQUALS(";", simplifycode("; loop { break; }"));