Fixed #1954 (False positive: function can be const (derived class))
This commit is contained in:
parent
f123e951ec
commit
66de0d8f72
|
@ -1770,6 +1770,11 @@ bool CheckClass::isVirtual(const SpaceInfo *info, const Token *functionToken) co
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// unable to find base class so assume it has a virtual function
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -137,6 +137,7 @@ private:
|
||||||
TEST_CASE(const30);
|
TEST_CASE(const30);
|
||||||
TEST_CASE(const31);
|
TEST_CASE(const31);
|
||||||
TEST_CASE(const32); // ticket #1905 - member array is assigned
|
TEST_CASE(const32); // ticket #1905 - member array is assigned
|
||||||
|
TEST_CASE(const33);
|
||||||
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(constincdec); // increment/decrement => non-const
|
TEST_CASE(constincdec); // increment/decrement => non-const
|
||||||
|
@ -3878,6 +3879,15 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
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
|
// increment/decrement => not const
|
||||||
void constincdec()
|
void constincdec()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue