diff --git a/lib/checkother.cpp b/lib/checkother.cpp index ac9d85d32..462b410a7 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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) diff --git a/test/testother.cpp b/test/testother.cpp index 57eab7eb5..3d3420249 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -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() {