small const fix
This commit is contained in:
parent
904597a8ce
commit
89c57c72c5
|
@ -1739,7 +1739,7 @@ bool CheckClass::isMemberVar(const Var *varlist, const Token *tok)
|
|||
{
|
||||
while (tok->previous() && !Token::Match(tok->previous(), "}|{|;|public:|protected:|private:"))
|
||||
{
|
||||
if (tok->previous()->str() == "this" && tok->tokAt(-2)->str() == "*")
|
||||
if (Token::Match(tok->previous(), "* this"))
|
||||
return true;
|
||||
|
||||
tok = tok->previous();
|
||||
|
|
|
@ -91,6 +91,7 @@ private:
|
|||
TEST_CASE(const4);
|
||||
TEST_CASE(const5); // ticket #1482
|
||||
TEST_CASE(const6); // ticket #1491
|
||||
TEST_CASE(const7);
|
||||
TEST_CASE(constoperator); // operator< can often be const
|
||||
TEST_CASE(constincdec); // increment/decrement => non-const
|
||||
TEST_CASE(constReturnReference);
|
||||
|
@ -2094,6 +2095,18 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void const7()
|
||||
{
|
||||
checkConst("class foo {\n"
|
||||
" int a;\n"
|
||||
"public:\n"
|
||||
" void set(int i) { a = i; }\n"
|
||||
" void set(const foo & f) { *this = f; }\n"
|
||||
"};\n"
|
||||
"void bar() {}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// increment/decrement => not const
|
||||
void constincdec()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue