CheckCondition: Fix FP for undeclared variables (daca)

This commit is contained in:
Daniel Marjamäki 2017-09-10 22:30:41 +02:00
parent e7f469c4ba
commit c34fdd1905
2 changed files with 10 additions and 1 deletions

View File

@ -526,7 +526,7 @@ void CheckCondition::multiCondition2()
}
} else if (!nonlocal && cond->isName()) {
// varid is 0. this is possibly a nonlocal variable..
nonlocal = Token::Match(cond->astParent(), "%cop%|(|[") || (_tokenizer->isCPP() && cond->str() == "this");
nonlocal = Token::Match(cond->astParent(), "%cop%|(|[") || Token::Match(cond, "%name% .") || (_tokenizer->isCPP() && cond->str() == "this");
} else {
tokens.push(cond->astOperand1());
tokens.push(cond->astOperand2());

View File

@ -1627,6 +1627,15 @@ private:
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// daca hyphy
check("bool f() {\n"
" if (rec.lLength==0) {\n"
" rec.Delete(i);\n"
" if (rec.lLength!=0) {}\n"
" }\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void oppositeInnerConditionAlias() {