From 738fb1b23a2351992f819d512e98adb7243bde49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 8 Sep 2018 09:14:02 +0200 Subject: [PATCH] Disabled CheckClass::checkCopyCtorAndEqOperator because of FP (#8388) --- lib/checkclass.cpp | 4 ++++ lib/checkclass.h | 2 +- test/testclass.cpp | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 34d594703..064856f2c 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2463,6 +2463,10 @@ enum CtorType { void CheckClass::checkCopyCtorAndEqOperator() { + // This is disabled because of #8388 + // The message must be clarified. How is the behaviour different? + return; + if (!mSettings->isEnabled(Settings::WARNING)) return; diff --git a/lib/checkclass.h b/lib/checkclass.h index 549a4ef4e..c0b9e5922 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -259,7 +259,7 @@ private: "- Suspicious subtraction from 'this'\n" "- Call of pure virtual function in constructor/destructor\n" "- Duplicated inherited data members\n" - "- If 'copy constructor' defined, 'operator=' also should be defined and vice versa\n" + // disabled for now "- If 'copy constructor' defined, 'operator=' also should be defined and vice versa\n" "- Check that arbitrary usage of public interface does not result in division by zero\n" "- Check that the 'override' keyword is used when overriding virtual methods\n"; } diff --git a/test/testclass.cpp b/test/testclass.cpp index e293dcfad..07f23e8d6 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -266,14 +266,16 @@ private: " A(const A& other) { } \n" " int x;\n" "};"); - ASSERT_EQUALS("[test.cpp:1]: (warning) The class 'A' has 'copy constructor' but lack of 'operator='.\n", errout.str()); + TODO_ASSERT_EQUALS("[test.cpp:1]: (warning) The class 'A' has 'copy constructor' but lack of 'operator='.\n", "", errout.str()); + // TODO the error message should be clarified. It should say something like 'copy constructor is empty and will not assign i and therefore the behaviour is different to the default assignment operator' checkCopyCtorAndEqOperator("class A \n" "{ \n" " A& operator=(const A& other) { return *this; }\n" " int x;\n" "};"); - ASSERT_EQUALS("[test.cpp:1]: (warning) The class 'A' has 'operator=' but lack of 'copy constructor'.\n", errout.str()); + TODO_ASSERT_EQUALS("[test.cpp:1]: (warning) The class 'A' has 'operator=' but lack of 'copy constructor'.\n", "", errout.str()); + // TODO the error message should be clarified. It should say something like 'assignment operator does not assign i and therefore the behaviour is different to the default copy constructor' checkCopyCtorAndEqOperator("class A \n" "{ \n"