diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 137560ce1..31c337e85 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1732,6 +1732,8 @@ void CheckOther::functionVariableUsage() else if (Token::Match(tok, ">>|& %var%")) variables.use(tok->next()->varId()); // use = read + write + else if (Token::Match(tok, "[;{}] %var% >>")) + variables.use(tok->next()->varId()); // use = read + write // function parameter else if (Token::Match(tok, "[(,] %var% [")) diff --git a/test/testunusedvar.cpp b/test/testunusedvar.cpp index 7259b20df..72e5de6c7 100644 --- a/test/testunusedvar.cpp +++ b/test/testunusedvar.cpp @@ -1335,11 +1335,11 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); } - + void localvar32() // ticket #2330 { functionVariableUsage("void f() {\n" - " int x;\n" + " int x;\n" " fstream &f = getfile();\n" " f >> x;\n" "}\n");