Fixed #9195 (False positive: shadowFunction when constructor is shadowed)

This commit is contained in:
Daniel Marjamäki 2020-04-20 18:02:10 +02:00
parent e93959186e
commit da6e0308c5
2 changed files with 4 additions and 1 deletions

View File

@ -2944,7 +2944,7 @@ static const Token *findShadowed(const Scope *scope, const std::string &varname,
return var.nameToken();
}
for (const Function &f : scope->functionList) {
if (f.name() == varname)
if (f.type == Function::Type::eFunction && f.name() == varname)
return f.tokenDef;
}
if (scope->type == Scope::eLambda)

View File

@ -8316,6 +8316,9 @@ private:
check("void f(int x) { int x; }");
ASSERT_EQUALS("[test.cpp:1] -> [test.cpp:1]: (style) Local variable 'x' shadows outer argument\n", errout.str());
check("class C { C(); void foo() { static int C = 0; } }"); // #9195 - shadow constructor
ASSERT_EQUALS("", errout.str());
}
void constArgument() {