Skip to content

Commit

Permalink
Fix #11881 FP returnStdMoveLocal for rvalue reference return value
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Aug 18, 2023
1 parent 66cc8cd commit 5703aed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checkfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ void CheckFunctions::returnLocalStdMove()
const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();
for (const Scope *scope : symbolDatabase->functionScopes) {
// Expect return by-value
if (Function::returnsReference(scope->function, true))
if (Function::returnsReference(scope->function, /*unknown*/ true, /*includeRValueRef*/ true))
continue;
const auto rets = Function::findReturns(scope->function);
for (const Token* ret : rets) {
Expand Down
6 changes: 6 additions & 0 deletions test/testfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,12 @@ class TestFunctions : public TestFixture {
" std::cout << p->msg;\n"
"}\n");
ASSERT_EQUALS("", errout.str());

check("std::string&& f() {\n" // #11881
" std::string s;\n"
" return std::move(s);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}

void negativeMemoryAllocationSizeError() { // #389
Expand Down

0 comments on commit 5703aed

Please sign in to comment.