Fix 10286: false positive: uninitvar (#3271)

* Fix 10286: false positive: uninitvar

* Remove header
This commit is contained in:
Paul Fultz II 2021-05-23 00:58:19 -05:00 committed by GitHub
parent 8541e0503e
commit e2d9aaf23b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -1844,7 +1844,7 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings *settings,
}
}
if (cpp && Token::simpleMatch(tok2->astParent(), ">>") && tok2->astParent()->astOperand2() == tok2 && isLikelyStreamRead(cpp, tok2->astParent()))
if (cpp && Token::Match(tok2->astParent(), ">>|&") && astIsRHS(tok2) && isLikelyStreamRead(cpp, tok2->astParent()))
return true;
if (isLikelyStream(cpp, tok2))

View File

@ -4731,6 +4731,17 @@ private:
" return (res);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
valueFlowUninit("struct Archive {\n"
" bool isNull;\n"
" friend void operator&(const Archive &, bool &isNull);\n"
"};\n"
"void load(Archive& ar) {\n"
" bool isNull;\n"
" ar & isNull;\n"
" if (!isNull) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void uninitvar_ipa() {