Tokenizer: Fixed Tokenizer::simplifyKnownVariable bug when the variable is re-assigned in a loop
This commit is contained in:
parent
7ce4825f95
commit
6d9740adea
|
@ -4079,7 +4079,7 @@ bool Tokenizer::simplifyKnownVariables()
|
||||||
for (const Token *tok4 = tok3; tok4 && tok4 != endpar; tok4 = tok4->next())
|
for (const Token *tok4 = tok3; tok4 && tok4 != endpar; tok4 = tok4->next())
|
||||||
{
|
{
|
||||||
if (Token::Match(tok4, "++|-- %varid%", varid) ||
|
if (Token::Match(tok4, "++|-- %varid%", varid) ||
|
||||||
Token::Match(tok4, "%varid% ++|--", varid))
|
Token::Match(tok4, "%varid% ++|--|=", varid))
|
||||||
{
|
{
|
||||||
bailout = true;
|
bailout = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -93,6 +93,7 @@ private:
|
||||||
TEST_CASE(simplifyKnownVariables16);
|
TEST_CASE(simplifyKnownVariables16);
|
||||||
TEST_CASE(simplifyKnownVariables17);
|
TEST_CASE(simplifyKnownVariables17);
|
||||||
TEST_CASE(simplifyKnownVariables18);
|
TEST_CASE(simplifyKnownVariables18);
|
||||||
|
TEST_CASE(simplifyKnownVariables19);
|
||||||
|
|
||||||
TEST_CASE(match1);
|
TEST_CASE(match1);
|
||||||
|
|
||||||
|
@ -979,6 +980,14 @@ private:
|
||||||
simplifyKnownVariables(code));
|
simplifyKnownVariables(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyKnownVariables19()
|
||||||
|
{
|
||||||
|
const char code[] = "void f ( ) { int i=0; do { if (i>0) { a(); } i=b(); } while (i != 12); }";
|
||||||
|
ASSERT_EQUALS(
|
||||||
|
"void f ( ) { int i ; i = 0 ; do { if ( 0 < i ) { a ( ) ; } i = b ( ) ; } while ( i != 12 ) ; }",
|
||||||
|
simplifyKnownVariables(code));
|
||||||
|
}
|
||||||
|
|
||||||
void match1()
|
void match1()
|
||||||
{
|
{
|
||||||
// Match "%var% | %var%"
|
// Match "%var% | %var%"
|
||||||
|
|
Loading…
Reference in New Issue