Skip to content

Commit

Permalink
Update testclass.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Aug 29, 2024
1 parent cf02d06 commit 54b4cdb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9066,6 +9066,23 @@ class TestClass : public TestFixture {
" std::string foo() && { return s; }\n" // <- used for temporary objects
"};\n");
ASSERT_EQUALS("", errout_str());

checkReturnByReference("struct S1 {\n" // #13056
" std::string str;\n"
" struct T { std::string strT; } mT;\n"
"};\n"
"struct S2 {\n"
" std::string get1() const {\n"
" return mS1->str;\n"
" }\n"
" std::string get2() const {\n"
" return mS1->mT.strT;\n"
" }\n"
" S1* mS1;\n"
"};\n");
ASSERT_EQUALS("[test.cpp:6]: (performance) Function 'get1()' should return member 'str' by const reference.\n"
"[test.cpp:9]: (performance) Function 'get2()' should return member 'strT' by const reference.\n",
errout_str());
}
};

Expand Down

0 comments on commit 54b4cdb

Please sign in to comment.