diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 6e29aadd2..bf27dec8d 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -477,7 +477,7 @@ private: bool assignment = false; for (const Token *tok2 = tok.next(); tok2 && tok2->str() != ";"; tok2 = tok2->next()) { - if (tok2->str() == "=") + if (tok2->str() == "=" || tok2->str() == ">>") { assignment = true; break; diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index 170e975a9..e4f13bead 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -181,6 +181,12 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + checkUninitVar("static int foo() {\n" + " int ret;\n" + " return cin >> ret;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + checkUninitVar("void f()\n" "{\n" " int a;\n"