Fix another SymbolDatabase bailout (#1157)

This commit is contained in:
IOBYTE 2018-04-08 01:29:19 -04:00 committed by Daniel Marjamäki
parent 270635eb1f
commit 4f9073159a
2 changed files with 13 additions and 1 deletions

View File

@ -123,7 +123,12 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
continue;
else if (Token::Match(tok2, "%name% ["))
continue;
else
// skip template
else if (Token::simpleMatch(tok->previous(), "template class") &&
Token::simpleMatch(tok2->previous(), "> ;")) {
tok = tok2;
continue;
} else
throw InternalError(tok2, "SymbolDatabase bailout; unhandled code", InternalError::SYNTAX);
continue;
}

View File

@ -274,6 +274,7 @@ private:
TEST_CASE(symboldatabase60);
TEST_CASE(symboldatabase61);
TEST_CASE(symboldatabase62);
TEST_CASE(symboldatabase63);
TEST_CASE(enum1);
TEST_CASE(enum2);
@ -2928,6 +2929,12 @@ private:
ASSERT(db && db->scopeList.size() == 5);
}
void symboldatabase63() {
GET_SYMBOL_DB("template class T<int> ; void foo() { }");
ASSERT(db != nullptr);
ASSERT(db && db->scopeList.size() == 2);
}
void enum1() {
GET_SYMBOL_DB("enum BOOL { FALSE, TRUE }; enum BOOL b;");