Partial fix for #11444 cppcheckError: Analysis failed (function not recognized) (#4656)

This commit is contained in:
chrchr-github 2022-12-19 22:29:43 +01:00 committed by GitHub
parent da32c5aecd
commit ad858e92dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 2 deletions

View File

@ -479,8 +479,10 @@ void SymbolDatabase::createSymbolDatabaseFindAllScopes()
// check for end of scope
else if (tok == scope->bodyEnd) {
access.erase(scope);
scope = const_cast<Scope*>(scope->nestedIn);
do {
access.erase(scope);
scope = const_cast<Scope*>(scope->nestedIn);
} while (scope->type != Scope::eGlobal && succeeds(tok, scope->bodyEnd));
continue;
}
// check for end of init list

View File

@ -372,6 +372,7 @@ private:
TEST_CASE(createSymbolDatabaseFindAllScopes2);
TEST_CASE(createSymbolDatabaseFindAllScopes3);
TEST_CASE(createSymbolDatabaseFindAllScopes4);
TEST_CASE(createSymbolDatabaseFindAllScopes5);
TEST_CASE(enum1);
TEST_CASE(enum2);
@ -5133,6 +5134,31 @@ private:
ASSERT(var1->variable());
}
void createSymbolDatabaseFindAllScopes5()
{
GET_SYMBOL_DB("class C {\n"
"public:\n"
" template<typename T>\n"
" class D;\n"
" template<typename T>\n"
" struct O : public std::false_type {};\n"
"};\n"
"template<typename T>\n"
"struct C::O<std::optional<T>> : public std::true_type {};\n"
"template<typename T>\n"
"class C::D {};\n"
"struct S {\n"
" S(int i) : m(i) {}\n"
" static const S IN;\n"
" int m;\n"
"};\n"
"const S S::IN(1);\n");
ASSERT(db);
ASSERT_EQUALS(6, db->scopeList.size());
const Token* const var = Token::findsimplematch(tokenizer.tokens(), "IN (");
TODO_ASSERT(var && var->variable());
}
void enum1() {
GET_SYMBOL_DB("enum BOOL { FALSE, TRUE }; enum BOOL b;");