Fixed #8470 ((error) SymbolDatabase bailout; unhandled code)

This commit is contained in:
Daniel Marjamäki 2018-04-06 16:03:58 +02:00
parent 034296039c
commit 05acf9b352
2 changed files with 11 additions and 3 deletions

View File

@ -95,14 +95,13 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
while (Token::Match(tok2, ":: %name%"))
tok2 = tok2->tokAt(2);
while (Token::Match(tok2, "%name% :: %name%"))
tok2 = tok2->tokAt(2);
// skip over template args
if (tok2 && tok2->str() == "<" && tok2->link())
tok2 = tok2->link()->next();
if (Token::Match(tok2, "%name% ["))
continue;
// make sure we have valid code
if (!Token::Match(tok2, "{|:")) {
// check for qualified variable
@ -120,6 +119,8 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
continue;
else if (Token::Match(tok2, "%name% (") && _tokenizer->isFunctionHead(tok2->next(), "{;"))
continue;
else if (Token::Match(tok2, "%name% ["))
continue;
else
throw InternalError(tok2, "SymbolDatabase bailout; unhandled code", InternalError::SYNTAX);
continue;

View File

@ -271,6 +271,7 @@ private:
TEST_CASE(symboldatabase57);
TEST_CASE(symboldatabase58); // #6985 (using namespace type lookup)
TEST_CASE(symboldatabase59);
TEST_CASE(symboldatabase60);
TEST_CASE(enum1);
TEST_CASE(enum2);
@ -2889,6 +2890,12 @@ private:
ASSERT(db && db->scopeList.size() == 2);
}
void symboldatabase60() { // #8470
GET_SYMBOL_DB("struct A::someType A::bar() { return 0; }");
ASSERT(db != nullptr);
ASSERT(db && db->scopeList.size() == 2);
}
void enum1() {
GET_SYMBOL_DB("enum BOOL { FALSE, TRUE }; enum BOOL b;");