Skip to content

Commit 36f3694

Browse files
committed
isPointerDeref: Return false for function declarations
1 parent aee9519 commit 36f3694

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

lib/checknullpointer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ bool CheckNullPointer::isPointerDeRef(const Token *tok, bool &unknown, const Set
166166
}
167167
}
168168

169+
if (tok->str() == "(" && !tok->scope()->isExecutable())
170+
return false;
171+
169172
const Token* parent = tok->astParent();
170173
if (!parent)
171174
return false;

test/testnullpointer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class TestNullPointer : public TestFixture {
116116
TEST_CASE(ticket6505);
117117
TEST_CASE(subtract);
118118
TEST_CASE(addNull);
119+
TEST_CASE(isPointerDeRefFunctionDecl);
119120

120121
TEST_CASE(ctu);
121122
}
@@ -3053,6 +3054,11 @@ class TestNullPointer : public TestFixture {
30533054
ASSERT_EQUALS("", errout.str());
30543055
}
30553056

3057+
void isPointerDeRefFunctionDecl() {
3058+
check("const char** get() { return 0; }");
3059+
ASSERT_EQUALS("", errout.str());
3060+
}
3061+
30563062
void ctu(const char code[]) {
30573063
// Clear the error buffer..
30583064
errout.str("");

0 commit comments

Comments
 (0)