Fixed #1491 (False positive when putting an access specifier at the end of a class declaration)

This commit is contained in:
Robert Reif 2010-03-19 17:40:23 +01:00 committed by Daniel Marjamäki
parent 54c5d53eac
commit 92fe14e7f0
2 changed files with 12 additions and 1 deletions

View File

@ -1536,7 +1536,11 @@ void CheckClass::checkConst()
// skip private: public: etc
if (tok2->isName() && tok2->str().find(":") != std::string::npos)
continue;
{
if (tok2->next()->str() == "}")
continue;
tok2 = tok2->next();
}
// static functions can't be const
// virtual functions may be non-const for a reason

View File

@ -2093,6 +2093,13 @@ private:
"};\n"
"void bar() {}");
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()