File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -2119,6 +2119,8 @@ void CheckClass::checkConst()
21192119 continue ;
21202120 if (func.functionPointerUsage )
21212121 continue ;
2122+ if (func.hasRvalRefQualifier ())
2123+ continue ;
21222124
21232125 // don't suggest const when returning non-const pointer/reference, but still suggest static
21242126 auto isPointerOrReference = [this ](const Token* start, const Token* end) -> bool {
Original file line number Diff line number Diff line change @@ -186,6 +186,7 @@ class TestClass : public TestFixture {
186186 TEST_CASE (const92);
187187 TEST_CASE (const93);
188188 TEST_CASE (const94);
189+ TEST_CASE (const95); // #13320 - do not warn about r-value ref method
189190
190191 TEST_CASE (const_handleDefaultParameters);
191192 TEST_CASE (const_passThisToMemberOfOtherClass);
@@ -6705,6 +6706,14 @@ class TestClass : public TestFixture {
67056706 ASSERT_EQUALS (" " , errout_str ());
67066707 }
67076708
6709+ void const95 () { // #13320
6710+ checkConst (" class C {\n "
6711+ " std::string x;\n "
6712+ " std::string get() && { return x; }\n "
6713+ " };\n " );
6714+ ASSERT_EQUALS (" " , errout_str ());
6715+ }
6716+
67086717 void const_handleDefaultParameters () {
67096718 checkConst (" struct Foo {\n "
67106719 " void foo1(int i, int j = 0) {\n "
You can’t perform that action at this time.
0 commit comments