Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…:Clear' can be const.)
  • Loading branch information...
commit 9a0d076295168400219e828a361dbc6e5ca63a98 1 parent d643397
IOBYTE authored August 28, 2011
4  lib/checkclass.cpp
@@ -1413,6 +1413,10 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok)
1413 1413
         {
1414 1414
             return true;
1415 1415
         }
  1416
+        else if (Token::Match(tok->tokAt(-3), "( * this )"))
  1417
+        {
  1418
+            return true;
  1419
+        }
1416 1420
         else if (Token::Match(tok->tokAt(-2), "%var% . %var%"))
1417 1421
         {
1418 1422
             tok = tok->tokAt(-2);
10  test/testclass.cpp
@@ -181,6 +181,7 @@ class TestClass : public TestFixture
181 181
         TEST_CASE(const50); // ticket #2943
182 182
         TEST_CASE(const51); // ticket #3040
183 183
         TEST_CASE(const52); // ticket #3049
  184
+        TEST_CASE(const53); // ticket #3052
184 185
         TEST_CASE(assigningPointerToPointerIsNotAConstOperation);
185 186
         TEST_CASE(assigningArrayElementIsNotAConstOperation);
186 187
         TEST_CASE(constoperator1);  // operator< can often be const
@@ -5711,6 +5712,15 @@ class TestClass : public TestFixture
5711 5712
         ASSERT_EQUALS("", errout.str());
5712 5713
     }
5713 5714
 
  5715
+    void const53() // ticket 3052
  5716
+    {
  5717
+        checkConst("class Example {\n"
  5718
+                   "  public:\n"
  5719
+                   "    void Clear(void) { Example tmp; (*this) = tmp; }\n"
  5720
+                   "};\n");
  5721
+        ASSERT_EQUALS("", errout.str());
  5722
+    }
  5723
+
5714 5724
     void assigningPointerToPointerIsNotAConstOperation()
5715 5725
     {
5716 5726
         checkConst("struct s\n"

0 notes on commit 9a0d076

Please sign in to comment.
Something went wrong with that request. Please try again.