Fixed #1304 (False positive: The function 'x' can be const when modifing a member)
This commit is contained in:
parent
5b76be4935
commit
9a6b450501
|
@ -1455,8 +1455,18 @@ void CheckClass::checkConst()
|
|||
break;
|
||||
--indentlevel;
|
||||
}
|
||||
|
||||
// assignment.. = += |= ..
|
||||
else if (tok3->str() == "=" ||
|
||||
Token::Match(tok, "%var% ("))
|
||||
(tok3->str().find("=") == 1 &&
|
||||
tok3->str().find_first_of("<>") == std::string::npos))
|
||||
{
|
||||
isconst = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// function call..
|
||||
else if (Token::Match(tok, "%var% ("))
|
||||
{
|
||||
isconst = false;
|
||||
break;
|
||||
|
|
|
@ -1539,6 +1539,13 @@ private:
|
|||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// assignment through |=..
|
||||
checkConst("class Fred {\n"
|
||||
" int a;\n"
|
||||
" int setA() { a |= true; }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue