diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 40ea68a7d..2cfb188c3 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -150,13 +150,14 @@ CheckClass::Var *CheckClass::getVarList(const Token *tok1, bool withClasses, boo } // std::string.. - else if (withClasses && Token::Match(next, "std :: string %var% ;")) + else if (withClasses && Token::Match(next, "%type% :: %type% %var% ;")) { varname = next->strAt(3); } // Container.. - else if (withClasses && Token::Match(next, "std :: %type% <")) + else if (withClasses && (Token::Match(next, "%type% :: %type% <") || + Token::Match(next, "%type% <"))) { while (next && next->str() != ">") next = next->next(); diff --git a/test/testclass.cpp b/test/testclass.cpp index 86969f53f..65be780e4 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -93,6 +93,7 @@ private: TEST_CASE(const6); // ticket #1491 TEST_CASE(const7); TEST_CASE(const8); // ticket #1517 + TEST_CASE(const9); // ticket #1515 TEST_CASE(constoperator); // operator< can often be const TEST_CASE(constincdec); // increment/decrement => non-const TEST_CASE(constReturnReference); @@ -2142,6 +2143,18 @@ private: ASSERT_EQUALS("[test.cpp:4]: (style) The function 'A::strGetString' can be const\n", errout.str()); } + void const9() + { + // ticket #1515 + checkConst("class wxThreadInternal {\n" + "public:\n" + " void SetExitCode(wxThread::ExitCode exitcode) { m_exitcode = exitcode; }\n" + "private:\n" + " wxThread::ExitCode m_exitcode;\n" + "}"); + ASSERT_EQUALS("", errout.str()); + } + // increment/decrement => not const void constincdec() {