diff --git a/lib/astutils.cpp b/lib/astutils.cpp index d5a0f8376..0329b66da 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -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)) diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index fb867ce9c..77cdc0214 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -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() {