isPointerDeref: Return false for function declarations

This commit is contained in:
Daniel Marjamäki 2019-12-15 16:36:46 +01:00
parent aee9519d21
commit 36f369473e
2 changed files with 9 additions and 0 deletions

View File

@ -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;

View File

@ -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("");