Add missing else that could cause an extra try scope to be added to the scope list (#8025)
Add an optional extended description…
This commit is contained in:
parent
14be611a7e
commit
8a668aa860
|
@ -786,7 +786,7 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
|
||||||
const Token* tok1 = tok->next();
|
const Token* tok1 = tok->next();
|
||||||
if (tok->str() == "else")
|
if (tok->str() == "else")
|
||||||
scopeList.push_back(Scope(this, tok, scope, Scope::eElse, tok1));
|
scopeList.push_back(Scope(this, tok, scope, Scope::eElse, tok1));
|
||||||
if (tok->str() == "do")
|
else if (tok->str() == "do")
|
||||||
scopeList.push_back(Scope(this, tok, scope, Scope::eDo, tok1));
|
scopeList.push_back(Scope(this, tok, scope, Scope::eDo, tok1));
|
||||||
else //if (tok->str() == "try")
|
else //if (tok->str() == "try")
|
||||||
scopeList.push_back(Scope(this, tok, scope, Scope::eTry, tok1));
|
scopeList.push_back(Scope(this, tok, scope, Scope::eTry, tok1));
|
||||||
|
|
|
@ -254,6 +254,7 @@ private:
|
||||||
TEST_CASE(symboldatabase54); // #7257
|
TEST_CASE(symboldatabase54); // #7257
|
||||||
TEST_CASE(symboldatabase55); // #7767 (return unknown macro)
|
TEST_CASE(symboldatabase55); // #7767 (return unknown macro)
|
||||||
TEST_CASE(symboldatabase56); // #7909
|
TEST_CASE(symboldatabase56); // #7909
|
||||||
|
TEST_CASE(symboldatabase57);
|
||||||
|
|
||||||
TEST_CASE(enum1);
|
TEST_CASE(enum1);
|
||||||
TEST_CASE(enum2);
|
TEST_CASE(enum2);
|
||||||
|
@ -2755,6 +2756,27 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void symboldatabase57() {
|
||||||
|
GET_SYMBOL_DB("int bar(bool b)\n"
|
||||||
|
"{\n"
|
||||||
|
" if(b)\n"
|
||||||
|
" return 1;\n"
|
||||||
|
" else\n"
|
||||||
|
" return 1;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT(db != nullptr);
|
||||||
|
if (db) {
|
||||||
|
ASSERT(db->scopeList.size() == 4U);
|
||||||
|
if (db->scopeList.size() == 4U) {
|
||||||
|
std::list<Scope>::const_iterator it = db->scopeList.begin();
|
||||||
|
ASSERT(it->type == Scope::eGlobal);
|
||||||
|
ASSERT((++it)->type == Scope::eFunction);
|
||||||
|
ASSERT((++it)->type == Scope::eIf);
|
||||||
|
ASSERT((++it)->type == Scope::eElse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void enum1() {
|
void enum1() {
|
||||||
GET_SYMBOL_DB("enum BOOL { FALSE, TRUE }; enum BOOL b;");
|
GET_SYMBOL_DB("enum BOOL { FALSE, TRUE }; enum BOOL b;");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue