Fixed #9630 (False positive: in stlIfFind checking, if with initializer is not handled properly)
This commit is contained in:
parent
afb5590741
commit
1fd85c0ae8
|
@ -1092,7 +1092,11 @@ void CheckStl::if_find()
|
|||
if ((scope.type != Scope::eIf && scope.type != Scope::eWhile) || !scope.classDef)
|
||||
continue;
|
||||
|
||||
for (const Token *tok = scope.classDef->next(); tok->str() != "{"; tok = tok->next()) {
|
||||
const Token *conditionStart = scope.classDef->next();
|
||||
if (conditionStart && Token::simpleMatch(conditionStart->astOperand2(), ";"))
|
||||
conditionStart = conditionStart->astOperand2();
|
||||
|
||||
for (const Token *tok = conditionStart; tok->str() != "{"; tok = tok->next()) {
|
||||
const Token* funcTok = nullptr;
|
||||
const Library::Container* container = nullptr;
|
||||
|
||||
|
|
|
@ -2496,6 +2496,10 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(std::set<int> s) {\n"
|
||||
" if (auto result = s.find(123); result != s.end()) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// ---------------------------
|
||||
// std::find
|
||||
|
|
Loading…
Reference in New Issue