From dfe89f395aa7fac24627c409d75ff2e18ebd2acb Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 25 Aug 2011 19:13:53 -0400 Subject: [PATCH] fix #3049 (False Positive - Technically the member function 'VideoOutputNull::SetupDeinterlace' can be const.) --- lib/symboldatabase.cpp | 5 +++++ test/testclass.cpp | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 9934ee133..0371d4649 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -919,8 +919,13 @@ bool SymbolDatabase::argsMatch(const Scope *scope, const Token *first, const Tok // skip default value assignment else if (first->next()->str() == "=") + { first = first->tokAt(2); + if (second->next()->str() == "=") + second = second->tokAt(2); + } + // definition missing variable name else if (first->next()->str() == "," && second->next()->str() != ",") second = second->next(); diff --git a/test/testclass.cpp b/test/testclass.cpp index 32b7e7ba2..719e3e623 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -179,6 +179,7 @@ private: TEST_CASE(const49); // ticket #2795 TEST_CASE(const50); // ticket #2943 TEST_CASE(const51); // ticket #3040 + TEST_CASE(const52); // ticket #3049 TEST_CASE(assigningPointerToPointerIsNotAConstOperation); TEST_CASE(assigningArrayElementIsNotAConstOperation); TEST_CASE(constoperator1); // operator< can often be const @@ -5660,6 +5661,23 @@ private: ASSERT_EQUALS("", errout.str()); } + void const52() // ticket 3049 + { + checkConst("class A {\n" + " public:\n" + " A() : foo(false) {};\n" + " virtual bool One(bool b = false) { foo = b; return false; }\n" + " private:\n" + " bool foo;\n" + "};\n" + "class B : public A {\n" + " public:\n" + " B() {};\n" + " bool One(bool b = false) { return false; }\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); + } + void assigningPointerToPointerIsNotAConstOperation() { checkConst("struct s\n"