From c07fb0bd0a56d2f4a040a0b06a5d00de9444895b Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 27 Jun 2015 01:07:48 +0300 Subject: Allow check function pointers in arrays. --- src/analysis/expression.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/analysis/expression.cpp b/src/analysis/expression.cpp index 4d4c429..2c0dba3 100644 --- a/src/analysis/expression.cpp +++ b/src/analysis/expression.cpp @@ -49,6 +49,7 @@ #include "nodes/decl/function_decl.h" #include "nodes/decl/var_decl.h" +#include "nodes/ref/array_ref.h" #include "nodes/ref/component_ref.h" #include "nodes/ref/indirect_ref.h" @@ -458,16 +459,18 @@ void analyseCallExpr(CallExprNode *node, const WalkItem &wi, WalkItem &wo) if (node->function) { walkTree(node->function, wi, wo2); + Node *function = skipNop(node->function); Log::dumpWI(node, "wo function ", wo2); - if (node->function == ADDR_EXPR) + if (function == ADDR_EXPR) { - AddrExprNode *addrNode = static_cast(node->function); + AddrExprNode *addrNode = static_cast(function); if (!addrNode->args.empty()) { - if (addrNode->args[0] == FUNCTION_DECL) + Node *decl = skipNop(addrNode->args[0]); + if (decl == FUNCTION_DECL) { FunctionDeclNode *declNode = static_cast( - addrNode->args[0]); + decl); if (declNode->functionType == FUNCTION_TYPE) { enableCheck = false; @@ -481,8 +484,14 @@ void analyseCallExpr(CallExprNode *node, const WalkItem &wi, WalkItem &wo) } else { - reportParmDeclNullPointer(node, node->function, wi); - if (!getVariableName(node->function).empty()) + if (function == ARRAY_REF) + { + ArrayRefNode *arrRef = static_cast(function); + if (!arrRef->args.empty() && arrRef->args[0] == COMPONENT_REF) + function = arrRef->args[0]; + } + reportParmDeclNullPointer(node, function, wi); + if (!getVariableName(function).empty()) enableCheck = false; } } -- cgit v1.2.3-70-g09d2