Fixed #2330 (unreadVariable error for a fstream object when only extraction operator (>>) is used)

This commit is contained in:
Daniel Marjamäki 2010-12-21 19:02:00 +01:00
parent 244974a61a
commit 0f9415a5fb
2 changed files with 4 additions and 2 deletions

View File

@ -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% ["))

View File

@ -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");