diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index f5ffa4e1604..332f47eb0d6 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -6510,7 +6510,7 @@ Type* Scope::findType(const std::string& name) //--------------------------------------------------------------------------- -Scope *Scope::findInNestedListRecursive(const std::string & name) +const Scope *Scope::findInNestedListRecursive(const std::string & name) const { auto it = std::find_if(nestedList.cbegin(), nestedList.cend(), [&](const Scope* s) { return s->className == name; @@ -6518,8 +6518,8 @@ Scope *Scope::findInNestedListRecursive(const std::string & name) if (it != nestedList.end()) return *it; - for (Scope* scope: nestedList) { - Scope *child = scope->findInNestedListRecursive(name); + for (const Scope* scope: nestedList) { + const Scope *child = scope->findInNestedListRecursive(name); if (child) return child; } diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h index 954b31cc05b..0eaa0aab9ee 100644 --- a/lib/symboldatabase.h +++ b/lib/symboldatabase.h @@ -1157,7 +1157,7 @@ class CPPCHECKLIB Scope { * @brief find if name is in nested list * @param name name of nested scope */ - Scope *findInNestedListRecursive(const std::string & name); + const Scope *findInNestedListRecursive(const std::string & name) const; void addVariable(const Token *token_, const Token *start_, const Token *end_, AccessControl access_, const Type *type_,