diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 8b4456063..6b9362714 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -1408,14 +1408,7 @@ void CheckClass::privateFunctions() std::list FuncList; /** @todo embedded class have access to private functions */ - int nested = 0; - std::list::const_iterator ni; - for (ni = info->nestedList.begin(); ni != info->nestedList.end(); ++ni) - { - if ((*ni)->type != SpaceInfo::Function) - nested++; - } - if (!nested) + if (!info->getNestedNonFunctions()) { for (func = info->functionList.begin(); func != info->functionList.end(); ++func) { diff --git a/lib/checkclass.h b/lib/checkclass.h index e4ae9c510..49ac6ed3e 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -312,6 +312,24 @@ private: return 0; } + /** + * @brief get the number of nested spaces that are not functions + * + * This returns the number of user defined types (class, struct, union) + * that are defined in this user defined type or namespace. + */ + unsigned int getNestedNonFunctions() const + { + unsigned int nested = 0; + std::list::const_iterator ni; + for (ni = nestedList.begin(); ni != nestedList.end(); ++ni) + { + if ((*ni)->type != SpaceInfo::Function) + nested++; + } + return nested; + } + bool isBaseClassFunc(const Token *tok); };