Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix #3052 (False Positive - Technically the member function 'Example:…

…:Clear' can be const.)
  • Loading branch information...
commit 9a0d076295168400219e828a361dbc6e5ca63a98 1 parent d643397
IOBYTE IOBYTE authored
Showing with 14 additions and 0 deletions.
  1. +4 −0 lib/checkclass.cpp
  2. +10 −0 test/testclass.cpp
4 lib/checkclass.cpp
View
@@ -1413,6 +1413,10 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok)
{
return true;
}
+ else if (Token::Match(tok->tokAt(-3), "( * this )"))
+ {
+ return true;
+ }
else if (Token::Match(tok->tokAt(-2), "%var% . %var%"))
{
tok = tok->tokAt(-2);
10 test/testclass.cpp
View
@@ -181,6 +181,7 @@ class TestClass : public TestFixture
TEST_CASE(const50); // ticket #2943
TEST_CASE(const51); // ticket #3040
TEST_CASE(const52); // ticket #3049
+ TEST_CASE(const53); // ticket #3052
TEST_CASE(assigningPointerToPointerIsNotAConstOperation);
TEST_CASE(assigningArrayElementIsNotAConstOperation);
TEST_CASE(constoperator1); // operator< can often be const
@@ -5711,6 +5712,15 @@ class TestClass : public TestFixture
ASSERT_EQUALS("", errout.str());
}
+ void const53() // ticket 3052
+ {
+ checkConst("class Example {\n"
+ " public:\n"
+ " void Clear(void) { Example tmp; (*this) = tmp; }\n"
+ "};\n");
+ ASSERT_EQUALS("", errout.str());
+ }
+
void assigningPointerToPointerIsNotAConstOperation()
{
checkConst("struct s\n"
Please sign in to comment.
Something went wrong with that request. Please try again.