From 54b4cdb5cee4435a1fefd62f824c29dc67837b65 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 29 Aug 2024 11:05:02 +0200 Subject: [PATCH] Update testclass.cpp --- test/testclass.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/testclass.cpp b/test/testclass.cpp index 2cab08eeee1..bac96f1fc92 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -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()); } };