diff --git a/lib/checkother.cpp b/lib/checkother.cpp index c99b1a62d..709031847 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3273,6 +3273,8 @@ void CheckOther::checkShadowVariables() continue; if (scope.type == Scope::eFunction && scope.className == var.name()) continue; + if (functionScope->function && functionScope->function->isStatic() && shadowed->variable() && !shadowed->variable()->isLocal()) + continue; shadowError(var.nameToken(), shadowed, (shadowed->varId() != 0) ? "variable" : "function"); } } diff --git a/test/testother.cpp b/test/testother.cpp index 698275c3c..01ef808cc 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -9323,6 +9323,17 @@ private: check("class C { C(); void foo() { static int C = 0; } }"); // #9195 - shadow constructor ASSERT_EQUALS("", errout.str()); + + // 10752 - no + check("struct S {\n" + " int i;\n" + "\n" + " static int foo() {\n" + " int i = 0;\n" + " return i;\n" + " }\n" + "};"); + ASSERT_EQUALS("", errout.str()); } void knownArgument() {