Fixed #1491 (False positive when putting an access specifier at the end of a class declaration)
This commit is contained in:
parent
f7662b094d
commit
846a3a0186
|
@ -1532,7 +1532,7 @@ 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)
|
||||||
tok2 = tok2->next();
|
continue;
|
||||||
|
|
||||||
// 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
|
||||||
|
|
|
@ -89,6 +89,7 @@ private:
|
||||||
TEST_CASE(const3);
|
TEST_CASE(const3);
|
||||||
TEST_CASE(const4);
|
TEST_CASE(const4);
|
||||||
TEST_CASE(const5); // ticket #1482
|
TEST_CASE(const5); // ticket #1482
|
||||||
|
TEST_CASE(const6); // ticket #1491
|
||||||
TEST_CASE(constoperator); // operator< can often be const
|
TEST_CASE(constoperator); // operator< can often be const
|
||||||
TEST_CASE(constincdec); // increment/decrement => non-const
|
TEST_CASE(constincdec); // increment/decrement => non-const
|
||||||
TEST_CASE(constReturnReference);
|
TEST_CASE(constReturnReference);
|
||||||
|
@ -2064,6 +2065,16 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:3]: (style) The function 'A::foo' can be const\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:3]: (style) The function 'A::foo' can be const\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void const6()
|
||||||
|
{
|
||||||
|
// ticket # 1491
|
||||||
|
checkConst("class foo {\n"
|
||||||
|
"public:\n"
|
||||||
|
"};\n"
|
||||||
|
"void bar() {}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
// increment/decrement => not const
|
// increment/decrement => not const
|
||||||
void constincdec()
|
void constincdec()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue