Fixed #3423 (Uninitialized variable in operator>>)
This commit is contained in:
parent
5f1fadec7b
commit
0572321572
|
@ -1165,9 +1165,6 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok) const
|
|||
if (vartok->previous()->str() == "return")
|
||||
return true;
|
||||
|
||||
if (Token::Match(vartok->next(), "++|--|%op%"))
|
||||
return true;
|
||||
|
||||
if (Token::Match(vartok->previous(), "++|--|%op%")) {
|
||||
if (vartok->previous()->str() == ">>" && _tokenizer->isCPP()) {
|
||||
// assume that variable is initialized
|
||||
|
@ -1179,6 +1176,9 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok) const
|
|||
}
|
||||
}
|
||||
|
||||
if (Token::Match(vartok->next(), "++|--|%op%"))
|
||||
return true;
|
||||
|
||||
if (vartok->strAt(1) == "]")
|
||||
return true;
|
||||
|
||||
|
|
|
@ -1746,6 +1746,12 @@ private:
|
|||
ASSERT_EQUALS("[test.c:3]: (error) Uninitialized variable: x\n", errout.str());
|
||||
}
|
||||
|
||||
checkUninitVar2("void f() {\n"
|
||||
" int i, i2;\n"
|
||||
" strm >> i >> i2;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// conditional initialization
|
||||
checkUninitVar2("void f() {\n"
|
||||
" int x;\n"
|
||||
|
|
Loading…
Reference in New Issue