Fixed #10218 (FP uninitvar with input from stringstream in for loop)
This commit is contained in:
parent
db7be3e91b
commit
75311fba0f
|
@ -2213,7 +2213,7 @@ bool isLikelyStreamRead(bool cpp, const Token *op)
|
||||||
const Token *parent = op;
|
const Token *parent = op;
|
||||||
while (parent->astParent() && parent->astParent()->str() == op->str())
|
while (parent->astParent() && parent->astParent()->str() == op->str())
|
||||||
parent = parent->astParent();
|
parent = parent->astParent();
|
||||||
if (parent->astParent() && !Token::Match(parent->astParent(), "%oror%|&&|(|,|.|!"))
|
if (parent->astParent() && !Token::Match(parent->astParent(), "%oror%|&&|(|,|.|!|;"))
|
||||||
return false;
|
return false;
|
||||||
if (op->str() == "&" && parent->astParent())
|
if (op->str() == "&" && parent->astParent())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -71,6 +71,7 @@ private:
|
||||||
TEST_CASE(uninitvar9); // ticket #6424
|
TEST_CASE(uninitvar9); // ticket #6424
|
||||||
TEST_CASE(uninitvar10); // ticket #9467
|
TEST_CASE(uninitvar10); // ticket #9467
|
||||||
TEST_CASE(uninitvar11); // ticket #9123
|
TEST_CASE(uninitvar11); // ticket #9123
|
||||||
|
TEST_CASE(uninitvar12); // #10218 - stream read
|
||||||
TEST_CASE(uninitvar_unconditionalTry);
|
TEST_CASE(uninitvar_unconditionalTry);
|
||||||
TEST_CASE(uninitvar_funcptr); // #6404
|
TEST_CASE(uninitvar_funcptr); // #6404
|
||||||
TEST_CASE(uninitvar_operator); // #6680
|
TEST_CASE(uninitvar_operator); // #6680
|
||||||
|
@ -2773,6 +2774,15 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void uninitvar12() { // 10218
|
||||||
|
const char code[] = "void fp() {\n"
|
||||||
|
" std::stringstream ss;\n"
|
||||||
|
" for (int i; ss >> i;) {}\n"
|
||||||
|
"}";
|
||||||
|
checkUninitVar(code);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void uninitvar_unconditionalTry() {
|
void uninitvar_unconditionalTry() {
|
||||||
// Unconditional scopes and try{} scopes
|
// Unconditional scopes and try{} scopes
|
||||||
checkUninitVar("int f() {\n"
|
checkUninitVar("int f() {\n"
|
||||||
|
|
Loading…
Reference in New Issue