Fixed #1883 (false positive: (style) The function 'A::SetPos' can be const)
This commit is contained in:
parent
9debcb84cd
commit
f2f5b3ebf0
|
@ -2368,7 +2368,12 @@ bool CheckClass::checkConstFunc(const std::string &classname, const std::vector<
|
|||
(tok1->str().find("=") == 1 &&
|
||||
tok1->str().find_first_of("<!>") == std::string::npos))
|
||||
{
|
||||
if (isMemberVar(classname, derivedFrom, varlist, tok1->previous()))
|
||||
if (tok1->previous()->varId() == 0 && !derivedFrom.empty())
|
||||
{
|
||||
isconst = false;
|
||||
break;
|
||||
}
|
||||
else if (isMemberVar(classname, derivedFrom, varlist, tok1->previous()))
|
||||
{
|
||||
isconst = false;
|
||||
break;
|
||||
|
|
|
@ -3630,6 +3630,27 @@ private:
|
|||
"};\n"
|
||||
);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkConst("class AA : public P {\n"
|
||||
"public:\n"
|
||||
" AA():P(){}\n"
|
||||
" inline void vSetXPos(int x_)\n"
|
||||
" {\n"
|
||||
" UnknownScope::x = x_;\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkConst("class AA {\n"
|
||||
"public:\n"
|
||||
" AA():P(){}\n"
|
||||
" inline void vSetXPos(int x_)\n"
|
||||
" {\n"
|
||||
" UnknownScope::x = x_;\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) The function 'AA::vSetXPos' can be const\n", errout.str());
|
||||
|
||||
}
|
||||
|
||||
void const27() // ticket #1882
|
||||
|
|
Loading…
Reference in New Issue