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
6 changes: 1 addition & 5 deletions lib/checkassert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,8 @@ void CheckAssertImpl::assertWithSideEffects()

const Function* f = tmp->function();
const Scope* scope = f->functionScope;
if (!scope) {
// guess that const method doesn't have side effects
if (f->nestedIn->isClassOrStruct() && !f->isConst() && !f->isStatic())
sideEffectInAssertError(tmp, f->name()); // Non-const member function called, assume it has side effects
if (!scope)
continue;
}

for (const Token *tok2 = scope->bodyStart; tok2 != scope->bodyEnd; tok2 = tok2->next()) {
if (!tok2->isAssignmentOp() && tok2->tokType() != Token::eIncDecOp)
Expand Down
2 changes: 1 addition & 1 deletion test/testassert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class TestAssert : public TestFixture {
"void foo(SquarePack s) {\n"
" assert( s.Foo() );\n"
"}");
ASSERT_EQUALS("[test.cpp:5:14]: (warning) Assert statement calls a function which may have desired side effects: 'Foo'. [assertWithSideEffect]\n", errout_str());
ASSERT_EQUALS("", errout_str());

check("struct SquarePack {\n"
" int Foo() const;\n"
Expand Down
Loading