This commit is contained in:
parent
479533a80a
commit
15f8c71ec3
|
@ -1078,7 +1078,10 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
|
|||
|
||||
// function
|
||||
else if (Token::Match(tok, "%name% (")) {
|
||||
variables.read(tok->varId(), tok);
|
||||
if (tok->varId() && !tok->function()) // operator()
|
||||
variables.use(tok->varId(), tok);
|
||||
else
|
||||
variables.read(tok->varId(), tok);
|
||||
useFunctionArgs(tok->next()->astOperand2(), variables);
|
||||
} else if (Token::Match(tok, "std :: ref ( %var% )")) {
|
||||
variables.eraseAll(tok->tokAt(4)->varId());
|
||||
|
|
|
@ -136,6 +136,7 @@ private:
|
|||
TEST_CASE(localvar64); // #9997
|
||||
TEST_CASE(localvar65); // #9876, #10006
|
||||
TEST_CASE(localvar66); // #11143
|
||||
TEST_CASE(localvar67); // #9946
|
||||
TEST_CASE(localvarloops); // loops
|
||||
TEST_CASE(localvaralias1);
|
||||
TEST_CASE(localvaralias2); // ticket #1637
|
||||
|
@ -3612,6 +3613,28 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvar67() { // #9946
|
||||
functionVariableUsage("struct B {\n"
|
||||
" virtual ~B() {}\n"
|
||||
" bool operator() () const { return true; }\n"
|
||||
" virtual bool f() const = 0;\n"
|
||||
"};\n"
|
||||
"class D : B {\n"
|
||||
"public:\n"
|
||||
" bool f() const override { return false; }\n"
|
||||
"};\n"
|
||||
"void f1() {\n"
|
||||
" const D d1;\n"
|
||||
" d1.f();\n"
|
||||
"}\n"
|
||||
"void f2() {\n"
|
||||
" const D d2;\n"
|
||||
" d2();\n"
|
||||
" B() {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void localvarloops() {
|
||||
// loops
|
||||
functionVariableUsage("void fun(int c) {\n"
|
||||
|
|
|
@ -4520,8 +4520,8 @@ private:
|
|||
code = "struct base {\n"
|
||||
" virtual int f() { return 0; }\n"
|
||||
"};\n"
|
||||
"struct derived {\n"
|
||||
" virtual int f() { return 1; }\n"
|
||||
"struct derived : base {\n"
|
||||
" int f() override { return 1; }\n"
|
||||
"};\n"
|
||||
"void g(derived* d) {\n"
|
||||
" base* b = d;\n"
|
||||
|
|
Loading…
Reference in New Issue