From b6c010c17ef9eb83a2ea9303521553f2adaa9a7e Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Tue, 18 Jan 2022 13:09:02 +0100 Subject: [PATCH] Added regression test for Ticket 7981. --- test/testother.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/testother.cpp b/test/testother.cpp index dad864205..d80c51147 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -6967,6 +6967,18 @@ private: " return f(s);\n" "}"); ASSERT_EQUALS("", errout.str()); + + // #7981 - False positive redundantCopyLocalConst - const ref argument to ctor + check("class CD {\n" + " public:\n" + " CD(const CD&);\n" + " static const CD& getOne();\n" + "};\n" + " \n" + "void foo() {\n" + " const CD cd(CD::getOne());\n" + "}", nullptr, false, true); + ASSERT_EQUALS("", errout.str()); } void checkNegativeShift() {