Fixed #753 (Tokenizer: don't simplify variables inside do {} while loop)
http://sourceforge.net/apps/trac/cppcheck/ticket/753
This commit is contained in:
parent
a1e20290cd
commit
b9237db9a3
|
@ -3022,7 +3022,7 @@ bool Tokenizer::simplifyKnownVariables()
|
|||
}
|
||||
|
||||
// Stop if something like 'while (--var)' is found
|
||||
if (tok3->str() == "while")
|
||||
if (tok3->str() == "while" || tok3->str() == "do")
|
||||
{
|
||||
const Token *endpar = tok3->next()->link();
|
||||
bool bailout = false;
|
||||
|
|
|
@ -80,6 +80,7 @@ private:
|
|||
TEST_CASE(simplifyKnownVariables11);
|
||||
TEST_CASE(simplifyKnownVariables12);
|
||||
TEST_CASE(simplifyKnownVariables13);
|
||||
TEST_CASE(simplifyKnownVariables14);
|
||||
|
||||
TEST_CASE(match1);
|
||||
|
||||
|
@ -802,6 +803,13 @@ private:
|
|||
simplifyKnownVariables(code));
|
||||
}
|
||||
|
||||
void simplifyKnownVariables14()
|
||||
{
|
||||
// ticket #753
|
||||
const char code[] = "void f ( ) { int n ; n = 1 ; do { ++ n ; } while ( n < 10 ) ; }";
|
||||
ASSERT_EQUALS(code, simplifyKnownVariables(code));
|
||||
}
|
||||
|
||||
|
||||
void match1()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue