From a360fc0595adb240312862a6308cbe8204d0d76f Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Thu, 29 Aug 2024 14:23:01 +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 bac96f1fc92..64913601b65 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -9083,6 +9083,23 @@ class TestClass : public TestFixture { 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()); + + checkReturnByReference("struct S { std::string str; };\n" // #13059 + "struct T {\n" + " S temp() const;\n" + " S s[1];\n" + "};\n" + "struct U {\n" + " std::string get1() const {\n" + " return t.temp().str;\n" + " }\n" + " std::string get2() const {\n" + " return t.s[0].str;\n" + " }\n" + " T t;\n" + "};\n"); + ASSERT_EQUALS("[test.cpp:10]: (performance) Function 'get2()' should return member 'str' by const reference.\n", + errout_str()); } };