Skip to content

Commit

Permalink
Fix #11818 FP constParameterReference with stream write
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Jul 7, 2023
1 parent 607c090 commit 1f44fbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3033,7 +3033,7 @@ bool isLikelyStreamRead(bool cpp, const Token *op)
const Token *parent = op;
while (parent->astParent() && parent->astParent()->str() == op->str())
parent = parent->astParent();
if (parent->astParent() && !Token::Match(parent->astParent(), "%oror%|&&|(|,|.|!|;"))
if (parent->astParent() && !Token::Match(parent->astParent(), "%oror%|&&|(|,|.|!|;|return"))
return false;
if (op->str() == "&" && parent->astParent())
return false;
Expand Down
6 changes: 6 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3270,6 +3270,12 @@ class TestOther : public TestFixture {
" const int* p = s.g<int>();\n"
"}\n");
ASSERT_EQUALS("", errout.str());

check("struct S { int x; };\n" // #11818
"std::istream& f(std::istream& is, S& s) {\n"
" return is >> s.x;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}

void constParameterCallback() {
Expand Down

0 comments on commit 1f44fbb

Please sign in to comment.