Fixed #8797 (exprDependsOnThis handle method call in non-inline method)
This commit is contained in:
parent
2348dcde6c
commit
b8e8b12783
|
@ -180,9 +180,12 @@ static bool exprDependsOnThis(const Token *expr)
|
|||
// calling nonstatic method?
|
||||
if (Token::Match(expr->previous(), "!!:: %name% (") && expr->function() && expr->function()->nestedIn && expr->function()->nestedIn->isClassOrStruct()) {
|
||||
// is it a method of this?
|
||||
const Scope *nestedIn = expr->scope();
|
||||
while (nestedIn && nestedIn != expr->function()->nestedIn)
|
||||
const Scope *nestedIn = expr->scope()->functionOf;
|
||||
if (nestedIn && nestedIn->function)
|
||||
nestedIn = nestedIn->function->token->scope();
|
||||
while (nestedIn && nestedIn != expr->function()->nestedIn) {
|
||||
nestedIn = nestedIn->nestedIn;
|
||||
}
|
||||
return nestedIn == expr->function()->nestedIn;
|
||||
}
|
||||
return exprDependsOnThis(expr->astOperand1()) || exprDependsOnThis(expr->astOperand2());
|
||||
|
|
|
@ -2037,6 +2037,20 @@ private:
|
|||
" int get() const;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class C {\n"
|
||||
"public:\n"
|
||||
" bool f() const { return x > 0; }\n"
|
||||
" void g();\n"
|
||||
" int x = 0;\n"
|
||||
"};\n"
|
||||
"\n"
|
||||
"void C::g() {\n"
|
||||
" bool b = f();\n"
|
||||
" x += 1;\n"
|
||||
" if (!b && f()) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void identicalInnerCondition() {
|
||||
|
|
Loading…
Reference in New Issue