SymbolDatabase: Throw InternalError if parsing fails

This commit is contained in:
Daniel Marjamäki 2018-04-02 13:14:48 +02:00
parent 4a36520af2
commit 9f92685b92
2 changed files with 5 additions and 3 deletions

View File

@ -118,8 +118,10 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
// skip variable declaration
else if (Token::Match(tok2, "*|&|>"))
continue;
else if (Token::Match(tok2, "%name% (") && _tokenizer->isFunctionHead(tok2->next(), "{;"))
continue;
else
break; // bail
throw InternalError(tok2, "SymbolDatabase bailout; unhandled code", InternalError::SYNTAX);
continue;
}
break; // bail

View File

@ -606,7 +606,7 @@ private:
}
void garbageCode43() { // #6703
checkCode("int { }; struct A<void> a = { }");
ASSERT_THROW(checkCode("int { }; struct A<void> a = { }"), InternalError);
}
void garbageCode44() { // #6704
@ -1238,7 +1238,7 @@ private:
void garbageSymbolDatabase() {
checkCode("void f( { u = 1 ; } ) { }");
checkCode("{ }; void namespace A::f; { g() { int } }");
ASSERT_THROW(checkCode("{ }; void namespace A::f; { g() { int } }"), InternalError);
ASSERT_THROW(checkCode("class Foo {}; class Bar : public Foo"), InternalError);