Fix issue 10235: Regression: oppositeInnerCondition (#3223)

This commit is contained in:
Paul Fultz II 2021-04-19 02:15:03 -05:00 committed by GitHub
parent 5768c3a726
commit 691f681d86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -650,6 +650,8 @@ bool exprDependsOnThis(const Token* expr, nonneg int depth)
{
if (!expr)
return false;
if (expr->str() == "this")
return true;
if (depth >= 1000)
// Abort recursion to avoid stack overflow
return true;

View File

@ -2429,6 +2429,20 @@ private:
"};");
ASSERT_EQUALS("", errout.str());
check("struct CD {\n"
" bool state;\n"
" void foo() {\n"
" const bool flag = this->get();\n"
" if (flag) {\n"
" this->bar();\n"
" if (!this->get()) return;\n"
" }\n"
" }\n"
" bool get() const;\n"
" void bar();\n"
"};\n");
ASSERT_EQUALS("", errout.str());
check("class C {\n"
"public:\n"
" bool f() const { return x > 0; }\n"