Ticket #6703: Rewrite pattern in SymbolDatabase to avoid crash upon garbage code.
This commit is contained in:
parent
1eba077c24
commit
898ba783bf
|
@ -75,7 +75,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
if (tok2->next()->str() == ";")
|
||||
tok = tok2->next();
|
||||
else if (Token::simpleMatch(tok2->next(), "= {") &&
|
||||
tok2->linkAt(2)->next()->str() == ";")
|
||||
Token::simpleMatch(tok2->linkAt(2), "} ;"))
|
||||
tok = tok2->linkAt(2)->next();
|
||||
else if (Token::Match(tok2->next(), "(|{") &&
|
||||
tok2->next()->link()->strAt(1) == ";")
|
||||
|
|
|
@ -81,6 +81,7 @@ private:
|
|||
TEST_CASE(garbageCode40); // #6620
|
||||
TEST_CASE(garbageCode41); // #6685
|
||||
TEST_CASE(garbageCode42); // #5760
|
||||
TEST_CASE(garbageCode43); // #6703
|
||||
|
||||
TEST_CASE(garbageValueFlow);
|
||||
TEST_CASE(garbageSymbolDatabase);
|
||||
|
@ -470,6 +471,10 @@ private:
|
|||
ASSERT_THROW(checkCode("{ } * const ( ) { }"), InternalError);
|
||||
}
|
||||
|
||||
void garbageCode43() { // #6703
|
||||
checkCode("int { }; struct A<void> a = { }");
|
||||
}
|
||||
|
||||
void garbageValueFlow() {
|
||||
// #6089
|
||||
const char* code = "{} int foo(struct, x1, struct x2, x3, int, x5, x6, x7)\n"
|
||||
|
|
Loading…
Reference in New Issue