Fixed #887 (Tokenizer: Simplify variable value after loop)
This commit is contained in:
parent
5c00c1a539
commit
a42273da63
|
@ -5591,7 +5591,8 @@ bool Tokenizer::simplifyKnownVariables()
|
|||
tok3->deleteNext();
|
||||
}
|
||||
incdec(value, op);
|
||||
tok2->tokAt(2)->str(value);
|
||||
if (!Token::simpleMatch(tok2->tokAt(-2), "for ("))
|
||||
tok2->tokAt(2)->str(value);
|
||||
ret = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,6 +108,7 @@ private:
|
|||
TEST_CASE(simplifyKnownVariables23);
|
||||
TEST_CASE(simplifyKnownVariables24);
|
||||
TEST_CASE(simplifyKnownVariables25);
|
||||
TEST_CASE(simplifyKnownVariables26);
|
||||
|
||||
TEST_CASE(match1);
|
||||
|
||||
|
@ -1296,6 +1297,25 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void simplifyKnownVariables26()
|
||||
{
|
||||
// This testcase is related to ticket #887
|
||||
const char code[] = "void foo()\n"
|
||||
"{\n"
|
||||
" int i;\n"
|
||||
" for (i=0;i<10;++i) { }\n"
|
||||
" int k = i++;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(
|
||||
"void foo ( ) "
|
||||
"{"
|
||||
" int i ;"
|
||||
" for ( i = 0 ; i < 10 ; ++ i ) { }"
|
||||
" int k ; k = 10 ; "
|
||||
"}",
|
||||
simplifyKnownVariables(code));
|
||||
}
|
||||
|
||||
|
||||
void match1()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue