Fixed #1491 (False positive when putting an access specifier at the end of a class declaration)
This commit is contained in:
parent
54c5d53eac
commit
92fe14e7f0
|
@ -1536,7 +1536,11 @@ void CheckClass::checkConst()
|
||||||
|
|
||||||
// skip private: public: etc
|
// skip private: public: etc
|
||||||
if (tok2->isName() && tok2->str().find(":") != std::string::npos)
|
if (tok2->isName() && tok2->str().find(":") != std::string::npos)
|
||||||
continue;
|
{
|
||||||
|
if (tok2->next()->str() == "}")
|
||||||
|
continue;
|
||||||
|
tok2 = tok2->next();
|
||||||
|
}
|
||||||
|
|
||||||
// static functions can't be const
|
// static functions can't be const
|
||||||
// virtual functions may be non-const for a reason
|
// virtual functions may be non-const for a reason
|
||||||
|
|
|
@ -2093,6 +2093,13 @@ private:
|
||||||
"};\n"
|
"};\n"
|
||||||
"void bar() {}");
|
"void bar() {}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkConst("class Fred\n"
|
||||||
|
"{\n"
|
||||||
|
"public:\n"
|
||||||
|
" void foo() { }\n"
|
||||||
|
"};");
|
||||||
|
ASSERT_EQUALS("[test.cpp:4]: (style) The function 'Fred::foo' can be const\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void const7()
|
void const7()
|
||||||
|
|
Loading…
Reference in New Issue