diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index ce656a567..e6750cecc 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -166,6 +166,9 @@ bool CheckNullPointer::isPointerDeRef(const Token *tok, bool &unknown, const Set } } + if (tok->str() == "(" && !tok->scope()->isExecutable()) + return false; + const Token* parent = tok->astParent(); if (!parent) return false; diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 4ad2cc500..7aaa0408a 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -116,6 +116,7 @@ private: TEST_CASE(ticket6505); TEST_CASE(subtract); TEST_CASE(addNull); + TEST_CASE(isPointerDeRefFunctionDecl); TEST_CASE(ctu); } @@ -3053,6 +3054,11 @@ private: ASSERT_EQUALS("", errout.str()); } + void isPointerDeRefFunctionDecl() { + check("const char** get() { return 0; }"); + ASSERT_EQUALS("", errout.str()); + } + void ctu(const char code[]) { // Clear the error buffer.. errout.str("");