Skip to content

Commit c34fdd1

Browse files
committed
CheckCondition: Fix FP for undeclared variables (daca)
1 parent e7f469c commit c34fdd1

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

lib/checkcondition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ void CheckCondition::multiCondition2()
526526
}
527527
} else if (!nonlocal && cond->isName()) {
528528
// varid is 0. this is possibly a nonlocal variable..
529-
nonlocal = Token::Match(cond->astParent(), "%cop%|(|[") || (_tokenizer->isCPP() && cond->str() == "this");
529+
nonlocal = Token::Match(cond->astParent(), "%cop%|(|[") || Token::Match(cond, "%name% .") || (_tokenizer->isCPP() && cond->str() == "this");
530530
} else {
531531
tokens.push(cond->astOperand1());
532532
tokens.push(cond->astOperand2());

test/testcondition.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,15 @@ class TestCondition : public TestFixture {
16271627
" }\n"
16281628
"}\n");
16291629
ASSERT_EQUALS("", errout.str());
1630+
1631+
// daca hyphy
1632+
check("bool f() {\n"
1633+
" if (rec.lLength==0) {\n"
1634+
" rec.Delete(i);\n"
1635+
" if (rec.lLength!=0) {}\n"
1636+
" }\n"
1637+
"}");
1638+
ASSERT_EQUALS("", errout.str());
16301639
}
16311640

16321641
void oppositeInnerConditionAlias() {

0 commit comments

Comments
 (0)