Fixed #1529 (false positive: function can be const (struct member variable))
This commit is contained in:
parent
258e7e292e
commit
307000b448
|
@ -123,6 +123,12 @@ CheckClass::Var *CheckClass::getVarList(const Token *tok1, bool withClasses, boo
|
|||
varname = next->strAt(1);
|
||||
}
|
||||
|
||||
// Structure?
|
||||
else if (Token::Match(next, "struct|union %type% %var% ;"))
|
||||
{
|
||||
varname = next->strAt(2);
|
||||
}
|
||||
|
||||
// Pointer?
|
||||
else if (Token::Match(next, "%type% * %var% ;"))
|
||||
{
|
||||
|
|
|
@ -97,6 +97,7 @@ private:
|
|||
TEST_CASE(const8); // ticket #1517
|
||||
TEST_CASE(const9); // ticket #1515
|
||||
TEST_CASE(const10); // ticket #1522
|
||||
TEST_CASE(const11); // ticket #1529
|
||||
TEST_CASE(constoperator); // operator< can often be const
|
||||
TEST_CASE(constincdec); // increment/decrement => non-const
|
||||
TEST_CASE(constReturnReference);
|
||||
|
@ -2216,6 +2217,18 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void const11()
|
||||
{
|
||||
// ticket #1529
|
||||
checkConst("class A {\n"
|
||||
"public:\n"
|
||||
" void set(struct tm time) { m_time = time; }\n"
|
||||
"private:\n"
|
||||
" struct tm m_time;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// increment/decrement => not const
|
||||
void constincdec()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue