File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,6 +78,11 @@ void CheckAssertImpl::assertWithSideEffects()
7878 continue ;
7979 }
8080
81+ const Token* parent = tmp->astParent ();
82+ while (Token::Match (parent, " .|::" ))
83+ parent = parent->astParent ();
84+ if (!Token::simpleMatch (parent, " (" ))
85+ continue ;
8186 const Function* f = tmp->function ();
8287 const Scope* scope = f->functionScope ;
8388 if (!scope) {
Original file line number Diff line number Diff line change @@ -147,6 +147,17 @@ class TestAssert : public TestFixture {
147147 " assert(g());\n "
148148 " }\n " );
149149 ASSERT_EQUALS (" " , errout_str ());
150+
151+ check (" int i;\n " // #14973
152+ " bool f() {\n "
153+ " i = 0;\n "
154+ " return true;\n "
155+ " }\n "
156+ " void g() {\n "
157+ " bool (*fp)() = f;\n "
158+ " assert(fp == f);\n "
159+ " }\n " );
160+ ASSERT_EQUALS (" " , errout_str ());
150161 }
151162
152163 void memberFunctionCallInAssert () {
You can’t perform that action at this time.
0 commit comments