Fixed crash on garbage code (#7081)

This commit is contained in:
PKEuS 2015-10-31 18:10:42 +01:00
parent d69cc450ce
commit 23e6e5a568
2 changed files with 9 additions and 1 deletions

View File

@ -4373,7 +4373,7 @@ void Tokenizer::removeRedundantFor()
void Tokenizer::removeRedundantSemicolons()
{
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (tok->str() == "(") {
if (tok->link() && tok->str() == "(") {
tok = tok->link();
continue;
}

View File

@ -194,6 +194,7 @@ private:
TEST_CASE(garbageCode143); // #6922
TEST_CASE(garbageCode144); // #6865
TEST_CASE(garbageCode145); // #7074
TEST_CASE(garbageCode146); // #7081
TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase);
@ -1143,6 +1144,13 @@ private:
checkCode("++4++ + + E++++++++++ + ch " "tp.oed5[.]");
}
void garbageCode146() { // #7081
ASSERT_THROW(checkCode("void foo() {\n"
" ? std::cout << pow((, 1) << std::endl;\n"
" double <ip = NUO ip) << std::end;\n"
"}"), InternalError);
}
void garbageValueFlow() {
// #6089
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"