Fixed false positive #5976: Properly handle shift from stream.
This commit is contained in:
parent
15bb447fdc
commit
8c96cc59c9
|
@ -997,7 +997,7 @@ void CheckUnusedVar::checkFunctionVariableUsage_iterateScopes(const Scope* const
|
|||
} else // addressof
|
||||
variables.use(tok->next()->varId(), tok); // use = read + write
|
||||
} else if (Token::Match(tok, ">>|>>= %var%")) {
|
||||
if (_tokenizer->isC() || (tok->previous()->variable() && tok->previous()->variable()->typeEndToken()->isStandardType()))
|
||||
if (_tokenizer->isC() || (tok->previous()->variable() && tok->previous()->variable()->typeEndToken()->isStandardType() && tok->astOperand1()->str() != ">>"))
|
||||
variables.read(tok->next()->varId(), tok);
|
||||
else
|
||||
variables.use(tok->next()->varId(), tok); // use = read + write
|
||||
|
|
|
@ -1682,6 +1682,19 @@ private:
|
|||
" if (c >> x) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'x' is not assigned a value.\n", errout.str());
|
||||
|
||||
functionVariableUsage("void f() {\n"
|
||||
" int x, y;\n"
|
||||
" std::cin >> x >> y;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
functionVariableUsage("void f() {\n"
|
||||
" int x, y;\n"
|
||||
" std::cin >> (x >> y);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'x' is not assigned a value.\n"
|
||||
"[test.cpp:2]: (style) Variable 'y' is not assigned a value.\n", errout.str());
|
||||
}
|
||||
|
||||
void localvar33() { // ticket #2345
|
||||
|
|
Loading…
Reference in New Issue