From 4e55fb604ce5a698ec75117f663a81c6095f17d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 26 Jul 2011 21:30:58 +0200 Subject: [PATCH] Fixed #2945 (False positive: Uninitialized variable reading from stream) --- lib/checkuninitvar.cpp | 2 +- test/testuninitvar.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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"