FIx FN shadowVariable in static function (#4079)
* FIx FN shadowVariable in static function * Use functionOf
This commit is contained in:
parent
e2069dd1b9
commit
9a379925cd
|
@ -3407,7 +3407,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())
|
||||
if (functionScope->functionOf && functionScope->functionOf->isClassOrStructOrUnion() && functionScope->function && functionScope->function->isStatic() &&
|
||||
shadowed->variable() && !shadowed->variable()->isLocal())
|
||||
continue;
|
||||
shadowError(var.nameToken(), shadowed, (shadowed->varId() != 0) ? "variable" : "function");
|
||||
}
|
||||
|
|
|
@ -9712,6 +9712,14 @@ private:
|
|||
" for (const F& f : fl) {}\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:7]: (style) Local variable 'f' shadows outer variable\n", errout.str());
|
||||
|
||||
check("extern int a;\n"
|
||||
"int a;\n"
|
||||
"static int f(void) {\n"
|
||||
" int a;\n"
|
||||
" return 0;\n"
|
||||
"}\n", "test.c");
|
||||
ASSERT_EQUALS("[test.c:1] -> [test.c:4]: (style) Local variable 'a' shadows outer variable\n", errout.str());
|
||||
}
|
||||
|
||||
void knownArgument() {
|
||||
|
|
Loading…
Reference in New Issue