This commit is contained in:
parent
204e75dc59
commit
88a9119f88
|
@ -988,6 +988,14 @@ void CheckClass::initializeVarList(const Function &func, std::list<const Functio
|
|||
else if (!member->isConst() && !member->isStatic()) {
|
||||
assignAllVar(usage);
|
||||
}
|
||||
|
||||
// const method, assume it assigns all mutable members
|
||||
else if (member->isConst()) {
|
||||
for (Usage& i: usage) {
|
||||
if (i.var->isMutable())
|
||||
i.assign = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// not member function
|
||||
|
|
|
@ -116,6 +116,7 @@ private:
|
|||
TEST_CASE(initvar_chained_assign); // BUG 2270433
|
||||
TEST_CASE(initvar_2constructors); // BUG 2270353
|
||||
TEST_CASE(initvar_constvar);
|
||||
TEST_CASE(initvar_mutablevar);
|
||||
TEST_CASE(initvar_staticvar);
|
||||
TEST_CASE(initvar_brace_init);
|
||||
TEST_CASE(initvar_union);
|
||||
|
@ -1194,6 +1195,18 @@ private:
|
|||
}
|
||||
|
||||
|
||||
void initvar_mutablevar() {
|
||||
check("class Foo {\n"
|
||||
"public:\n"
|
||||
" Foo() { update(); }\n"
|
||||
"private:\n"
|
||||
" void update() const;\n"
|
||||
" mutable int x;\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
void initvar_staticvar() {
|
||||
check("class Fred\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue