Fix issue 9718: False positive: Parameter can be declared const when written to via stream extraction operator (#2677)
This commit is contained in:
parent
6600453b44
commit
03b41ac987
|
@ -1578,7 +1578,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;
|
||||||
|
|
|
@ -1977,6 +1977,12 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("bool from_string(int& t, const std::string& s) {\n"
|
||||||
|
" std::istringstream iss(s);\n"
|
||||||
|
" return !(iss >> t).fail();\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("void e();\n"
|
check("void e();\n"
|
||||||
"void g(void);\n"
|
"void g(void);\n"
|
||||||
"void h(void);\n"
|
"void h(void);\n"
|
||||||
|
|
Loading…
Reference in New Issue