Fixed #1954 (False positive: function can be const (derived class))

This commit is contained in:
Robert Reif 2010-08-20 07:28:31 +02:00 committed by Daniel Marjamäki
parent f123e951ec
commit 66de0d8f72
2 changed files with 15 additions and 0 deletions

View File

@ -1770,6 +1770,11 @@ bool CheckClass::isVirtual(const SpaceInfo *info, const Token *functionToken) co
return true;
}
}
else
{
// unable to find base class so assume it has a virtual function
return true;
}
}
return false;

View File

@ -137,6 +137,7 @@ private:
TEST_CASE(const30);
TEST_CASE(const31);
TEST_CASE(const32); // ticket #1905 - member array is assigned
TEST_CASE(const33);
TEST_CASE(constoperator1); // operator< can often be const
TEST_CASE(constoperator2); // operator<<
TEST_CASE(constincdec); // increment/decrement => non-const
@ -3878,6 +3879,15 @@ private:
ASSERT_EQUALS("", errout.str());
}
void const33()
{
checkConst("class derived : public base {\n"
"public:\n"
" void f(){}\n"
"};\n");
ASSERT_EQUALS("", errout.str());
}
// increment/decrement => not const
void constincdec()
{