Fixed #6968 (unusedPrivateFunction not correct, called by inner class)
This commit is contained in:
parent
7fffc09b17
commit
99fc13ee70
|
@ -899,10 +899,10 @@ static bool checkFunctionUsage(const Function *privfunc, const Scope* scope)
|
|||
return true;
|
||||
}
|
||||
|
||||
for (std::list<Scope*>::const_iterator i = scope->nestedList.begin(); i != scope->nestedList.end(); ++i) {
|
||||
if ((*i)->isClassOrStruct())
|
||||
if (checkFunctionUsage(privfunc, *i)) // Check nested classes, which can access private functions of their base
|
||||
return true;
|
||||
for (std::list<Type*>::const_iterator i = scope->definedTypes.begin(); i != scope->definedTypes.end(); ++i) {
|
||||
const Type *type = *i;
|
||||
if (type->enclosingScope == scope && checkFunctionUsage(privfunc, type->classScope))
|
||||
return true;
|
||||
}
|
||||
|
||||
for (std::list<Variable>::const_iterator i = scope->varlist.begin(); i != scope->varlist.end(); ++i) {
|
||||
|
|
|
@ -392,6 +392,17 @@ private:
|
|||
" };\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class A {\n" // #6968 - outer definition
|
||||
"public:\n"
|
||||
" class B;\n"
|
||||
"private:\n"
|
||||
" void f() {}\n"
|
||||
"}\n"
|
||||
"class A::B {"
|
||||
" B() { A a; a.f(); }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue