File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ void CheckAssert::assertWithSideEffects()
6868 for (const Token *tok2 = scope->classStart ; tok2 != scope->classEnd ; tok2 = tok2->next ()) {
6969 if (tok2->type () != Token::eAssignmentOp && tok2->type () != Token::eIncDecOp) continue ;
7070 const Variable* var = tok2->previous ()->variable ();
71- if (!var) continue ;
71+ if (!var || var-> isLocal () ) continue ;
7272
7373 std::vector<const Token*> returnTokens; // find all return statements
7474 for (const Token *rt = scope->classStart ; rt != scope->classEnd ; rt = rt->next ()) {
Original file line number Diff line number Diff line change @@ -68,6 +68,15 @@ class TestAssert : public TestFixture {
6868 " assert(foo() == 3); \n "
6969 );
7070 ASSERT_EQUALS (" " , errout.str ());
71+
72+ check (
73+ " int foo(int a) {\n "
74+ " int b=a+1;\n "
75+ " return b;\n "
76+ " }\n "
77+ " assert(foo(1) == 2); \n "
78+ );
79+ ASSERT_EQUALS (" " , errout.str ());
7180 }
7281
7382 void functionCallInAssert () {
@@ -138,4 +147,4 @@ class TestAssert : public TestFixture {
138147 }
139148};
140149
141- REGISTER_TEST (TestAssert)
150+ REGISTER_TEST (TestAssert)
You can’t perform that action at this time.
0 commit comments