Fixed #1319 (false negative: missing const not found)
This commit is contained in:
parent
53f514fc5c
commit
f561441d90
|
@ -1441,6 +1441,8 @@ void CheckClass::checkConst()
|
|||
// member function?
|
||||
if (Token::Match(tok2, "%type% %var% (") ||
|
||||
Token::Match(tok2, "%type% %type% %var% (") ||
|
||||
Token::Match(tok2, "const %type% &|* %var% (") ||
|
||||
Token::Match(tok2, "const std :: %type% &|*| %var% (") ||
|
||||
Token::Match(tok2, "%type% operator %any% ("))
|
||||
{
|
||||
// goto function name..
|
||||
|
|
|
@ -1546,6 +1546,17 @@ private:
|
|||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) The function 'Fred::getA' can be const\n", errout.str());
|
||||
|
||||
checkConst("class Fred {\n"
|
||||
" const std::string foo() { return ""; }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) The function 'Fred::foo' can be const\n", errout.str());
|
||||
|
||||
checkConst("class Fred {\n"
|
||||
" std::string s;\n"
|
||||
" const std::string & foo() { return ""; }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) The function 'Fred::foo' can be const\n", errout.str());
|
||||
|
||||
// constructors can't be const..
|
||||
checkConst("class Fred {\n"
|
||||
" int a;\n"
|
||||
|
|
Loading…
Reference in New Issue