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..
|
// Simplify simple calculations..
|
||||||
while (simplifyCalculations())
|
while (simplifyCalculations())
|
||||||
;
|
;
|
||||||
|
@ -1056,7 +1058,6 @@ void Tokenizer::simplifyTokenList()
|
||||||
{
|
{
|
||||||
modified = false;
|
modified = false;
|
||||||
modified |= simplifyConditions();
|
modified |= simplifyConditions();
|
||||||
modified |= simplifyCasts();
|
|
||||||
modified |= simplifyFunctionReturn();
|
modified |= simplifyFunctionReturn();
|
||||||
modified |= simplifyKnownVariables();
|
modified |= simplifyKnownVariables();
|
||||||
modified |= removeReduntantConditions();
|
modified |= removeReduntantConditions();
|
||||||
|
|
|
@ -74,6 +74,7 @@ private:
|
||||||
TEST_CASE(sizeof4);
|
TEST_CASE(sizeof4);
|
||||||
TEST_CASE(sizeof5);
|
TEST_CASE(sizeof5);
|
||||||
TEST_CASE(sizeof6);
|
TEST_CASE(sizeof6);
|
||||||
|
TEST_CASE(casting);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tok(const char code[])
|
std::string tok(const char code[])
|
||||||
|
@ -425,6 +426,18 @@ private:
|
||||||
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
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)
|
REGISTER_TEST(TestSimplifyTokens)
|
||||||
|
|
Loading…
Reference in New Issue