Fixed #1708 (False positive for const)
This commit is contained in:
parent
5692e7a6f6
commit
4306082fcf
|
@ -192,9 +192,11 @@ CheckClass::Var *CheckClass::getVarList(const Token *tok1, bool withClasses, boo
|
|||
}
|
||||
if (next && Token::Match(next, "> %var% ;"))
|
||||
varname = next->strAt(1);
|
||||
else if (next && Token::Match(next, "> * %var% ;"))
|
||||
varname = next->strAt(2);
|
||||
}
|
||||
|
||||
// If the varname was set in one of the two if-block above, create a entry for this variable..
|
||||
// If the varname was set in the if-blocks above, create a entry for this variable..
|
||||
if (!varname.empty() && varname != "operator")
|
||||
{
|
||||
Var *var = new Var(varname, false, priv, isMutable, isStatic, varlist);
|
||||
|
@ -1905,6 +1907,9 @@ bool CheckClass::isMemberVar(const std::string &classname, const Var *varlist, c
|
|||
if (tok->str() == "this")
|
||||
return true;
|
||||
|
||||
if (Token::Match(tok, "( * %var% ) ["))
|
||||
tok = tok->tokAt(2);
|
||||
|
||||
// ignore class namespace
|
||||
if (tok->str() == classname && tok->next()->str() == "::")
|
||||
tok = tok->tokAt(2);
|
||||
|
|
|
@ -119,6 +119,7 @@ private:
|
|||
TEST_CASE(const21); // ticket #1683
|
||||
TEST_CASE(const22);
|
||||
TEST_CASE(const23); // ticket #1699
|
||||
TEST_CASE(const24); // ticket #1708
|
||||
TEST_CASE(constoperator1); // operator< can often be const
|
||||
TEST_CASE(constoperator2); // operator<<
|
||||
TEST_CASE(constincdec); // increment/decrement => non-const
|
||||
|
@ -3410,6 +3411,20 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void const24()
|
||||
{
|
||||
checkConst("class Class {\n"
|
||||
"public:\n"
|
||||
"void Settings::SetSetting(QString strSetting, QString strNewVal)\n"
|
||||
"{\n"
|
||||
" (*m_pSettings)[strSetting] = strNewVal;\n"
|
||||
"}\n"
|
||||
"private:\n"
|
||||
" std::map<QString, QString> *m_pSettings;\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// increment/decrement => not const
|
||||
void constincdec()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue