Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/checkclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2567,7 +2567,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, Member
return false;
if (Token::Match(tok1->previous(), "( this . * %var% )")) // call using ptr to member function TODO: check constness
return false;
if (Token::simpleMatch(tok1->astParent(), "*") && tok1->astParent()->astParent() && tok1->astParent()->astParent()->isIncDecOp())
if (Token::simpleMatch(tok1->astParent(), "*"))
return false;
}

Expand Down
17 changes: 16 additions & 1 deletion test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6974,13 +6974,28 @@ class TestClass : public TestFixture {
}

void const101() {
checkConst("struct error {\n"
checkConst("struct error {\n" // #14450
" error() = default;\n"
"};\n"
"struct S : U {\n"
" int f() { return this->error(); }\n"
"};\n");
ASSERT_EQUALS("", errout_str());

checkConst("struct S {\n" // #14702
" int i;\n"
" void f() {\n"
" S& r = *this;\n"
" r.i = 0;\n"
" }\n"
"};\n"
"struct T : std::array<int, 5> {\n"
" void g() {\n"
" for (int& r : *this)\n"
" r = 0;\n"
" }\n"
"};\n");
ASSERT_EQUALS("", errout_str());
}

void const_handleDefaultParameters() {
Expand Down
Loading