From 08b86e0b7edf4b6ccdfa2e8d82b6a3c3e3f09dc2 Mon Sep 17 00:00:00 2001 From: Robert Reif Date: Thu, 25 Nov 2010 07:15:33 +0100 Subject: [PATCH] Fixed #2228 (False positive: Claims function can be const when it can not be (shared_ptr)) --- lib/symboldatabase.cpp | 3 ++- test/testclass.cpp | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 4cfa2bfe5..ea5e46096 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -967,7 +967,8 @@ void SymbolDatabase::SpaceInfo::getVarList() } // Container.. - else if (Token::Match(tok, "%type% :: %type% <") || + else if (Token::Match(tok, "%type% :: %type% :: %type% <") || + Token::Match(tok, "%type% :: %type% <") || Token::Match(tok, "%type% <")) { // got an unhandled template? diff --git a/test/testclass.cpp b/test/testclass.cpp index 82ba5e106..7ebb646bb 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -151,6 +151,7 @@ private: TEST_CASE(const37); // ticket #2081 and #2085 TEST_CASE(const38); // ticket #2135 TEST_CASE(const39); + TEST_CASE(const40); // ticket #2228 TEST_CASE(constoperator1); // operator< can often be const TEST_CASE(constoperator2); // operator<< TEST_CASE(constoperator3); @@ -4414,6 +4415,24 @@ private: ASSERT_EQUALS("", errout.str()); } + void const40() // ticket #2228 + { + checkConst("class SharedPtrHolder\n" + "{\n" + " private:\n" + " std::tr1::shared_ptr pView;\n" + " public:\n" + " SharedPtrHolder()\n" + " { }\n" + " void SetView(const std::shared_ptr & aView)\n" + " {\n" + " pView = aView;\n" + " }\n" + "}\n"); + + ASSERT_EQUALS("", errout.str()); + } + // increment/decrement => not const void constincdec() {