Fixed #1303 (False positive: The function 'x' can be const for a constructor)
This commit is contained in:
parent
f62466493b
commit
5b76be4935
|
@ -1430,6 +1430,8 @@ void CheckClass::checkConst()
|
|||
{
|
||||
// get function name
|
||||
const std::string functionName(tok2->strAt(2));
|
||||
if (functionName == classname)
|
||||
continue;
|
||||
|
||||
// goto the ')'
|
||||
tok2 = tok2->tokAt(3)->link();
|
||||
|
|
|
@ -1530,6 +1530,15 @@ private:
|
|||
" int getA() { return a; }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) The function 'Fred::getA' can be const\n", errout.str());
|
||||
|
||||
// constructors can't be const..
|
||||
checkConst("class Fred {\n"
|
||||
" int a;\n"
|
||||
"public:\n"
|
||||
" Fred() { }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue