Fixed #8465 (SymbolDatabase: bailout if there is 'struct A::B ab[5];')

This commit is contained in:
Daniel Marjamäki 2018-03-31 17:54:47 +02:00
parent e3977f7e51
commit 4af2e517b9
2 changed files with 12 additions and 1 deletions

View File

@ -93,13 +93,16 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
else if (_tokenizer->isCPP() && tok->strAt(1) == "class")
tok2 = tok2->next();
while (tok2 && tok2->str() == "::")
while (Token::Match(tok2, ":: %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

View File

@ -270,6 +270,7 @@ private:
TEST_CASE(symboldatabase56); // #7909
TEST_CASE(symboldatabase57);
TEST_CASE(symboldatabase58); // #6985 (using namespace type lookup)
TEST_CASE(symboldatabase59);
TEST_CASE(enum1);
TEST_CASE(enum2);
@ -2879,6 +2880,13 @@ private:
}
}
void symboldatabase59() { // #8465
GET_SYMBOL_DB("struct A::B ab[10];\n"
"void f() {}");
ASSERT(db != nullptr);
ASSERT(db && db->scopeList.size() == 2);
}
void enum1() {
GET_SYMBOL_DB("enum BOOL { FALSE, TRUE }; enum BOOL b;");