Fixed crash on garbage code (#7090)

This commit is contained in:
PKEuS 2015-11-04 10:10:20 +01:00
parent 8374e8414b
commit 6c20f4b2a2
2 changed files with 11 additions and 2 deletions

View File

@ -347,7 +347,7 @@ bool Tokenizer::duplicateTypedef(Token **tokPtr, const Token *name, const Token
return false;
}
}
if (tok)
tok = tok->previous();
}

View File

@ -196,6 +196,7 @@ private:
TEST_CASE(garbageCode145); // #7074
TEST_CASE(garbageCode146); // #7081
TEST_CASE(garbageCode147); // #7082
TEST_CASE(garbageCode148); // #7090
TEST_CASE(garbageValueFlow);
TEST_CASE(garbageSymbolDatabase);
@ -1168,6 +1169,14 @@ private:
checkCode("; void f ^ { return } int main ( ) { }"); // #4941
}
void garbageCode148() { // #7090
ASSERT_THROW(checkCode("void f_1() {\n"
" typedef S0 b[][1][1] != 0\n"
"};\n"
"b[K][0] S0 b[][1][1] != 4{ 0 };\n"
"b[0][0]"), InternalError);
}
void garbageValueFlow() {
// #6089
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"