Fixed #2228 (False positive: Claims function can be const when it can not be (shared_ptr))

This commit is contained in:
Robert Reif 2010-11-25 07:15:33 +01:00 committed by Daniel Marjamäki
parent 469be78254
commit 08b86e0b7e
2 changed files with 21 additions and 1 deletions

View File

@ -967,7 +967,8 @@ void SymbolDatabase::SpaceInfo::getVarList()
} }
// Container.. // 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% <")) Token::Match(tok, "%type% <"))
{ {
// got an unhandled template? // got an unhandled template?

View File

@ -151,6 +151,7 @@ private:
TEST_CASE(const37); // ticket #2081 and #2085 TEST_CASE(const37); // ticket #2081 and #2085
TEST_CASE(const38); // ticket #2135 TEST_CASE(const38); // ticket #2135
TEST_CASE(const39); TEST_CASE(const39);
TEST_CASE(const40); // ticket #2228
TEST_CASE(constoperator1); // operator< can often be const TEST_CASE(constoperator1); // operator< can often be const
TEST_CASE(constoperator2); // operator<< TEST_CASE(constoperator2); // operator<<
TEST_CASE(constoperator3); TEST_CASE(constoperator3);
@ -4414,6 +4415,24 @@ private:
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
} }
void const40() // ticket #2228
{
checkConst("class SharedPtrHolder\n"
"{\n"
" private:\n"
" std::tr1::shared_ptr<int> pView;\n"
" public:\n"
" SharedPtrHolder()\n"
" { }\n"
" void SetView(const std::shared_ptr<int> & aView)\n"
" {\n"
" pView = aView;\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
// increment/decrement => not const // increment/decrement => not const
void constincdec() void constincdec()
{ {