Fixed #10752 (False positive: shadow variable in static method)
This commit is contained in:
parent
38420c8ecf
commit
637aca8d59
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue