From 3ff792560f6885d8262e1868450561e647acc080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 17 Sep 2012 18:10:11 +0200 Subject: [PATCH] Deactived bad message. Ticket #4154 --- lib/checkclass.cpp | 4 ++++ lib/checkclass.h | 6 +++--- test/testclass.cpp | 14 +++++++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 54827b067..7d58cba4b 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -217,13 +217,16 @@ void CheckClass::copyconstructors() } } // throw error if count mismatch + /* FIXME: This doesn't work. See #4154 for (std::map::const_iterator i = allocatedVars.begin(); i != allocatedVars.end(); ++i) { copyConstructorMallocError(copyCtor, i->second, i->second->str()); } + */ } } } +/* This doesn't work. See #4154 void CheckClass::copyConstructorMallocError(const Token *cctor, const Token *alloc, const std::string& varname) { std::list callstack; @@ -231,6 +234,7 @@ void CheckClass::copyConstructorMallocError(const Token *cctor, const Token *all callstack.push_back(alloc); reportError(callstack, Severity::warning, "copyCtorNoAllocation", "Copy constructor does not allocate memory for member '" + varname + "' although memory has been allocated in other constructors."); } +*/ void CheckClass::copyConstructorShallowCopyError(const Token *tok, const std::string& varname) { diff --git a/lib/checkclass.h b/lib/checkclass.h index 2a9da018a..67229e215 100644 --- a/lib/checkclass.h +++ b/lib/checkclass.h @@ -123,7 +123,7 @@ private: // Reporting errors.. void noConstructorError(const Token *tok, const std::string &classname, bool isStruct); - void copyConstructorMallocError(const Token *cctor, const Token *alloc, const std::string& var_name); + //void copyConstructorMallocError(const Token *cctor, const Token *alloc, const std::string& var_name); void copyConstructorShallowCopyError(const Token *tok, const std::string& varname); void noCopyConstructorError(const Token *tok, const std::string &classname, bool isStruct); void uninitVarError(const Token *tok, const std::string &classname, const std::string &varname); @@ -143,7 +143,7 @@ private: void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const { CheckClass c(0, settings, errorLogger); c.noConstructorError(0, "classname", false); - c.copyConstructorMallocError(0, 0, "var"); + //c.copyConstructorMallocError(0, 0, "var"); c.copyConstructorShallowCopyError(0, "var"); c.noCopyConstructorError(0, "class", false); c.uninitVarError(0, "classname", "varname"); @@ -168,7 +168,7 @@ private: std::string classInfo() const { return "Check the code for each class.\n" "* Missing constructors and copy constructors\n" - "* Missing allocation of memory in copy constructor\n" + //"* Missing allocation of memory in copy constructor\n" "* Are all variables initialized by the constructors?\n" "* Are all variables assigned by 'operator='?\n" "* Warn if memset, memcpy etc are used on a class\n" diff --git a/test/testclass.cpp b/test/testclass.cpp index f1e0f359c..7d0f3afd7 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -207,8 +207,10 @@ private: " p = malloc(strlen(str)+1);\n" " }\n" "};"); - ASSERT_EQUALS("[test.cpp:4]: (style) Value of pointer 'p', which points to allocated memory, is copied in copy constructor instead of allocating new memory.\n" - "[test.cpp:3] -> [test.cpp:7]: (warning) Copy constructor does not allocate memory for member 'p' although memory has been allocated in other constructors.\n", errout.str()); + TODO_ASSERT_EQUALS("[test.cpp:4]: (style) Value of pointer 'p', which points to allocated memory, is copied in copy constructor instead of allocating new memory.\n" + "[test.cpp:3] -> [test.cpp:7]: (warning) Copy constructor does not allocate memory for member 'p' although memory has been allocated in other constructors.\n", + "[test.cpp:4]: (style) Value of pointer 'p', which points to allocated memory, is copied in copy constructor instead of allocating new memory.\n" + , errout.str()); checkCopyConstructor("class F\n" "{\n" @@ -223,8 +225,10 @@ private: " strcpy(p,str);\n" " }\n" "};"); - ASSERT_EQUALS("[test.cpp:5]: (style) Value of pointer 'p', which points to allocated memory, is copied in copy constructor instead of allocating new memory.\n" - "[test.cpp:5] -> [test.cpp:10]: (warning) Copy constructor does not allocate memory for member 'p' although memory has been allocated in other constructors.\n", errout.str()); + TODO_ASSERT_EQUALS("[test.cpp:5]: (style) Value of pointer 'p', which points to allocated memory, is copied in copy constructor instead of allocating new memory.\n" + "[test.cpp:5] -> [test.cpp:10]: (warning) Copy constructor does not allocate memory for member 'p' although memory has been allocated in other constructors.\n", + "[test.cpp:5]: (style) Value of pointer 'p', which points to allocated memory, is copied in copy constructor instead of allocating new memory.\n" + , errout.str()); checkCopyConstructor("class kalci\n" "{\n" @@ -272,7 +276,7 @@ private: " strcpy(p,f.p);\n" " }\n" "};"); - ASSERT_EQUALS("[test.cpp:14] -> [test.cpp:11]: (warning) Copy constructor does not allocate memory for member 'd' although memory has been allocated in other constructors.\n", errout.str()); + TODO_ASSERT_EQUALS("[test.cpp:14] -> [test.cpp:11]: (warning) Copy constructor does not allocate memory for member 'd' although memory has been allocated in other constructors.\n", "", errout.str()); checkCopyConstructor("class F {\n" " char *c;\n"