Fix ticket #133 (Segmentation fault when static_cast is in for loop)
This commit is contained in:
parent
0011d059e6
commit
42a9eb9e53
|
@ -876,6 +876,8 @@ void Tokenizer::simplifyTokenList()
|
|||
}
|
||||
}
|
||||
|
||||
simplifyCasts();
|
||||
|
||||
// Simplify simple calculations..
|
||||
while (simplifyCalculations())
|
||||
;
|
||||
|
@ -1056,7 +1058,6 @@ void Tokenizer::simplifyTokenList()
|
|||
{
|
||||
modified = false;
|
||||
modified |= simplifyConditions();
|
||||
modified |= simplifyCasts();
|
||||
modified |= simplifyFunctionReturn();
|
||||
modified |= simplifyKnownVariables();
|
||||
modified |= removeReduntantConditions();
|
||||
|
|
|
@ -74,6 +74,7 @@ private:
|
|||
TEST_CASE(sizeof4);
|
||||
TEST_CASE(sizeof5);
|
||||
TEST_CASE(sizeof6);
|
||||
TEST_CASE(casting);
|
||||
}
|
||||
|
||||
std::string tok(const char code[])
|
||||
|
@ -425,6 +426,18 @@ private:
|
|||
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
||||
}
|
||||
|
||||
void casting()
|
||||
{
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
"for (int i = 0; i < static_cast<int>(3); ++i) {}\n"
|
||||
"}\n";
|
||||
|
||||
std::ostringstream expected;
|
||||
expected << " void f ( ) { for ( int i = 0 ; i < 3 ; ++ i ) { } }";
|
||||
|
||||
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestSimplifyTokens)
|
||||
|
|
Loading…
Reference in New Issue